hexsha stringlengths 40 40 | size int64 19 11.4M | ext stringclasses 13 values | lang stringclasses 1 value | max_stars_repo_path stringlengths 3 270 | max_stars_repo_name stringlengths 5 110 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 270 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 270 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 19 11.4M | avg_line_length float64 1.93 229k | max_line_length int64 12 688k | alphanum_fraction float64 0.07 0.99 | matches listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
74dee206c0ee79370dfdc6f8a43e5999552ed788 | 43,649 | cpp | C++ | src/blender/blender_shader.cpp | alecsavvy/cycles | 2ad08fa83a7b0ad275a97bc183db34a9c98d6384 | [
"Apache-2.0"
] | null | null | null | src/blender/blender_shader.cpp | alecsavvy/cycles | 2ad08fa83a7b0ad275a97bc183db34a9c98d6384 | [
"Apache-2.0"
] | null | null | null | src/blender/blender_shader.cpp | alecsavvy/cycles | 2ad08fa83a7b0ad275a97bc183db34a9c98d6384 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2011-2013 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "background.h"
#include "graph.h"
#include "light.h"
#include "nodes.h"
#include "osl.h"
#include "scene.h"
#include "shader.h"
#include "blender_texture.h"
#include "blender_sync.h"
#include "blender_util.h"
#include "util_debug.h"
CCL_NAMESPACE_BEGIN
typedef map<void*, ShaderInput*> PtrInputMap;
typedef map<void*, ShaderOutput*> PtrOutputMap;
typedef map<std::string, ProxyNode*> ProxyMap;
/* Find */
void BlenderSync::find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader)
{
Shader *shader = (id)? shader_map.find(id): scene->shaders[default_shader];
for(size_t i = 0; i < scene->shaders.size(); i++) {
if(scene->shaders[i] == shader) {
used_shaders.push_back(i);
scene->shaders[i]->tag_used(scene);
break;
}
}
}
/* Graph */
static BL::NodeSocket get_node_output(BL::Node b_node, const string& name)
{
BL::Node::outputs_iterator b_out;
for(b_node.outputs.begin(b_out); b_out != b_node.outputs.end(); ++b_out)
if(b_out->name() == name)
return *b_out;
assert(0);
return *b_out;
}
static float3 get_node_output_rgba(BL::Node b_node, const string& name)
{
BL::NodeSocket b_sock = get_node_output(b_node, name);
float value[4];
RNA_float_get_array(&b_sock.ptr, "default_value", value);
return make_float3(value[0], value[1], value[2]);
}
static float get_node_output_value(BL::Node b_node, const string& name)
{
BL::NodeSocket b_sock = get_node_output(b_node, name);
return RNA_float_get(&b_sock.ptr, "default_value");
}
static float3 get_node_output_vector(BL::Node b_node, const string& name)
{
BL::NodeSocket b_sock = get_node_output(b_node, name);
float value[3];
RNA_float_get_array(&b_sock.ptr, "default_value", value);
return make_float3(value[0], value[1], value[2]);
}
static ShaderSocketType convert_socket_type(BL::NodeSocket b_socket)
{
switch(b_socket.type()) {
case BL::NodeSocket::type_VALUE:
return SHADER_SOCKET_FLOAT;
case BL::NodeSocket::type_INT:
return SHADER_SOCKET_INT;
case BL::NodeSocket::type_VECTOR:
return SHADER_SOCKET_VECTOR;
case BL::NodeSocket::type_RGBA:
return SHADER_SOCKET_COLOR;
case BL::NodeSocket::type_STRING:
return SHADER_SOCKET_STRING;
case BL::NodeSocket::type_SHADER:
return SHADER_SOCKET_CLOSURE;
default:
return SHADER_SOCKET_UNDEFINED;
}
}
#ifdef WITH_OSL
static ShaderSocketType convert_osl_socket_type(OSL::OSLQuery& query,
BL::NodeSocket b_socket)
{
ShaderSocketType socket_type = convert_socket_type(b_socket);
#if OSL_LIBRARY_VERSION_CODE < 10701
(void) query;
#else
if(socket_type == SHADER_SOCKET_VECTOR) {
/* TODO(sergey): Do we need compatible_name() here? */
const OSL::OSLQuery::Parameter *param = query.getparam(b_socket.name());
assert(param != NULL);
if(param != NULL) {
if(param->type.vecsemantics == TypeDesc::POINT) {
socket_type = SHADER_SOCKET_POINT;
}
else if(param->type.vecsemantics == TypeDesc::NORMAL) {
socket_type = SHADER_SOCKET_NORMAL;
}
}
}
#endif
return socket_type;
}
#endif /* WITH_OSL */
static void set_default_value(ShaderInput *input, BL::NodeSocket b_sock, BL::BlendData b_data, BL::ID b_id)
{
/* copy values for non linked inputs */
switch(input->type) {
case SHADER_SOCKET_FLOAT: {
input->set(get_float(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_INT: {
input->set((float)get_int(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_COLOR: {
input->set(float4_to_float3(get_float4(b_sock.ptr, "default_value")));
break;
}
case SHADER_SOCKET_NORMAL:
case SHADER_SOCKET_POINT:
case SHADER_SOCKET_VECTOR: {
input->set(get_float3(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_STRING: {
input->set((ustring)blender_absolute_path(b_data, b_id, get_string(b_sock.ptr, "default_value")));
break;
}
case SHADER_SOCKET_CLOSURE:
case SHADER_SOCKET_UNDEFINED:
break;
}
}
static void get_tex_mapping(TextureMapping *mapping, BL::TexMapping b_mapping)
{
if(!b_mapping)
return;
mapping->translation = get_float3(b_mapping.translation());
mapping->rotation = get_float3(b_mapping.rotation());
mapping->scale = get_float3(b_mapping.scale());
mapping->type = (TextureMapping::Type)b_mapping.vector_type();
mapping->x_mapping = (TextureMapping::Mapping)b_mapping.mapping_x();
mapping->y_mapping = (TextureMapping::Mapping)b_mapping.mapping_y();
mapping->z_mapping = (TextureMapping::Mapping)b_mapping.mapping_z();
}
static void get_tex_mapping(TextureMapping *mapping, BL::ShaderNodeMapping b_mapping)
{
if(!b_mapping)
return;
mapping->translation = get_float3(b_mapping.translation());
mapping->rotation = get_float3(b_mapping.rotation());
mapping->scale = get_float3(b_mapping.scale());
mapping->type = (TextureMapping::Type)b_mapping.vector_type();
mapping->use_minmax = b_mapping.use_min() || b_mapping.use_max();
if(b_mapping.use_min())
mapping->min = get_float3(b_mapping.min());
if(b_mapping.use_max())
mapping->max = get_float3(b_mapping.max());
}
static bool is_output_node(BL::Node b_node)
{
return (b_node.is_a(&RNA_ShaderNodeOutputMaterial)
|| b_node.is_a(&RNA_ShaderNodeOutputWorld)
|| b_node.is_a(&RNA_ShaderNodeOutputLamp));
}
static ShaderNode *add_node(Scene *scene,
BL::RenderEngine b_engine,
BL::BlendData b_data,
BL::Scene b_scene,
const bool background,
ShaderGraph *graph,
BL::ShaderNodeTree b_ntree,
BL::ShaderNode b_node)
{
ShaderNode *node = NULL;
/* existing blender nodes */
if(b_node.is_a(&RNA_ShaderNodeRGBCurve)) {
BL::ShaderNodeRGBCurve b_curve_node(b_node);
BL::CurveMapping mapping(b_curve_node.mapping());
RGBCurvesNode *curves = new RGBCurvesNode();
curvemapping_color_to_array(mapping,
curves->curves,
RAMP_TABLE_SIZE,
true);
curvemapping_minmax(mapping, true, &curves->min_x, &curves->max_x);
node = curves;
}
if(b_node.is_a(&RNA_ShaderNodeVectorCurve)) {
BL::ShaderNodeVectorCurve b_curve_node(b_node);
VectorCurvesNode *curves = new VectorCurvesNode();
curvemapping_color_to_array(b_curve_node.mapping(), curves->curves, RAMP_TABLE_SIZE, false);
node = curves;
}
else if(b_node.is_a(&RNA_ShaderNodeValToRGB)) {
RGBRampNode *ramp = new RGBRampNode();
BL::ShaderNodeValToRGB b_ramp_node(b_node);
colorramp_to_array(b_ramp_node.color_ramp(), ramp->ramp, RAMP_TABLE_SIZE);
ramp->interpolate = b_ramp_node.color_ramp().interpolation() != BL::ColorRamp::interpolation_CONSTANT;
node = ramp;
}
else if(b_node.is_a(&RNA_ShaderNodeRGB)) {
ColorNode *color = new ColorNode();
color->value = get_node_output_rgba(b_node, "Color");
node = color;
}
else if(b_node.is_a(&RNA_ShaderNodeValue)) {
ValueNode *value = new ValueNode();
value->value = get_node_output_value(b_node, "Value");
node = value;
}
else if(b_node.is_a(&RNA_ShaderNodeCameraData)) {
node = new CameraNode();
}
else if(b_node.is_a(&RNA_ShaderNodeInvert)) {
node = new InvertNode();
}
else if(b_node.is_a(&RNA_ShaderNodeGamma)) {
node = new GammaNode();
}
else if(b_node.is_a(&RNA_ShaderNodeBrightContrast)) {
node = new BrightContrastNode();
}
else if(b_node.is_a(&RNA_ShaderNodeMixRGB)) {
BL::ShaderNodeMixRGB b_mix_node(b_node);
MixNode *mix = new MixNode();
mix->type = MixNode::type_enum[b_mix_node.blend_type()];
/* Tag if it's Mix */
if(b_mix_node.blend_type() == 0)
mix->special_type = SHADER_SPECIAL_TYPE_MIX_RGB;
mix->use_clamp = b_mix_node.use_clamp();
node = mix;
}
else if(b_node.is_a(&RNA_ShaderNodeSeparateRGB)) {
node = new SeparateRGBNode();
}
else if(b_node.is_a(&RNA_ShaderNodeCombineRGB)) {
node = new CombineRGBNode();
}
else if(b_node.is_a(&RNA_ShaderNodeSeparateHSV)) {
node = new SeparateHSVNode();
}
else if(b_node.is_a(&RNA_ShaderNodeCombineHSV)) {
node = new CombineHSVNode();
}
else if(b_node.is_a(&RNA_ShaderNodeSeparateXYZ)) {
node = new SeparateXYZNode();
}
else if(b_node.is_a(&RNA_ShaderNodeCombineXYZ)) {
node = new CombineXYZNode();
}
else if(b_node.is_a(&RNA_ShaderNodeHueSaturation)) {
node = new HSVNode();
}
else if(b_node.is_a(&RNA_ShaderNodeRGBToBW)) {
node = new ConvertNode(SHADER_SOCKET_COLOR, SHADER_SOCKET_FLOAT);
}
else if(b_node.is_a(&RNA_ShaderNodeMath)) {
BL::ShaderNodeMath b_math_node(b_node);
MathNode *math = new MathNode();
math->type = MathNode::type_enum[b_math_node.operation()];
math->use_clamp = b_math_node.use_clamp();
node = math;
}
else if(b_node.is_a(&RNA_ShaderNodeVectorMath)) {
BL::ShaderNodeVectorMath b_vector_math_node(b_node);
VectorMathNode *vmath = new VectorMathNode();
vmath->type = VectorMathNode::type_enum[b_vector_math_node.operation()];
node = vmath;
}
else if(b_node.is_a(&RNA_ShaderNodeVectorTransform)) {
BL::ShaderNodeVectorTransform b_vector_transform_node(b_node);
VectorTransformNode *vtransform = new VectorTransformNode();
vtransform->type = VectorTransformNode::type_enum[b_vector_transform_node.vector_type()];
vtransform->convert_from = VectorTransformNode::convert_space_enum[b_vector_transform_node.convert_from()];
vtransform->convert_to = VectorTransformNode::convert_space_enum[b_vector_transform_node.convert_to()];
node = vtransform;
}
else if(b_node.is_a(&RNA_ShaderNodeNormal)) {
BL::Node::outputs_iterator out_it;
b_node.outputs.begin(out_it);
NormalNode *norm = new NormalNode();
norm->direction = get_node_output_vector(b_node, "Normal");
node = norm;
}
else if(b_node.is_a(&RNA_ShaderNodeMapping)) {
BL::ShaderNodeMapping b_mapping_node(b_node);
MappingNode *mapping = new MappingNode();
get_tex_mapping(&mapping->tex_mapping, b_mapping_node);
node = mapping;
}
else if(b_node.is_a(&RNA_ShaderNodeFresnel)) {
node = new FresnelNode();
}
else if(b_node.is_a(&RNA_ShaderNodeLayerWeight)) {
node = new LayerWeightNode();
}
else if(b_node.is_a(&RNA_ShaderNodeAddShader)) {
node = new AddClosureNode();
}
else if(b_node.is_a(&RNA_ShaderNodeMixShader)) {
node = new MixClosureNode();
}
else if(b_node.is_a(&RNA_ShaderNodeAttribute)) {
BL::ShaderNodeAttribute b_attr_node(b_node);
AttributeNode *attr = new AttributeNode();
attr->attribute = b_attr_node.attribute_name();
node = attr;
}
else if(b_node.is_a(&RNA_ShaderNodeBackground)) {
node = new BackgroundNode();
}
else if(b_node.is_a(&RNA_ShaderNodeHoldout)) {
node = new HoldoutNode();
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfAnisotropic)) {
BL::ShaderNodeBsdfAnisotropic b_aniso_node(b_node);
AnisotropicBsdfNode *aniso = new AnisotropicBsdfNode();
switch(b_aniso_node.distribution()) {
case BL::ShaderNodeBsdfAnisotropic::distribution_BECKMANN:
aniso->distribution = ustring("Beckmann");
break;
case BL::ShaderNodeBsdfAnisotropic::distribution_GGX:
aniso->distribution = ustring("GGX");
break;
case BL::ShaderNodeBsdfAnisotropic::distribution_ASHIKHMIN_SHIRLEY:
aniso->distribution = ustring("Ashikhmin-Shirley");
break;
}
node = aniso;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfDiffuse)) {
node = new DiffuseBsdfNode();
}
else if(b_node.is_a(&RNA_ShaderNodeSubsurfaceScattering)) {
BL::ShaderNodeSubsurfaceScattering b_subsurface_node(b_node);
SubsurfaceScatteringNode *subsurface = new SubsurfaceScatteringNode();
switch(b_subsurface_node.falloff()) {
case BL::ShaderNodeSubsurfaceScattering::falloff_CUBIC:
subsurface->closure = CLOSURE_BSSRDF_CUBIC_ID;
break;
case BL::ShaderNodeSubsurfaceScattering::falloff_GAUSSIAN:
subsurface->closure = CLOSURE_BSSRDF_GAUSSIAN_ID;
break;
}
node = subsurface;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfGlossy)) {
BL::ShaderNodeBsdfGlossy b_glossy_node(b_node);
GlossyBsdfNode *glossy = new GlossyBsdfNode();
switch(b_glossy_node.distribution()) {
case BL::ShaderNodeBsdfGlossy::distribution_SHARP:
glossy->distribution = ustring("Sharp");
break;
case BL::ShaderNodeBsdfGlossy::distribution_BECKMANN:
glossy->distribution = ustring("Beckmann");
break;
case BL::ShaderNodeBsdfGlossy::distribution_GGX:
glossy->distribution = ustring("GGX");
break;
case BL::ShaderNodeBsdfGlossy::distribution_ASHIKHMIN_SHIRLEY:
glossy->distribution = ustring("Ashikhmin-Shirley");
break;
}
node = glossy;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfGlass)) {
BL::ShaderNodeBsdfGlass b_glass_node(b_node);
GlassBsdfNode *glass = new GlassBsdfNode();
switch(b_glass_node.distribution()) {
case BL::ShaderNodeBsdfGlass::distribution_SHARP:
glass->distribution = ustring("Sharp");
break;
case BL::ShaderNodeBsdfGlass::distribution_BECKMANN:
glass->distribution = ustring("Beckmann");
break;
case BL::ShaderNodeBsdfGlass::distribution_GGX:
glass->distribution = ustring("GGX");
break;
}
node = glass;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfRefraction)) {
BL::ShaderNodeBsdfRefraction b_refraction_node(b_node);
RefractionBsdfNode *refraction = new RefractionBsdfNode();
switch(b_refraction_node.distribution()) {
case BL::ShaderNodeBsdfRefraction::distribution_SHARP:
refraction->distribution = ustring("Sharp");
break;
case BL::ShaderNodeBsdfRefraction::distribution_BECKMANN:
refraction->distribution = ustring("Beckmann");
break;
case BL::ShaderNodeBsdfRefraction::distribution_GGX:
refraction->distribution = ustring("GGX");
break;
}
node = refraction;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfToon)) {
BL::ShaderNodeBsdfToon b_toon_node(b_node);
ToonBsdfNode *toon = new ToonBsdfNode();
switch(b_toon_node.component()) {
case BL::ShaderNodeBsdfToon::component_DIFFUSE:
toon->component = ustring("Diffuse");
break;
case BL::ShaderNodeBsdfToon::component_GLOSSY:
toon->component = ustring("Glossy");
break;
}
node = toon;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfHair)) {
BL::ShaderNodeBsdfHair b_hair_node(b_node);
HairBsdfNode *hair = new HairBsdfNode();
switch(b_hair_node.component()) {
case BL::ShaderNodeBsdfHair::component_Reflection:
hair->component = ustring("Reflection");
break;
case BL::ShaderNodeBsdfHair::component_Transmission:
hair->component = ustring("Transmission");
break;
}
node = hair;
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfTranslucent)) {
node = new TranslucentBsdfNode();
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfTransparent)) {
node = new TransparentBsdfNode();
}
else if(b_node.is_a(&RNA_ShaderNodeBsdfVelvet)) {
node = new VelvetBsdfNode();
}
else if(b_node.is_a(&RNA_ShaderNodeEmission)) {
node = new EmissionNode();
}
else if(b_node.is_a(&RNA_ShaderNodeAmbientOcclusion)) {
node = new AmbientOcclusionNode();
}
else if(b_node.is_a(&RNA_ShaderNodeVolumeScatter)) {
node = new ScatterVolumeNode();
}
else if(b_node.is_a(&RNA_ShaderNodeVolumeAbsorption)) {
node = new AbsorptionVolumeNode();
}
else if(b_node.is_a(&RNA_ShaderNodeNewGeometry)) {
node = new GeometryNode();
}
else if(b_node.is_a(&RNA_ShaderNodeWireframe)) {
BL::ShaderNodeWireframe b_wireframe_node(b_node);
WireframeNode *wire = new WireframeNode();
wire->use_pixel_size = b_wireframe_node.use_pixel_size();
node = wire;
}
else if(b_node.is_a(&RNA_ShaderNodeWavelength)) {
node = new WavelengthNode();
}
else if(b_node.is_a(&RNA_ShaderNodeBlackbody)) {
node = new BlackbodyNode();
}
else if(b_node.is_a(&RNA_ShaderNodeLightPath)) {
node = new LightPathNode();
}
else if(b_node.is_a(&RNA_ShaderNodeLightFalloff)) {
node = new LightFalloffNode();
}
else if(b_node.is_a(&RNA_ShaderNodeObjectInfo)) {
node = new ObjectInfoNode();
}
else if(b_node.is_a(&RNA_ShaderNodeParticleInfo)) {
node = new ParticleInfoNode();
}
else if(b_node.is_a(&RNA_ShaderNodeHairInfo)) {
node = new HairInfoNode();
}
else if(b_node.is_a(&RNA_ShaderNodeBump)) {
BL::ShaderNodeBump b_bump_node(b_node);
BumpNode *bump = new BumpNode();
bump->invert = b_bump_node.invert();
node = bump;
}
else if(b_node.is_a(&RNA_ShaderNodeScript)) {
#ifdef WITH_OSL
if(scene->shader_manager->use_osl()) {
/* create script node */
BL::ShaderNodeScript b_script_node(b_node);
OSLScriptNode *script_node = new OSLScriptNode();
OSLShaderManager *manager = (OSLShaderManager*)scene->shader_manager;
string bytecode_hash = b_script_node.bytecode_hash();
/* Gather additional information from the shader, such as
* input/output type info needed for proper node construction.
*/
OSL::OSLQuery query;
#if OSL_LIBRARY_VERSION_CODE >= 10701
if(!bytecode_hash.empty()) {
query.open_bytecode(b_script_node.bytecode());
}
else {
!OSLShaderManager::osl_query(query, b_script_node.filepath());
}
/* TODO(sergey): Add proper query info error parsing. */
#endif
/* Generate inputs/outputs from node sockets
*
* Note: the node sockets are generated from OSL parameters,
* so the names match those of the corresponding parameters exactly.
*
* Note 2: ShaderInput/ShaderOutput store shallow string copies only!
* Socket names must be stored in the extra lists instead. */
BL::Node::inputs_iterator b_input;
for(b_script_node.inputs.begin(b_input); b_input != b_script_node.inputs.end(); ++b_input) {
script_node->input_names.push_back(ustring(b_input->name()));
ShaderInput *input = script_node->add_input(script_node->input_names.back().c_str(),
convert_osl_socket_type(query, *b_input));
set_default_value(input, *b_input, b_data, b_ntree);
}
BL::Node::outputs_iterator b_output;
for(b_script_node.outputs.begin(b_output); b_output != b_script_node.outputs.end(); ++b_output) {
script_node->output_names.push_back(ustring(b_output->name()));
script_node->add_output(script_node->output_names.back().c_str(),
convert_osl_socket_type(query, *b_output));
}
/* load bytecode or filepath */
if(!bytecode_hash.empty()) {
/* loaded bytecode if not already done */
if(!manager->shader_test_loaded(bytecode_hash))
manager->shader_load_bytecode(bytecode_hash, b_script_node.bytecode());
script_node->bytecode_hash = bytecode_hash;
}
else {
/* set filepath */
script_node->filepath = blender_absolute_path(b_data, b_ntree, b_script_node.filepath());
}
node = script_node;
}
#else
(void)b_data;
(void)b_ntree;
#endif
}
else if(b_node.is_a(&RNA_ShaderNodeTexImage)) {
BL::ShaderNodeTexImage b_image_node(b_node);
BL::Image b_image(b_image_node.image());
ImageTextureNode *image = new ImageTextureNode();
if(b_image) {
/* builtin images will use callback-based reading because
* they could only be loaded correct from blender side
*/
bool is_builtin = b_image.packed_file() ||
b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
b_engine.is_preview();
if(is_builtin) {
/* for builtin images we're using image datablock name to find an image to
* read pixels from later
*
* also store frame number as well, so there's no differences in handling
* builtin names for packed images and movies
*/
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_image_node.image_user(), scene_frame);
image->filename = b_image.name() + "@" + string_printf("%d", image_frame);
image->builtin_data = b_image.ptr.data;
}
else {
image->filename = image_user_file_path(b_image_node.image_user(), b_image, b_scene.frame_current());
image->builtin_data = NULL;
}
image->animated = b_image_node.image_user().use_auto_refresh();
image->use_alpha = b_image.use_alpha();
/* TODO(sergey): Does not work properly when we change builtin type. */
if(b_image.is_updated()) {
scene->image_manager->tag_reload_image(
image->filename,
image->builtin_data,
(InterpolationType)b_image_node.interpolation(),
(ExtensionType)b_image_node.extension());
}
}
image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
image->interpolation = (InterpolationType)b_image_node.interpolation();
image->extension = (ExtensionType)b_image_node.extension();
image->projection_blend = b_image_node.projection_blend();
get_tex_mapping(&image->tex_mapping, b_image_node.texture_mapping());
node = image;
}
else if(b_node.is_a(&RNA_ShaderNodeTexEnvironment)) {
BL::ShaderNodeTexEnvironment b_env_node(b_node);
BL::Image b_image(b_env_node.image());
EnvironmentTextureNode *env = new EnvironmentTextureNode();
if(b_image) {
bool is_builtin = b_image.packed_file() ||
b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
b_engine.is_preview();
if(is_builtin) {
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_env_node.image_user(), scene_frame);
env->filename = b_image.name() + "@" + string_printf("%d", image_frame);
env->builtin_data = b_image.ptr.data;
}
else {
env->filename = image_user_file_path(b_env_node.image_user(), b_image, b_scene.frame_current());
env->animated = b_env_node.image_user().use_auto_refresh();
env->builtin_data = NULL;
}
env->use_alpha = b_image.use_alpha();
/* TODO(sergey): Does not work properly when we change builtin type. */
if(b_image.is_updated()) {
scene->image_manager->tag_reload_image(env->filename,
env->builtin_data,
(InterpolationType)b_env_node.interpolation(),
EXTENSION_REPEAT);
}
}
env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
env->interpolation = (InterpolationType)b_env_node.interpolation();
env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()];
get_tex_mapping(&env->tex_mapping, b_env_node.texture_mapping());
node = env;
}
else if(b_node.is_a(&RNA_ShaderNodeTexGradient)) {
BL::ShaderNodeTexGradient b_gradient_node(b_node);
GradientTextureNode *gradient = new GradientTextureNode();
gradient->type = GradientTextureNode::type_enum[(int)b_gradient_node.gradient_type()];
get_tex_mapping(&gradient->tex_mapping, b_gradient_node.texture_mapping());
node = gradient;
}
else if(b_node.is_a(&RNA_ShaderNodeTexVoronoi)) {
BL::ShaderNodeTexVoronoi b_voronoi_node(b_node);
VoronoiTextureNode *voronoi = new VoronoiTextureNode();
voronoi->coloring = VoronoiTextureNode::coloring_enum[(int)b_voronoi_node.coloring()];
get_tex_mapping(&voronoi->tex_mapping, b_voronoi_node.texture_mapping());
node = voronoi;
}
else if(b_node.is_a(&RNA_ShaderNodeTexMagic)) {
BL::ShaderNodeTexMagic b_magic_node(b_node);
MagicTextureNode *magic = new MagicTextureNode();
magic->depth = b_magic_node.turbulence_depth();
get_tex_mapping(&magic->tex_mapping, b_magic_node.texture_mapping());
node = magic;
}
else if(b_node.is_a(&RNA_ShaderNodeTexWave)) {
BL::ShaderNodeTexWave b_wave_node(b_node);
WaveTextureNode *wave = new WaveTextureNode();
wave->type = WaveTextureNode::type_enum[(int)b_wave_node.wave_type()];
get_tex_mapping(&wave->tex_mapping, b_wave_node.texture_mapping());
node = wave;
}
else if(b_node.is_a(&RNA_ShaderNodeTexChecker)) {
BL::ShaderNodeTexChecker b_checker_node(b_node);
CheckerTextureNode *checker = new CheckerTextureNode();
get_tex_mapping(&checker->tex_mapping, b_checker_node.texture_mapping());
node = checker;
}
else if(b_node.is_a(&RNA_ShaderNodeTexBrick)) {
BL::ShaderNodeTexBrick b_brick_node(b_node);
BrickTextureNode *brick = new BrickTextureNode();
brick->offset = b_brick_node.offset();
brick->offset_frequency = b_brick_node.offset_frequency();
brick->squash = b_brick_node.squash();
brick->squash_frequency = b_brick_node.squash_frequency();
get_tex_mapping(&brick->tex_mapping, b_brick_node.texture_mapping());
node = brick;
}
else if(b_node.is_a(&RNA_ShaderNodeTexNoise)) {
BL::ShaderNodeTexNoise b_noise_node(b_node);
NoiseTextureNode *noise = new NoiseTextureNode();
get_tex_mapping(&noise->tex_mapping, b_noise_node.texture_mapping());
node = noise;
}
else if(b_node.is_a(&RNA_ShaderNodeTexMusgrave)) {
BL::ShaderNodeTexMusgrave b_musgrave_node(b_node);
MusgraveTextureNode *musgrave = new MusgraveTextureNode();
musgrave->type = MusgraveTextureNode::type_enum[(int)b_musgrave_node.musgrave_type()];
get_tex_mapping(&musgrave->tex_mapping, b_musgrave_node.texture_mapping());
node = musgrave;
}
else if(b_node.is_a(&RNA_ShaderNodeTexCoord)) {
BL::ShaderNodeTexCoord b_tex_coord_node(b_node);
TextureCoordinateNode *tex_coord = new TextureCoordinateNode();
tex_coord->from_dupli = b_tex_coord_node.from_dupli();
if(b_tex_coord_node.object()) {
tex_coord->use_transform = true;
tex_coord->ob_tfm = get_transform(b_tex_coord_node.object().matrix_world());
}
node = tex_coord;
}
else if(b_node.is_a(&RNA_ShaderNodeTexSky)) {
BL::ShaderNodeTexSky b_sky_node(b_node);
SkyTextureNode *sky = new SkyTextureNode();
sky->type = SkyTextureNode::type_enum[(int)b_sky_node.sky_type()];
sky->sun_direction = normalize(get_float3(b_sky_node.sun_direction()));
sky->turbidity = b_sky_node.turbidity();
sky->ground_albedo = b_sky_node.ground_albedo();
get_tex_mapping(&sky->tex_mapping, b_sky_node.texture_mapping());
node = sky;
}
else if(b_node.is_a(&RNA_ShaderNodeNormalMap)) {
BL::ShaderNodeNormalMap b_normal_map_node(b_node);
NormalMapNode *nmap = new NormalMapNode();
nmap->space = NormalMapNode::space_enum[(int)b_normal_map_node.space()];
nmap->attribute = b_normal_map_node.uv_map();
node = nmap;
}
else if(b_node.is_a(&RNA_ShaderNodeTangent)) {
BL::ShaderNodeTangent b_tangent_node(b_node);
TangentNode *tangent = new TangentNode();
tangent->direction_type = TangentNode::direction_type_enum[(int)b_tangent_node.direction_type()];
tangent->axis = TangentNode::axis_enum[(int)b_tangent_node.axis()];
tangent->attribute = b_tangent_node.uv_map();
node = tangent;
}
else if(b_node.is_a(&RNA_ShaderNodeUVMap)) {
BL::ShaderNodeUVMap b_uvmap_node(b_node);
UVMapNode *uvm = new UVMapNode();
uvm->attribute = b_uvmap_node.uv_map();
uvm->from_dupli = b_uvmap_node.from_dupli();
node = uvm;
}
else if(b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
PointDensityTextureNode *point_density = new PointDensityTextureNode();
point_density->filename = b_point_density_node.name();
point_density->space =
PointDensityTextureNode::space_enum[(int)b_point_density_node.space()];
point_density->interpolation =
(InterpolationType)b_point_density_node.interpolation();
point_density->builtin_data = b_point_density_node.ptr.data;
/* Transformation form world space to texture space. */
BL::Object b_ob(b_point_density_node.object());
if(b_ob) {
float3 loc, size;
point_density_texture_space(b_point_density_node, loc, size);
point_density->tfm =
transform_translate(-loc) * transform_scale(size) *
transform_inverse(get_transform(b_ob.matrix_world()));
}
/* TODO(sergey): Use more proper update flag. */
if(true) {
int settings = background ? 1 : 0; /* 1 - render settings, 0 - vewport settings. */
b_point_density_node.cache_point_density(b_scene, settings);
scene->image_manager->tag_reload_image(
point_density->filename,
point_density->builtin_data,
point_density->interpolation,
EXTENSION_CLIP);
}
node = point_density;
}
if(node)
graph->add(node);
return node;
}
static bool node_use_modified_socket_name(ShaderNode *node)
{
if(node->special_type == SHADER_SPECIAL_TYPE_SCRIPT)
return false;
return true;
}
static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket)
{
string name = b_socket.name();
if(node_use_modified_socket_name(node)) {
BL::Node::inputs_iterator b_input;
bool found = false;
int counter = 0, total = 0;
for(b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
if(b_input->name() == name) {
if(!found)
counter++;
total++;
}
if(b_input->ptr.data == b_socket.ptr.data)
found = true;
}
/* rename if needed */
if(name == "Shader")
name = "Closure";
if(total > 1)
name = string_printf("%s%d", name.c_str(), counter);
}
return node->input(name.c_str());
}
static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket)
{
string name = b_socket.name();
if(node_use_modified_socket_name(node)) {
BL::Node::outputs_iterator b_output;
bool found = false;
int counter = 0, total = 0;
for(b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
if(b_output->name() == name) {
if(!found)
counter++;
total++;
}
if(b_output->ptr.data == b_socket.ptr.data)
found = true;
}
/* rename if needed */
if(name == "Shader")
name = "Closure";
if(total > 1)
name = string_printf("%s%d", name.c_str(), counter);
}
return node->output(name.c_str());
}
static void add_nodes(Scene *scene,
BL::RenderEngine b_engine,
BL::BlendData b_data,
BL::Scene b_scene,
const bool background,
ShaderGraph *graph,
BL::ShaderNodeTree b_ntree,
const ProxyMap &proxy_input_map,
const ProxyMap &proxy_output_map)
{
/* add nodes */
BL::ShaderNodeTree::nodes_iterator b_node;
PtrInputMap input_map;
PtrOutputMap output_map;
BL::Node::inputs_iterator b_input;
BL::Node::outputs_iterator b_output;
/* find the node to use for output if there are multiple */
bool found_active_output = false;
BL::ShaderNode output_node(PointerRNA_NULL);
for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
if(is_output_node(*b_node)) {
BL::ShaderNodeOutputMaterial b_output_node(*b_node);
if(b_output_node.is_active_output()) {
output_node = b_output_node;
found_active_output = true;
break;
}
else if(!output_node.ptr.data && !found_active_output) {
output_node = b_output_node;
}
}
}
/* add nodes */
for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) {
if(b_node->mute() || b_node->is_a(&RNA_NodeReroute)) {
/* replace muted node with internal links */
BL::Node::internal_links_iterator b_link;
for(b_node->internal_links.begin(b_link); b_link != b_node->internal_links.end(); ++b_link) {
ProxyNode *proxy = new ProxyNode(convert_socket_type(b_link->to_socket()));
input_map[b_link->from_socket().ptr.data] = proxy->inputs[0];
output_map[b_link->to_socket().ptr.data] = proxy->outputs[0];
graph->add(proxy);
}
}
else if(b_node->is_a(&RNA_ShaderNodeGroup) || b_node->is_a(&RNA_NodeCustomGroup)) {
BL::ShaderNodeTree b_group_ntree(PointerRNA_NULL);
if(b_node->is_a(&RNA_ShaderNodeGroup))
b_group_ntree = BL::ShaderNodeTree(((BL::NodeGroup)(*b_node)).node_tree());
else
b_group_ntree = BL::ShaderNodeTree(((BL::NodeCustomGroup)(*b_node)).node_tree());
ProxyMap group_proxy_input_map, group_proxy_output_map;
/* Add a proxy node for each socket
* Do this even if the node group has no internal tree,
* so that links have something to connect to and assert won't fail.
*/
for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
ProxyNode *proxy = new ProxyNode(convert_socket_type(*b_input));
graph->add(proxy);
/* register the proxy node for internal binding */
group_proxy_input_map[b_input->identifier()] = proxy;
input_map[b_input->ptr.data] = proxy->inputs[0];
set_default_value(proxy->inputs[0], *b_input, b_data, b_ntree);
}
for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
ProxyNode *proxy = new ProxyNode(convert_socket_type(*b_output));
graph->add(proxy);
/* register the proxy node for internal binding */
group_proxy_output_map[b_output->identifier()] = proxy;
output_map[b_output->ptr.data] = proxy->outputs[0];
}
if(b_group_ntree) {
add_nodes(scene,
b_engine,
b_data,
b_scene,
background,
graph,
b_group_ntree,
group_proxy_input_map,
group_proxy_output_map);
}
}
else if(b_node->is_a(&RNA_NodeGroupInput)) {
/* map each socket to a proxy node */
for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
ProxyMap::const_iterator proxy_it = proxy_input_map.find(b_output->identifier());
if(proxy_it != proxy_input_map.end()) {
ProxyNode *proxy = proxy_it->second;
output_map[b_output->ptr.data] = proxy->outputs[0];
}
}
}
else if(b_node->is_a(&RNA_NodeGroupOutput)) {
BL::NodeGroupOutput b_output_node(*b_node);
/* only the active group output is used */
if(b_output_node.is_active_output()) {
/* map each socket to a proxy node */
for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
ProxyMap::const_iterator proxy_it = proxy_output_map.find(b_input->identifier());
if(proxy_it != proxy_output_map.end()) {
ProxyNode *proxy = proxy_it->second;
input_map[b_input->ptr.data] = proxy->inputs[0];
set_default_value(proxy->inputs[0], *b_input, b_data, b_ntree);
}
}
}
}
else {
ShaderNode *node = NULL;
if(is_output_node(*b_node)) {
if(b_node->ptr.data == output_node.ptr.data) {
node = graph->output();
}
}
else {
node = add_node(scene,
b_engine,
b_data,
b_scene,
background,
graph,
b_ntree,
BL::ShaderNode(*b_node));
}
if(node) {
/* map node sockets for linking */
for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
ShaderInput *input = node_find_input_by_name(node, *b_node, *b_input);
if(!input) {
/* XXX should not happen, report error? */
continue;
}
input_map[b_input->ptr.data] = input;
set_default_value(input, *b_input, b_data, b_ntree);
}
for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
ShaderOutput *output = node_find_output_by_name(node, *b_node, *b_output);
if(!output) {
/* XXX should not happen, report error? */
continue;
}
output_map[b_output->ptr.data] = output;
}
}
}
}
/* connect nodes */
BL::NodeTree::links_iterator b_link;
for(b_ntree.links.begin(b_link); b_link != b_ntree.links.end(); ++b_link) {
/* Ignore invalid links to avoid unwanted cycles created in graph. */
if(!b_link->is_valid()) {
continue;
}
/* get blender link data */
BL::NodeSocket b_from_sock = b_link->from_socket();
BL::NodeSocket b_to_sock = b_link->to_socket();
ShaderOutput *output = 0;
ShaderInput *input = 0;
PtrOutputMap::iterator output_it = output_map.find(b_from_sock.ptr.data);
if(output_it != output_map.end())
output = output_it->second;
PtrInputMap::iterator input_it = input_map.find(b_to_sock.ptr.data);
if(input_it != input_map.end())
input = input_it->second;
/* either node may be NULL when the node was not exported, typically
* because the node type is not supported */
if(output && input)
graph->connect(output, input);
}
}
static void add_nodes(Scene *scene,
BL::RenderEngine b_engine,
BL::BlendData b_data,
BL::Scene b_scene,
const bool background,
ShaderGraph *graph,
BL::ShaderNodeTree b_ntree)
{
static const ProxyMap empty_proxy_map;
add_nodes(scene,
b_engine,
b_data,
b_scene,
background,
graph,
b_ntree,
empty_proxy_map,
empty_proxy_map);
}
/* Sync Materials */
void BlenderSync::sync_materials(bool update_all)
{
shader_map.set_default(scene->shaders[scene->default_surface]);
/* material loop */
BL::BlendData::materials_iterator b_mat;
for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) {
Shader *shader;
/* test if we need to sync */
if(shader_map.sync(&shader, *b_mat) || update_all) {
ShaderGraph *graph = new ShaderGraph();
shader->name = b_mat->name().c_str();
shader->pass_id = b_mat->pass_index();
/* create nodes */
if(b_mat->use_nodes() && b_mat->node_tree()) {
BL::ShaderNodeTree b_ntree(b_mat->node_tree());
add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
}
else {
ShaderNode *closure, *out;
closure = graph->add(new DiffuseBsdfNode());
closure->input("Color")->value = get_float3(b_mat->diffuse_color());
out = graph->output();
graph->connect(closure->output("BSDF"), out->input("Surface"));
}
/* settings */
PointerRNA cmat = RNA_pointer_get(&b_mat->ptr, "cycles");
shader->use_mis = get_boolean(cmat, "sample_as_light");
shader->use_transparent_shadow = get_boolean(cmat, "use_transparent_shadow");
shader->heterogeneous_volume = !get_boolean(cmat, "homogeneous_volume");
shader->volume_sampling_method = (VolumeSampling)RNA_enum_get(&cmat, "volume_sampling");
shader->volume_interpolation_method = (VolumeInterpolation)RNA_enum_get(&cmat, "volume_interpolation");
shader->set_graph(graph);
shader->tag_update(scene);
}
}
}
/* Sync World */
void BlenderSync::sync_world(bool update_all)
{
Background *background = scene->background;
Background prevbackground = *background;
BL::World b_world = b_scene.world();
if(world_recalc || update_all || b_world.ptr.data != world_map) {
Shader *shader = scene->shaders[scene->default_background];
ShaderGraph *graph = new ShaderGraph();
/* create nodes */
if(b_world && b_world.use_nodes() && b_world.node_tree()) {
BL::ShaderNodeTree b_ntree(b_world.node_tree());
add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
/* volume */
PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
shader->heterogeneous_volume = !get_boolean(cworld, "homogeneous_volume");
shader->volume_sampling_method = (VolumeSampling)RNA_enum_get(&cworld, "volume_sampling");
shader->volume_interpolation_method = (VolumeInterpolation)RNA_enum_get(&cworld, "volume_interpolation");
}
else if(b_world) {
ShaderNode *closure, *out;
closure = graph->add(new BackgroundNode());
closure->input("Color")->value = get_float3(b_world.horizon_color());
out = graph->output();
graph->connect(closure->output("Background"), out->input("Surface"));
}
if(b_world) {
/* AO */
BL::WorldLighting b_light = b_world.light_settings();
if(b_light.use_ambient_occlusion())
background->ao_factor = b_light.ao_factor();
else
background->ao_factor = 0.0f;
background->ao_distance = b_light.distance();
/* visibility */
PointerRNA cvisibility = RNA_pointer_get(&b_world.ptr, "cycles_visibility");
uint visibility = 0;
visibility |= get_boolean(cvisibility, "camera")? PATH_RAY_CAMERA: 0;
visibility |= get_boolean(cvisibility, "diffuse")? PATH_RAY_DIFFUSE: 0;
visibility |= get_boolean(cvisibility, "glossy")? PATH_RAY_GLOSSY: 0;
visibility |= get_boolean(cvisibility, "transmission")? PATH_RAY_TRANSMIT: 0;
visibility |= get_boolean(cvisibility, "scatter")? PATH_RAY_VOLUME_SCATTER: 0;
background->visibility = visibility;
}
else {
background->ao_factor = 0.0f;
background->ao_distance = FLT_MAX;
}
shader->set_graph(graph);
shader->tag_update(scene);
background->tag_update(scene);
}
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
/* when doing preview render check for BI's transparency settings,
* this is so because Blender's preview render routines are not able
* to tweak all cycles's settings depending on different circumstances
*/
if(b_engine.is_preview() == false)
background->transparent = get_boolean(cscene, "film_transparent");
else
background->transparent = b_scene.render().alpha_mode() == BL::RenderSettings::alpha_mode_TRANSPARENT;
background->use_shader = render_layer.use_background_shader;
background->use_ao = render_layer.use_background_ao;
if(background->modified(prevbackground))
background->tag_update(scene);
}
/* Sync Lamps */
void BlenderSync::sync_lamps(bool update_all)
{
shader_map.set_default(scene->shaders[scene->default_light]);
/* lamp loop */
BL::BlendData::lamps_iterator b_lamp;
for(b_data.lamps.begin(b_lamp); b_lamp != b_data.lamps.end(); ++b_lamp) {
Shader *shader;
/* test if we need to sync */
if(shader_map.sync(&shader, *b_lamp) || update_all) {
ShaderGraph *graph = new ShaderGraph();
/* create nodes */
if(b_lamp->use_nodes() && b_lamp->node_tree()) {
shader->name = b_lamp->name().c_str();
BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
}
else {
ShaderNode *closure, *out;
float strength = 1.0f;
if(b_lamp->type() == BL::Lamp::type_POINT ||
b_lamp->type() == BL::Lamp::type_SPOT ||
b_lamp->type() == BL::Lamp::type_AREA)
{
strength = 100.0f;
}
closure = graph->add(new EmissionNode());
closure->input("Color")->value = get_float3(b_lamp->color());
closure->input("Strength")->value.x = strength;
out = graph->output();
graph->connect(closure->output("Emission"), out->input("Surface"));
}
shader->set_graph(graph);
shader->tag_update(scene);
}
}
}
void BlenderSync::sync_shaders()
{
/* for auto refresh images */
bool auto_refresh_update = false;
if(preview) {
ImageManager *image_manager = scene->image_manager;
int frame = b_scene.frame_current();
auto_refresh_update = image_manager->set_animation_frame_update(frame);
}
shader_map.pre_sync();
sync_world(auto_refresh_update);
sync_lamps(auto_refresh_update);
sync_materials(auto_refresh_update);
/* false = don't delete unused shaders, not supported */
shader_map.post_sync(false);
}
CCL_NAMESPACE_END
| 32.992441 | 109 | 0.700543 | [
"render",
"object",
"vector"
] |
74e54ac3c4f0055299f6582fe9a5c4ef31950732 | 28,247 | cpp | C++ | Addins/ExportKF.cpp | BlazesRus/hkxcmd | e00a554225234e40e111e808b095156ac1d4b1fe | [
"Intel"
] | null | null | null | Addins/ExportKF.cpp | BlazesRus/hkxcmd | e00a554225234e40e111e808b095156ac1d4b1fe | [
"Intel"
] | null | null | null | Addins/ExportKF.cpp | BlazesRus/hkxcmd | e00a554225234e40e111e808b095156ac1d4b1fe | [
"Intel"
] | null | null | null | #pragma region Headers
#include "stdafx.h"
#include "hkxcmd.h"
#include "hkxutils.h"
#include "hkfutils.h"
#include "log.h"
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
#pragma region Niflib Headers
//////////////////////////////////////////////////////////////////////////
// Niflib Includes
//////////////////////////////////////////////////////////////////////////
#include <niflib.h>
#include <nif_io.h>
#include "obj/NiObject.h"
#include "obj/NiNode.h"
#include "obj/NiTexturingProperty.h"
#include "obj/NiSourceTexture.h"
#include "obj/NiTriBasedGeom.h"
#include "obj/NiTriBasedGeomData.h"
#include "obj/NiTriShape.h"
#include "obj/NiTriStrips.h"
#include <obj/NiControllerSequence.h>
#include <obj/NiControllerManager.h>
#include <obj/NiInterpolator.h>
#include <obj/NiTransformInterpolator.h>
#include <obj/NiTransformData.h>
#include <obj/NiTransformController.h>
#include <obj/NiTimeController.h>
#include <obj/NiTransformController.h>
#include <obj/NiTextKeyExtraData.h>
#include <obj/NiKeyframeController.h>
#include <obj/NiKeyframeData.h>
#include <obj/NiStringPalette.h>
#include <obj/NiBSplineTransformInterpolator.h>
#include <obj/NiDefaultAVObjectPalette.h>
#include <obj/NiMultiTargetTransformController.h>
#include <obj/NiGeomMorpherController.h>
#include <obj/NiMorphData.h>
#include <obj/NiBSplineCompFloatInterpolator.h>
#include <obj/NiFloatInterpolator.h>
#include <obj/NiFloatData.h>
#include <Key.h>
typedef Niflib::Key<float> FloatKey;
typedef Niflib::Key<Niflib::Quaternion> QuatKey;
typedef Niflib::Key<Niflib::Vector3> Vector3Key;
typedef Niflib::Key<string> StringKey;
#pragma endregion
#pragma region Havok Headers
//////////////////////////////////////////////////////////////////////////
// Havok Includes
//////////////////////////////////////////////////////////////////////////
#include <Common/Base/hkBase.h>
#include <Common/Base/Memory/System/Util/hkMemoryInitUtil.h>
#include <Common/Base/Memory/Allocator/Malloc/hkMallocAllocator.h>
#include <Common/Base/System/Io/IStream/hkIStream.h>
#include <cstdio>
// Scene
#include <Common/SceneData/Scene/hkxScene.h>
#include <Common/Serialize/Util/hkRootLevelContainer.h>
#include <Common/Serialize/Util/hkLoader.h>
// Physics
#include <Physics/Dynamics/Entity/hkpRigidBody.h>
#include <Physics/Collide/Shape/Convex/Box/hkpBoxShape.h>
#include <Physics/Utilities/Dynamics/Inertia/hkpInertiaTensorComputer.h>
// Animation
#include <Animation/Animation/Rig/hkaSkeleton.h>
#include <Animation/Animation/hkaAnimationContainer.h>
#include <Animation/Animation/Mapper/hkaSkeletonMapper.h>
#include <Animation/Animation/Playback/Control/Default/hkaDefaultAnimationControl.h>
#include <Animation/Animation/Playback/hkaAnimatedSkeleton.h>
#include <Animation/Animation/Animation/SplineCompressed/hkaSplineCompressedAnimation.h>
#include <Animation/Animation/Rig/hkaPose.h>
#include <Animation/Ragdoll/Controller/PoweredConstraint/hkaRagdollPoweredConstraintController.h>
#include <Animation/Ragdoll/Controller/RigidBody/hkaRagdollRigidBodyController.h>
#include <Animation/Ragdoll/Utils/hkaRagdollUtils.h>
#include <Animation/Animation/Rig/hkaSkeletonUtils.h>
// Serialize
#include <Common/Serialize/Util/hkSerializeUtil.h>
#pragma endregion
//////////////////////////////////////////////////////////////////////////
// Our Includes
//////////////////////////////////////////////////////////////////////////
#include <float.h>
#include <cstdio>
#include <sys/stat.h>
using namespace Niflib;
using namespace std;
#pragma endregion
//////////////////////////////////////////////////////////////////////////
// Enumeration Types
//////////////////////////////////////////////////////////////////////////
namespace {
enum {
IPOS_X_REF = 0,
IPOS_Y_REF = 1,
IPOS_Z_REF = 2,
IPOS_W_REF = 3,
};
enum AccumType
{
AT_NONE = 0,
AT_X = 0x01,
AT_Y = 0x02,
AT_Z = 0x04,
AT_XYZ = AT_X | AT_Y | AT_Z,
AT_FORCE = 0x80000000,
};
}
//////////////////////////////////////////////////////////////////////////
// Constants
//////////////////////////////////////////////////////////////////////////
const unsigned int IntegerInf = 0x7f7fffff;
const unsigned int IntegerNegInf = 0xff7fffff;
const float FloatINF = *(float*)&IntegerInf;
const float FloatNegINF = *(float*)&IntegerNegInf;
//////////////////////////////////////////////////////////////////////////
// Structures
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Helper functions
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Classes
//////////////////////////////////////////////////////////////////////////
struct AnimationExport
{
AnimationExport(NiControllerSequenceRef seq, hkRefPtr<hkaSkeleton> skeleton, hkRefPtr<hkaAnimationBinding> binding);
bool doExport();
bool exportNotes( );
bool exportController();
//bool SampleAnimation( INode * node, Interval &range, PosRotScale prs, NiKeyframeDataRef data );
NiControllerSequenceRef seq;
hkRefPtr<hkaAnimationBinding> binding;
hkRefPtr<hkaSkeleton> skeleton;
};
float QuatDot(const Quaternion& q, const Quaternion&p)
{
return q.w*p.w + q.x*p.x + q.y*p.y + q.z*p.z;
}
AnimationExport::AnimationExport(NiControllerSequenceRef seq, hkRefPtr<hkaSkeleton> skeleton, hkRefPtr<hkaAnimationBinding> binding)
{
this->seq = seq;
this->binding = binding;
this->skeleton = skeleton;
}
bool AnimationExport::doExport()
{
hkStringPtr rootName = binding->m_originalSkeletonName;
seq->SetStartTime(FloatINF);
seq->SetStopTime(FloatINF);
seq->SetFrequency(1.0f);
seq->SetCycleType( CYCLE_CLAMP );
seq->SetTargetName( string(rootName) );
seq->SetStartTime(0.0);
if (!exportNotes())
return false;
return exportController();
}
bool AnimationExport::exportNotes( )
{
vector<StringKey> textKeys;
#if 0
NiTextKeyExtraDataRef textKeyData = new NiTextKeyExtraData();
seq->SetTextKey(textKeyData);
//seq->SetName( note.m_text );
AccumType accumType = AT_NONE;
hkRefPtr<hkaAnimation> anim = binding->m_animation;
const hkInt32 numAnnotationTracks = anim->m_annotationTracks.getSize();
// Scan the animation for get up points
for (hkInt32 t=0; t< numAnnotationTracks; ++t )
{
hkaAnnotationTrack& track = anim->m_annotationTracks[t];
const hkInt32 numAnnotations = track.m_annotations.getSize();
for( hkInt32 a = 0; a < numAnnotations; ++a )
{
hkaAnnotationTrack::Annotation& note = track.m_annotations[a];
if ( seq->GetStartTime() == FloatINF || seq->GetStartTime() > note.m_time )
seq->SetStartTime(note.m_time);
if ( seq->GetStopTime() == FloatINF || seq->GetStopTime() < note.m_time )
seq->SetStopTime(note.m_time);
StringKey strkey;
strkey.time = note.m_time;
strkey.data = note.m_text;
textKeys.push_back(strkey);
}
}
textKeyData->SetKeys(textKeys);
#endif
return true;
}
static inline Niflib::Vector3 TOVECTOR3(const hkVector4& v){
return Niflib::Vector3(v.getSimdAt(0), v.getSimdAt(1), v.getSimdAt(2));
}
static inline Niflib::Vector4 TOVECTOR4(const hkVector4& v){
return Niflib::Vector4(v.getSimdAt(0), v.getSimdAt(1), v.getSimdAt(2), v.getSimdAt(3));
}
static inline Niflib::Quaternion TOQUAT(const hkQuaternion& q, bool inverse = false){
Niflib::Quaternion qt(q.m_vec.getSimdAt(3), q.m_vec.getSimdAt(0), q.m_vec.getSimdAt(1), q.m_vec.getSimdAt(2));
return inverse ? qt.Inverse() : qt;
}
static inline Niflib::Quaternion TOQUAT(const hkRotation& rot, bool inverse = false){
return TOQUAT(hkQuaternion(rot), inverse);
}
static inline float Average(const Niflib::Vector3& val) {
return (val.x + val.y + val.z) / 3.0f;
}
const float MY_FLT_EPSILON = 1e-5f;
static inline bool EQUALS(float a, float b){
return fabs(a - b) < MY_FLT_EPSILON;
}
static inline bool EQUALS(float a, float b, float epsilon){
return fabs(a - b) < epsilon;
}
static inline bool EQUALS(const Niflib::Vector3& a, const Niflib::Vector3& b){
return (EQUALS(a.x,b.x) && EQUALS(a.y, b.y) && EQUALS(a.z, b.z) );
}
static inline bool EQUALS(const Niflib::Quaternion& a, const Niflib::Quaternion& b){
return EQUALS(a.w, b.w) && EQUALS(a.x,b.x) && EQUALS(a.y, b.y) && EQUALS(a.z, b.z);
}
struct BoneDataReference
{
string name;
NiTransformControllerRef transCont;
NiTransformInterpolatorRef interpolator;
NiTransformDataRef transData;
vector<Vector3Key> trans;
vector<QuatKey> rot;
vector<FloatKey> scale;
Vector3 lastTrans;
Quaternion lastRotate;
float lastScale;
};
bool AnimationExport::exportController()
{
hkRefPtr<hkaAnimation> anim = binding->m_animation;
int nframes = anim->getNumOriginalFrames();
int numTracks = anim->m_numberOfTransformTracks;
int nfloats = anim->m_numberOfFloatTracks;
if (numTracks == 0)
return false;
float duration = anim->m_duration;
seq->SetStopTime(duration);
int nbones = skeleton->m_bones.getSize();
// dont know how to deal with this
if (numTracks > nbones)
{
Log::Error("Error processing skeleton '%s' number of tracks exceed bones.", (LPCSTR)binding->m_originalSkeletonName);
return false;
}
hkLocalArray<float> floatsOut(nfloats);
hkLocalArray<hkQsTransform> transformOut(numTracks);
floatsOut.setSize(nfloats);
transformOut.setSize(numTracks);
hkReal startTime = 0.0;
hkArray<hkInt16> tracks;
tracks.setSize(numTracks);
for (int i=0; i<numTracks; ++i) tracks[i]=i;
vector<BoneDataReference> dataList;
dataList.resize(numTracks);
vector<bool> scaleWarn;
scaleWarn.resize(numTracks);
NiObjectNETRef placeHolder = new NiObjectNET();
for (int i=0,n=numTracks; i<n; ++i)
{
NiTransformControllerRef controller = new NiTransformController();
NiTransformInterpolatorRef interp = new NiTransformInterpolator();
controller->SetInterpolator(interp);
NiTransformDataRef data = new NiTransformData();
interp->SetData(data);
hkQsTransform localTransform = skeleton->m_referencePose[i];
interp->SetTranslation(TOVECTOR3(localTransform.getTranslation()));
interp->SetRotation(TOQUAT(localTransform.getRotation()));
interp->SetScale(Average(TOVECTOR3(localTransform.getScale()))); // no scaling?
BoneDataReference& boneData = dataList[i];
boneData.name = skeleton->m_bones[i].m_name;
boneData.transCont = controller;
boneData.transData = data;
boneData.trans.reserve(nframes);
boneData.rot.reserve(nframes);
boneData.scale.reserve(nframes);
boneData.lastTrans = interp->GetTranslation();
boneData.lastRotate = interp->GetRotation();
boneData.lastScale = interp->GetScale();
}
hkReal time = startTime;
for (int iFrame=0; iFrame<nframes; ++iFrame, time = startTime + (hkReal)iFrame * anim->m_duration / (hkReal)(nframes-1))
{
//hkUint32 uiAnnotations = anim->getNumAnnotations(time, incrFrame);
//hkUint32 nAnnotations = anim->getAnnotations(time, incrFrame, annotations.begin(), nbones);
anim->samplePartialTracks(time, numTracks, transformOut.begin(), nfloats, floatsOut.begin(), HK_NULL);
hkaSkeletonUtils::normalizeRotations(transformOut.begin(), numTracks);
// assume 1-to-1 transforms
for (int i=0; i<numTracks; ++i)
{
BoneDataReference& data = dataList[i];
hkQsTransform& transform = transformOut[i];
Vector3Key vk;
vk.time = time;
vk.data = TOVECTOR3(transform.getTranslation());
if (!EQUALS(vk.data,data.lastTrans))
{
data.trans.push_back(vk);
data.lastTrans = vk.data;
}
QuatKey qk;
qk.time = time;
qk.data = TOQUAT(transform.getRotation()).Normalized();
if (!EQUALS(qk.data,data.lastRotate))
{
data.rot.push_back(qk);
data.lastRotate = qk.data;
}
FloatKey sk;
sk.time = time;
Niflib::Vector3 sc = TOVECTOR3(transform.getScale());
if (!EQUALS(sc.x,sc.y,0.01f) && !EQUALS(sc.x,sc.z,0.01f))
{
if (!scaleWarn[i])
{
scaleWarn[i] = true;
Log::Warn("Non-uniform scaling found while processing '%s'.", skeleton->m_bones[i].m_name.cString());
}
}
sk.data = Average(sc);
if (!EQUALS(data.lastScale,sk.data,0.01f))
{
data.scale.push_back(sk);
data.lastScale = sk.data;
}
}
}
for (int i=0; i<numTracks; ++i)
{
bool keep=false;
BoneDataReference& data = dataList[i];
if (!data.trans.empty())
{
data.transData->SetTranslateType(LINEAR_KEY);
data.transData->SetTranslateKeys(data.trans);
keep = true;
}
if (!data.rot.empty())
{
data.transData->SetRotateType(QUADRATIC_KEY);
data.transData->SetQuatRotateKeys(data.rot);
keep = true;
}
if (!data.scale.empty())
{
data.transData->SetScaleType(LINEAR_KEY);
data.transData->SetScaleKeys(data.scale);
keep = true;
}
if (keep)
{
seq->AddController(data.name, data.transCont);
}
}
// Add some text keys for easier export from max
{
NiTextKeyExtraDataRef textKeys = new NiTextKeyExtraData();
vector<StringKey> keys;
StringKey first, last;
first.time = 0.0; first.data = "start";
last.time = duration; last.data = "end";
keys.push_back( first );
keys.push_back(last);
textKeys->SetKeys(keys);
seq->SetTextKeysName("Annotations");
seq->SetTextKeys(textKeys);
seq->SetTextKey(textKeys);
}
// remove controllers now
vector<ControllerLink> links = seq->GetControlledBlocks();
for (vector<ControllerLink>::iterator itr = links.begin(); itr != links.end(); ++itr)
{
NiTransformControllerRef controller = (*itr).controller;
(*itr).interpolator = controller->GetInterpolator();
(*itr).controller = NULL;
}
seq->SetControlledBlocks(links);
return true;
}
void ExportAnimations(const string& rootdir, const string& skelfile, const vector<string>& animlist, const string& outdir, Niflib::NifInfo& nifver, bool norelativepath = false)
{
hkResource* skelResource = NULL;
hkResource* animResource = NULL;
hkaSkeleton* skeleton = NULL;
hkaAnimationContainer * animCont= NULL;
Log::Verbose("ExportAnimation('%s','%s','%s')", rootdir.c_str(), skelfile.c_str(), outdir.c_str());
// Read back a serialized file
{
hkIstream stream(skelfile.c_str());
hkStreamReader *reader = stream.getStreamReader();
skelResource = hkSerializeLoadResource(reader);
if (skelResource)
{
const char * hktypename = skelResource->getContentsTypeName();
void * contentPtr = skelResource->getContentsPointer(HK_NULL, HK_NULL);
hkRootLevelContainer* scene = skelResource->getContents<hkRootLevelContainer>();
hkaAnimationContainer *skelAnimCont = scene->findObject<hkaAnimationContainer>();
if ( !skelAnimCont->m_skeletons.isEmpty() )
skeleton = skelAnimCont->m_skeletons[0];
}
}
if (skeleton != NULL)
{
for (vector<string>::const_iterator itr = animlist.begin(); itr != animlist.end(); ++itr)
{
string animfile = (*itr);
Log::Verbose("ExportAnimation Starting '%s'", animfile.c_str());
char outfile[MAX_PATH], relout[MAX_PATH];
LPCSTR extn = PathFindExtension(outdir.c_str());
if (stricmp(extn, ".kf") == 0)
{
strcpy(outfile, outdir.c_str());
}
else // assume its a folder
{
if (norelativepath)
{
PathCombine(outfile, outdir.c_str(), PathFindFileName(animfile.c_str()));
}
else
{
char relpath[MAX_PATH];
PathRelativePathTo(relpath, rootdir.c_str(), FILE_ATTRIBUTE_DIRECTORY, animfile.c_str(), 0);
PathCombine(outfile, outdir.c_str(), relpath);
GetFullPathName(outfile, MAX_PATH, outfile, NULL);
}
PathRemoveExtension(outfile);
PathAddExtension(outfile, ".kf");
}
char workdir[MAX_PATH];
_getcwd(workdir, MAX_PATH);
PathRelativePathTo(relout, workdir, FILE_ATTRIBUTE_DIRECTORY, outfile, 0);
Log::Verbose("ExportAnimation Reading '%s'", animfile.c_str());
hkIstream stream(animfile.c_str());
hkStreamReader *reader = stream.getStreamReader();
animResource = hkSerializeLoadResource(reader);
if (animResource != NULL)
{
const char * hktypename = animResource->getContentsTypeName();
void * contentPtr = animResource->getContentsPointer(HK_NULL, HK_NULL);
hkRootLevelContainer* scene = animResource->getContents<hkRootLevelContainer>();
animCont = scene->findObject<hkaAnimationContainer>();
if (animCont != NULL)
{
if (animCont != NULL)
{
int nbindings = animCont->m_bindings.getSize();
if ( nbindings == 0)
{
Log::Error("Animation file contains no animation bindings. Not exporting.");
}
else if ( nbindings != 1)
{
Log::Error("Animation file contains more than one animation binding. Not exporting.");
}
else
{
for ( int i=0, n=animCont->m_bindings.getSize(); i<n; ++i)
{
char fname[MAX_PATH];
_splitpath(animfile.c_str(), NULL, NULL, fname, NULL);
hkRefPtr<hkaAnimationBinding> binding = animCont->m_bindings[i];
NiControllerSequenceRef seq = new NiControllerSequence();
seq->SetName(fname);
Log::Verbose("ExportAnimation Exporting '%s'", outfile);
AnimationExport exporter(seq, skeleton, binding);
if ( exporter.doExport() )
{
char outfiledir[MAX_PATH];
strcpy(outfiledir, outfile);
PathRemoveFileSpec(outfiledir);
CreateDirectories(outfiledir);
Log::Info("Exporting '%s'", relout);
Niflib::WriteNifTree(outfile, seq, nifver);
}
else
{
Log::Error("Export failed for '%s'", relout);
}
}
}
}
}
animResource->removeReference();
}
}
}
if (skelResource) skelResource->removeReference();
}
//////////////////////////////////////////////////////////////////////////
static void HelpString(hkxcmd::HelpType type){
switch (type)
{
case hkxcmd::htShort: Log::Info("ExportKF - Convert Havok HKX animation to Gamebryo KF animation."); break;
case hkxcmd::htLong:
{
char fullName[MAX_PATH], exeName[MAX_PATH];
GetModuleFileName(NULL, fullName, MAX_PATH);
_splitpath(fullName, NULL, NULL, exeName, NULL);
Log::Info("Usage: %s ExportKF [-opts[modifiers]] [skel.hkx] [anim.hkx] [anim.kf]", exeName);
Log::Info(" Convert Havok HKX animation to Gamebryo KF animation." );
Log::Info(" If a folder is specified then the folder will be searched for any projects and convert those." );
Log::Info("");
Log::Info("<Options>" );
Log::Info(" skel.hkx Path to Havok skeleton for animation binding." );
Log::Info(" anim.hkx Path to Havok animation to convert" );
Log::Info(" anim.kf Path to Gamebryo animation to write (Default: anim.hkx with kf ext)" );
Log::Info("<Switches>" );
Log::Info(" -d[:level] Debug Level: ERROR,WARN,INFO,DEBUG,VERBOSE (Default: INFO)" );
Log::Info(" -n Disable recursive file processing" );
Log::Info(" -v x.x.x.x Nif Version to write as - Defaults to 20.2.0.7" );
Log::Info(" -u x Nif User Version to write as - Defaults to 12" );
Log::Info(" -u2 x Nif User2 Version to write as - Defaults to 83" );
Log::Info("");
}
break;
}
}
static void ExportProject( const string &projfile, const char * rootPath, const char * outdir, Niflib::NifInfo& nifver, bool recursion)
{
vector<string> skelfiles, animfiles;
char projpath[MAX_PATH], skelpath[MAX_PATH], animpath[MAX_PATH];
if ( wildmatch("*skeleton.hkx", projfile) )
{
skelfiles.push_back(projfile);
GetFullPathName(projfile.c_str(), MAX_PATH, projpath, NULL);
PathRemoveFileSpec(projpath);
PathAddBackslash(projpath);
PathCombine(animpath, projpath, "..\\animations\\*.hkx");
FindFiles(animfiles, animpath, recursion);
}
else
{
GetFullPathName(projfile.c_str(), MAX_PATH, projpath, NULL);
PathRemoveFileSpec(projpath);
PathAddBackslash(projpath);
PathCombine(skelpath, projpath, "character assets\\*skeleton.hkx");
FindFiles(skelfiles, skelpath, recursion);
PathCombine(animpath, projpath, "animations\\*.hkx");
FindFiles(animfiles, animpath, recursion);
}
if (skelfiles.empty())
{
Log::Warn("No skeletons found. Skipping '%s'", projpath);
}
else if (skelfiles.size() != 1)
{
Log::Warn("Multiple skeletons found. Skipping '%s'", projpath);
}
else if (animfiles.empty())
{
Log::Warn("No Animations found. Skipping '%s'", projpath);
}
else
{
ExportAnimations(string(rootPath), skelfiles[0],animfiles, outdir, nifver, false);
}
}
static bool ExecuteCmd(hkxcmdLine &cmdLine)
{
bool recursion = true;
vector<string> paths;
int argc = cmdLine.argc;
char **argv = cmdLine.argv;
Niflib::NifInfo nifver;
nifver.version = VER_20_2_0_7;
nifver.userVersion = 11;
nifver.userVersion2 = 83;
#pragma region Handle Input Args
for (int i = 0; i < argc; i++)
{
char *arg = argv[i];
if (arg == NULL)
continue;
if (arg[0] == '-' || arg[0] == '/')
{
switch (tolower(arg[1]))
{
case 'n':
recursion = false;
break;
case 'v':
{
const char *param = arg+2;
if (*param == ':' || *param=='=') ++param;
argv[i] = NULL;
if ( param[0] == 0 && ( i+1<argc && ( argv[i+1][0] != '-' || argv[i+1][0] != '/' ) ) ) {
param = argv[++i];
argv[i] = NULL;
}
if ( param[0] == 0 )
break;
nifver.version = Niflib::ParseVersionString(string(param));
nifver.userVersion = 0;
nifver.userVersion = 0;
}
break;
case 'u':
{
const char *param = arg+2;
if (*param == ':' || *param=='=') ++param;
argv[i] = NULL;
if ( param[0] == 0 && ( i+1<argc && ( argv[i+1][0] != '-' || argv[i+1][0] != '/' ) ) ) {
param = argv[++i];
argv[i] = NULL;
}
if ( param[0] == 0 )
break;
char *end;
nifver.userVersion = strtol(param, &end, 0);
nifver.userVersion2 = 0;
}
break;
case 'u2':
{
const char *param = arg+2;
if (*param == ':' || *param=='=') ++param;
argv[i] = NULL;
if ( param[0] == 0 && ( i+1<argc && ( argv[i+1][0] != '-' || argv[i+1][0] != '/' ) ) ) {
param = argv[++i];
argv[i] = NULL;
}
if ( param[0] == 0 )
break;
char *end;
nifver.userVersion2 = strtol(param, &end, 0);
}
break;
case 'd':
{
const char *param = arg+2;
if (*param == ':' || *param=='=') ++param;
argv[i] = NULL;
if ( param[0] == 0 && ( i+1<argc && ( argv[i+1][0] != '-' || argv[i+1][0] != '/' ) ) ) {
param = argv[++i];
argv[i] = NULL;
}
if ( param[0] == 0 )
{
Log::SetLogLevel(LOG_DEBUG);
break;
}
else
{
Log::SetLogLevel((LogLevel)StringToEnum(param, LogFlags, LOG_INFO));
}
} break;
case 'o':
{
const char *param = arg+2;
if (*param == ':' || *param=='=') ++param;
argv[i] = NULL;
if ( param[0] == 0 && ( i+1<argc && ( argv[i+1][0] != '-' || argv[i+1][0] != '/' ) ) ) {
param = argv[++i];
argv[i] = NULL;
}
if ( param[0] == 0 )
break;
paths.push_back(string(param));
}
break;
case 'i':
{
const char *param = arg+2;
if (*param == ':' || *param=='=') ++param;
argv[i] = NULL;
if ( param[0] == 0 && ( i+1<argc && ( argv[i+1][0] != '-' || argv[i+1][0] != '/' ) ) ) {
param = argv[++i];
argv[i] = NULL;
}
if ( param[0] == 0 )
break;
paths.insert(paths.begin(), 1, string(param));
}
break;
default:
Log::Error("Unknown argument specified '%s'", arg);
return false;
}
}
else
{
paths.push_back(arg);
}
}
#pragma endregion
if (paths.empty()){
HelpString(hkxcmd::htLong);
return false;
}
hkMallocAllocator baseMalloc;
hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault( &baseMalloc, hkMemorySystem::FrameInfo(1024 * 1024) );
hkBaseSystem::init( memoryRouter, errorReport );
// search for projects and guess the layout
if (PathIsDirectory(paths[0].c_str()))
{
char searchPath[MAX_PATH], rootPath[MAX_PATH];
GetFullPathName(paths[0].c_str(), MAX_PATH, rootPath, NULL);
strcpy(searchPath, rootPath);
PathAddBackslash(searchPath);
strcat(searchPath, "*skeleton.hkx");
vector<string> files;
FindFiles(files, searchPath, recursion);
for (vector<string>::iterator itr = files.begin(); itr != files.end(); )
{
if (wildmatch("*\\skeleton.hkx", (*itr)))
{
++itr;
}
else
{
Log::Verbose("Ignoring '%s' due to inexact skeleton.hkx file match", (*itr).c_str());
itr = files.erase(itr);
}
}
if (files.empty())
{
Log::Warn("No files found");
return false;
}
char outdir[MAX_PATH];
if (paths.size() > 1)
{
GetFullPathName(paths[1].c_str(), MAX_PATH, outdir, NULL);
}
else
{
strcpy(outdir, rootPath);
}
for (vector<string>::iterator itr = files.begin(); itr != files.end(); ++itr)
{
string projfile = (*itr).c_str();
ExportProject(projfile, rootPath, outdir, nifver, recursion);
}
}
else
{
string skelpath = (paths.size() >= 0) ? paths[0] : string();
if (skelpath.empty())
{
Log::Error("Skeleton file not specified");
HelpString(hkxcmd::htLong);
}
else if ( wildmatch("*project.hkx", skelpath) )
{
// handle specification of project by name
char rootPath[MAX_PATH];
GetFullPathName(skelpath.c_str(), MAX_PATH, rootPath, NULL);
PathRemoveFileSpec(rootPath);
if (paths.size() > 2)
{
Log::Error("Too many arguments specified");
HelpString(hkxcmd::htLong);
}
else
{
char outdir[MAX_PATH];
if (paths.size() >= 1){
GetFullPathName(paths[1].c_str(), MAX_PATH, outdir, NULL);
} else {
strcpy(outdir, rootPath);
}
ExportProject(skelpath, rootPath, outdir, nifver, recursion);
}
}
else
{
// handle specification of skeleton + animation + output
if ( !PathFileExists(skelpath.c_str()) )
{
Log::Error("Skeleton file not found at '%s'", skelpath.c_str());
}
else
{
// set relative path to current directory
char rootPath[MAX_PATH];
_getcwd(rootPath, MAX_PATH);
if (paths.size() > 3)
{
Log::Error("Too many arguments specified");
HelpString(hkxcmd::htLong);
}
else
{
bool norelativepath = true;
if (paths.size() == 1) // output files inplace
{
char animDir[MAX_PATH], tempdir[MAX_PATH];
strcpy(tempdir, skelpath.c_str());
PathRemoveFileSpec(tempdir);
PathCombine(animDir, tempdir, "..\animations");
PathAddBackslash(animDir);
ExportProject(skelpath, rootPath, rootPath, nifver, recursion);
}
else if (paths.size() == 2) // second path will be output
{
char outdir[MAX_PATH], tempdir[MAX_PATH];
strcpy(outdir, paths[1].c_str());
strcpy(tempdir, skelpath.c_str());
PathRemoveFileSpec(tempdir);
PathAddBackslash(tempdir);
PathCombine(rootPath,tempdir,"..\\animations");
GetFullPathName(rootPath, MAX_PATH, rootPath, NULL);
GetFullPathName(outdir, MAX_PATH, outdir, NULL);
ExportProject(skelpath, rootPath, outdir, nifver, recursion);
}
else // second path is animation, third is output
{
string animpath = paths[1];
if (PathIsDirectory(animpath.c_str()))
{
strcpy(rootPath, animpath.c_str());
animpath += string("\\*.hkx");
norelativepath = false;
}
vector<string> animfiles;
FindFiles(animfiles, animpath.c_str(), recursion);
if (animfiles.empty())
{
Log::Warn("No Animations found. Skipping '%s'", animpath.c_str());
}
else
{
char outdir[MAX_PATH];
if (paths.size() >= 2){
GetFullPathName(paths[2].c_str(), MAX_PATH, outdir, NULL);
} else {
strcpy(outdir, rootPath);
}
ExportAnimations(string(rootPath), skelpath, animfiles, outdir, nifver, norelativepath);
}
}
}
}
}
}
hkBaseSystem::quit();
hkMemoryInitUtil::quit();
return true;
}
static bool SafeExecuteCmd(hkxcmdLine &cmdLine)
{
__try{
return ExecuteCmd(cmdLine);
} __except (EXCEPTION_EXECUTE_HANDLER){
return false;
}
}
REGISTER_COMMAND(ExportKF, HelpString, SafeExecuteCmd);
| 29.090628 | 176 | 0.632138 | [
"shape",
"vector",
"transform"
] |
d55d7d50ed82615aff1e6b35829707a325a8bd80 | 55,343 | hpp | C++ | youbot/youbot_driver/include/youbot_driver/youbot/YouBotGripperParameter.hpp | MrJaeqx/ESA--WORK | 50d5b397f634db98e2627a764c7731e76a4b3feb | [
"MIT"
] | 2 | 2018-03-09T13:44:29.000Z | 2019-12-18T16:17:03.000Z | youbot/youbot_driver/include/youbot_driver/youbot/YouBotGripperParameter.hpp | MrJaeqx/ESA--WORK | 50d5b397f634db98e2627a764c7731e76a4b3feb | [
"MIT"
] | 32 | 2017-11-19T16:26:41.000Z | 2018-01-19T12:36:10.000Z | youbot/youbot_driver/include/youbot_driver/youbot/YouBotGripperParameter.hpp | FontysAtWork/ESA-PROJ | 50d5b397f634db98e2627a764c7731e76a4b3feb | [
"MIT"
] | 1 | 2017-11-19T12:45:37.000Z | 2017-11-19T12:45:37.000Z | #ifndef YOUBOT_YOUBOTGRIPPERPARAMETER_H
#define YOUBOT_YOUBOTGRIPPERPARAMETER_H
/****************************************************************
*
* Copyright (c) 2011
* All rights reserved.
*
* Hochschule Bonn-Rhein-Sieg
* University of Applied Sciences
* Computer Science Department
*
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Author:
* Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov
* Supervised by:
* Gerhard K. Kraetzschmar
*
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* This sofware is published under a dual-license: GNU Lesser General Public
* License LGPL 2.1 and BSD license. The dual-license implies that users of this
* code may choose which terms they prefer.
*
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License LGPL as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version or the BSD license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License LGPL and the BSD license for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License LGPL and BSD license along with this program.
*
****************************************************************/
#include <vector>
#include <sstream>
#include "youbot_driver/generic/Units.hpp"
#include "youbot_driver/generic-joint/JointParameter.hpp"
#include "youbot_driver/generic-gripper/GripperParameter.hpp"
#include "youbot_driver/youbot/ProtocolDefinitions.hpp"
#include "youbot_driver/youbot/YouBotSlaveMsg.hpp"
#include "youbot_driver/youbot/YouBotSlaveMailboxMsg.hpp"
namespace youbot {
///////////////////////////////////////////////////////////////////////////////
/// abstract youBot gripper parameter
///////////////////////////////////////////////////////////////////////////////
class YouBotGripperParameter : public GripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
protected:
YouBotGripperParameter();
public:
virtual ~YouBotGripperParameter();
virtual void toString(std::string& value) const = 0;
protected:
virtual ParameterType getType() const = 0;
virtual std::string getName() const = 0;
virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const = 0;
virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message) = 0;
std::string name;
private:
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// the firmware version of the gripper
///////////////////////////////////////////////////////////////////////////////
class GripperFirmwareVersion : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
GripperFirmwareVersion();
virtual ~GripperFirmwareVersion();
void getParameter(int& controllerType, double& firmwareVersion) const;
void setParameter(const int controllerType, const double firmwareVersion);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int controllerType;
double firmwareVersion;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The name for a gripper bar or finger
///////////////////////////////////////////////////////////////////////////////
class GripperBarName : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
GripperBarName();
virtual ~GripperBarName();
void getParameter(std::string& parameter) const;
void setParameter(const std::string parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
std::string value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Calibrate the gripper
///////////////////////////////////////////////////////////////////////////////
class CalibrateGripper : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
CalibrateGripper();
virtual ~CalibrateGripper();
void getParameter(bool& parameter) const;
void setParameter(const bool parameter);
void toString(std::string& value) const;
private:
virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
ParameterType getType() const {return this->parameterType;};
std::string getName() const {return this->name;};
bool value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Represents a bar spacing offset. It could be useful if the gripper can not be totally closed.
///////////////////////////////////////////////////////////////////////////////
class BarSpacingOffset : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
BarSpacingOffset();
virtual ~BarSpacingOffset();
void getParameter(quantity<si::length>& parameter) const;
void setParameter(const quantity<si::length>& parameter);
void toString(std::string& value) const;
private:
virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
ParameterType getType() const {return this->parameterType;};
std::string getName() const {return this->name;};
quantity<si::length> value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The encoder value when the gripper has reached it's maximum bar spacing position
///////////////////////////////////////////////////////////////////////////////
class MaxEncoderValue : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
MaxEncoderValue();
virtual ~MaxEncoderValue();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int parameter);
void toString(std::string& value) const;
private:
virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
ParameterType getType() const {return this->parameterType;};
std::string getName() const {return this->name;};
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The maximum bar spacing distance of the gripper
///////////////////////////////////////////////////////////////////////////////
class MaxTravelDistance : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
MaxTravelDistance();
virtual ~MaxTravelDistance();
void getParameter(quantity<si::length>& parameter) const;
void setParameter(const quantity<si::length>& parameter);
void toString(std::string& value) const;
private:
virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
ParameterType getType() const {return this->parameterType;};
std::string getName() const {return this->name;};
quantity<si::length> value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Actual position of one gripper bar
///////////////////////////////////////////////////////////////////////////////
class ActualPosition : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ActualPosition();
virtual ~ActualPosition();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Position setpoint for one gripper bar
///////////////////////////////////////////////////////////////////////////////
class PositionSetpoint : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
PositionSetpoint();
virtual ~PositionSetpoint();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Indicates that the actual position equals the target position.
///////////////////////////////////////////////////////////////////////////////
class TargetPositionReached : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
TargetPositionReached();
virtual ~TargetPositionReached();
void getParameter(bool& parameter) const;
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
bool value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Actual velocity of one gripper bar
///////////////////////////////////////////////////////////////////////////////
class ActualVelocity : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ActualVelocity();
virtual ~ActualVelocity();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Velocity setpoint for one gripper bar
///////////////////////////////////////////////////////////////////////////////
class VelocitySetpoint : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
VelocitySetpoint();
virtual ~VelocitySetpoint();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Readout of the actual load value with used for stall detection (stallGuard2).
///////////////////////////////////////////////////////////////////////////////
class ActualLoadValue : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ActualLoadValue();
virtual ~ActualLoadValue();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Selects the comparator blank time. This time needs to safely cover the switching event and the duration of the ringing on the sense resistor. For low current drivers, a setting of 1 or 2 is good.
///////////////////////////////////////////////////////////////////////////////
class ChopperBlankTime : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ChopperBlankTime();
virtual ~ChopperBlankTime();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Hysteresis decrement setting. This setting determines the slope of the hysteresis during on time and during fast decay time.
/// 0 fast decrement
/// 3 very slow decrement
///////////////////////////////////////////////////////////////////////////////
class ChopperHysteresisDecrement : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ChopperHysteresisDecrement();
virtual ~ChopperHysteresisDecrement();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Hysteresis end setting. Sets the hysteresis end value after a number of decrements. Decrement interval time is controlled by axis parameter 164.
/// -3... -1 negative hysteresis end setting
/// 0 zero hysteresis end setting
/// 1... 12 positive hysteresis end setting
///////////////////////////////////////////////////////////////////////////////
class ChopperHysteresisEnd : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ChopperHysteresisEnd();
virtual ~ChopperHysteresisEnd();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Hysteresis start setting. Please remark, that this value is an offset to the hysteresis end value.
///////////////////////////////////////////////////////////////////////////////
class ChopperHysteresisStart : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ChopperHysteresisStart();
virtual ~ChopperHysteresisStart();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Selection of the chopper mode:
/// 0 spread cycle
/// 1 classic const. off time
///////////////////////////////////////////////////////////////////////////////
class ChopperMode : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ChopperMode();
virtual ~ChopperMode();
void getParameter(bool& parameter) const;
void setParameter(const bool parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
bool value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The off time setting controls the minimum chopper frequency. An off time within the range of 5 s to 20 s will fit.
/// Off time setting for constant tOFF chopper:
/// NCLK= 12 + 32*tOFF (Minimum is 64 clocks)
//// Setting this parameter to zero completely disables all driver transistors and the motor can free-wheel.
///////////////////////////////////////////////////////////////////////////////
class ChopperOffTime : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ChopperOffTime();
virtual ~ChopperOffTime();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Every edge of the cycle releases a step/microstep. It does not make sense to activate this parameter for internal use. Double step enable can be used with Step/Dir interface.
/// 0 double step off
/// 1 double step on
///////////////////////////////////////////////////////////////////////////////
class DoubleStepEnable : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
DoubleStepEnable();
virtual ~DoubleStepEnable();
void getParameter(bool& parameter) const;
void setParameter(const bool parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
bool value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Bit 0: stallGuardTM status
/// (1: threshold reached)
/// Bit 1: Overtemperature
/// (1: driver is shut down due to overtemperature)
/// Bit 2: Pre-warning overtemperature
/// (1: Threshold is exceeded)
/// Bit 3: Short to ground A
/// (1: Short condition etected, driver currently shut down)
/// Bit 4: Short to ground B
/// (1: Short condition detected, driver currently shut down)
/// Bit 5: Open load A
/// (1: no chopper event has happened during the last period with constant coil polarity)
/// Bit 6: Open load B
/// (1: no chopper event has happened during the last period with constant coil polarity)
/// Bit 7: Stand still
/// (1: No step impulse occurred on the step input during the last 2^20 clock cycles)
///////////////////////////////////////////////////////////////////////////////
class ErrorFlags : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ErrorFlags();
virtual ~ErrorFlags();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Time after which the power to the motor will be cut when its velocity has reached zero.
/// 0... 65535
/// 0 = never
/// [msec]
///////////////////////////////////////////////////////////////////////////////
class Freewheeling : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
Freewheeling();
virtual ~Freewheeling();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Acceleration parameter for velocity control and position control
///////////////////////////////////////////////////////////////////////////////
class MaximumAcceleration : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
MaximumAcceleration();
virtual ~MaximumAcceleration();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The most important motor setting, since too high values might cause motor damage! The maximum value is 255. This value means 100% of the maximum current of the module. The current adjustment is within the range 0... 255 and can be adjusted in 32 steps (0... 255 divided by eight; e.g. step 0 = 0... 7, step 1 = 8... 15 and so on).
///////////////////////////////////////////////////////////////////////////////
class MaximumCurrent : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
MaximumCurrent();
virtual ~MaximumCurrent();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The limit for acceleration (and deceleration). Changing this parameter requires re-calculation of the acceleration factor (no. 146) and the acceleration divisor (no. 137), which is done automatically.
///////////////////////////////////////////////////////////////////////////////
class MaximumPositioningSpeed : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
MaximumPositioningSpeed();
virtual ~MaximumPositioningSpeed();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// 0: full step
/// 1: half step
/// 2: 4 microsteps
/// 3: 8 microsteps
/// 4: 16 microsteps
/// 5: 32 microsteps
/// 6: 64 microsteps
/// 7: 128 microsteps
/// 8: 256 microsteps
///////////////////////////////////////////////////////////////////////////////
class MicrostepResolution : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
MicrostepResolution();
virtual ~MicrostepResolution();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Standstill period before the current is changed down to standby current. The standard value is 200 (value equates 2000msec).
///////////////////////////////////////////////////////////////////////////////
class PowerDownDelay : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
PowerDownDelay();
virtual ~PowerDownDelay();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The exponent of the scaling factor for the pulse (step) generator should be de/incremented carefully (in steps of one).
///////////////////////////////////////////////////////////////////////////////
class PulseDivisor : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
PulseDivisor();
virtual ~PulseDivisor();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The exponent of the scaling factor for the ramp generator- should be de/incremented carefully (in steps of one).
///////////////////////////////////////////////////////////////////////////////
class RampDivisor : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
RampDivisor();
virtual ~RampDivisor();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Automatically set when using ROR, ROL, MST and MVP.
/// 0: position mode. Steps are generated, when the parameters actual position and target position differ. Trapezoidal speed ramps are provided.
/// 2: velocity mode. The motor will run continuously and the speed will be changed with constant (maximum) acceleration, if the parameter target speed is changed. For special purposes, the soft mode (value 1) with exponential decrease of speed can be selected.
///////////////////////////////////////////////////////////////////////////////
class RampMode : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
RampMode();
virtual ~RampMode();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// 0: 3.2 s
/// 1: 1.6 s
/// 2: 1.2 s
/// 3: 0.8 s
/// Use default value!
///////////////////////////////////////////////////////////////////////////////
class ShortDetectionTimer : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ShortDetectionTimer();
virtual ~ShortDetectionTimer();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// 0: Short to GND protection is on
/// 1: Short to GND protection is disabled
/// Use default value!
///////////////////////////////////////////////////////////////////////////////
class ShortProtectionDisable : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ShortProtectionDisable();
virtual ~ShortProtectionDisable();
void getParameter(bool& parameter) const;
void setParameter(const bool parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
bool value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Determines the slope of the motor driver outputs. Set to 2 or 3 for this module or rather use the default value.
/// 0: lowest slope
/// 3: fastest slope
///////////////////////////////////////////////////////////////////////////////
class SlopeControlHighSide : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SlopeControlHighSide();
virtual ~SlopeControlHighSide();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Determines the slope of the motor driver outputs. Set identical to slope control high side.
///////////////////////////////////////////////////////////////////////////////
class SlopeControlLowSide : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SlopeControlLowSide();
virtual ~SlopeControlLowSide();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// This status value provides the actual motor current setting as controlled by coolStepTM. The value goes up to the CS value and down to the portion of CS as specified by SEIMIN.
/// actual motor current scaling factor:
/// 0 ... 31: 1/32, 2/32, ... 32/32
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyActualCurrent : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SmartEnergyActualCurrent();
virtual ~SmartEnergyActualCurrent();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Sets the number of stallGuard2 readings current down above the upper threshold necessary for each step current decrement of the motor current.
/// Number of stallGuard2 measurements per decrement:
/// Scaling: 0... 3: 32, 8, 2, 1
/// 0: slow decrement
/// 3: fast decrement
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyCurrentDownStep : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SmartEnergyCurrentDownStep();
virtual ~SmartEnergyCurrentDownStep();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Sets the lower motor current limit for current minimum coolStep operation by scaling the CS (Current Scale, see axis parameter 6) value.
/// minimum motor current:
/// 0 1/2 of CS
/// 1 1/4 of CS
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyCurrentMinimum : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SmartEnergyCurrentMinimum();
virtual ~SmartEnergyCurrentMinimum();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Sets the current increment step. The current becomes incremented for each measured stallGuard2 value below the lower threshold (see smartEnergy hysteresis start). current increment step size:
/// Scaling: 0... 3: 1, 2, 4, 8
/// 0: slow increment
/// 3: fast increment / fast reaction to rising load
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyCurrentUpStep : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SmartEnergyCurrentUpStep();
virtual ~SmartEnergyCurrentUpStep();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Sets the distance between the lower and the upper threshold for stallGuard2TM reading. Above the upper threshold the motor current becomes decreased.
/// Hysteresis: (smartEnergy hysteresis value + 1) * 32
/// Upper stallGuard2 threshold: (smartEnergy hysteresis start + smartEnergy hysteresis + 1) * 32
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyHysteresis : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SmartEnergyHysteresis();
virtual ~SmartEnergyHysteresis();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The lower threshold for the stallGuard2 value (see smart Energy current up step).
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyHysteresisStart : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SmartEnergyHysteresisStart();
virtual ~SmartEnergyHysteresisStart();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Sets the motor current which is used below the threshold speed.
///////////////////////////////////////////////////////////////////////////////
class SmartEnergySlowRunCurrent : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SmartEnergySlowRunCurrent();
virtual ~SmartEnergySlowRunCurrent();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Above this speed coolStep becomes enabled.
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyThresholdSpeed : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
SmartEnergyThresholdSpeed();
virtual ~SmartEnergyThresholdSpeed();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Enables the stallGuard2 filter for more precision of the measurement. If set, reduces the measurement frequency to one measurement per four fullsteps. In most cases it is expedient to set the filtered mode before using coolStep. Use the standard mode for step loss detection.
/// 0 standard mode
/// 1 filtered mode
///////////////////////////////////////////////////////////////////////////////
class StallGuard2FilterEnable : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
StallGuard2FilterEnable();
virtual ~StallGuard2FilterEnable();
void getParameter(bool& parameter) const;
void setParameter(const bool parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
bool value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// This signed value controls stallGuard2 threshold level for stall output and sets the optimum measurement range for readout. A lower value gives a higher sensitivity. Zero is the starting value. A higher value makes stallGuard2 less sensitive and requires more torque to indicate a stall.
/// 0 Indifferent value
/// 1... 63 less sensitivity
/// -1... -64 higher sensitivity
///////////////////////////////////////////////////////////////////////////////
class StallGuard2Threshold : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
StallGuard2Threshold();
virtual ~StallGuard2Threshold();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The current limit two seconds after the motor has stopped.
///////////////////////////////////////////////////////////////////////////////
class StandbyCurrent : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
StandbyCurrent();
virtual ~StandbyCurrent();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Step interpolation is supported with a 16 microstep setting only. In this setting, each step impulse at the input causes the execution of 16 times 1/256 microsteps. This way, a smooth motor movement like in 256 microstep resolution is achieved.
/// 0 step interpolation off
/// 1 step interpolation on
///////////////////////////////////////////////////////////////////////////////
class StepInterpolationEnable : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
StepInterpolationEnable();
virtual ~StepInterpolationEnable();
void getParameter(bool& parameter) const;
void setParameter(const bool parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
bool value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Motor stop in case of stall.
///////////////////////////////////////////////////////////////////////////////
class StopOnStall : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
StopOnStall();
virtual ~StopOnStall();
void getParameter(bool& parameter) const;
void setParameter(const bool parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
bool value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// sense resistor voltage based current scaling
/// 0: Full scale sense resistor voltage is 1/18 VDD
/// 1: Full scale sense resistor voltage is 1/36 VDD
/// (refers to a current setting of 31 and DAC value 255)
/// Use default value. Do not change!
///////////////////////////////////////////////////////////////////////////////
class Vsense : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
Vsense();
virtual ~Vsense();
void getParameter(unsigned int& parameter) const;
void setParameter(const unsigned int& parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
unsigned int upperLimit;
unsigned int lowerLimit;
unsigned int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// The current acceleration (read only).
///////////////////////////////////////////////////////////////////////////////
class ActualAcceleration : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
ActualAcceleration();
virtual ~ActualAcceleration();
void getParameter(int& parameter) const;
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
///////////////////////////////////////////////////////////////////////////////
/// Should always be set 1 to ensure exact reaching of the target position. Do not change!
///////////////////////////////////////////////////////////////////////////////
class MinimumSpeed : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
public:
MinimumSpeed();
virtual ~MinimumSpeed();
void getParameter(int& parameter) const;
void setParameter(const int parameter);
void toString(std::string& value) const;
private:
void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;
void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);
std::string getName() const {return this->name;};
ParameterType getType() const {return this->parameterType;};
int upperLimit;
int lowerLimit;
int value;
std::string name;
ParameterType parameterType;
};
} // namespace youbot
#endif
| 27.451885 | 334 | 0.626565 | [
"vector"
] |
d55f98fa57d9cd6cfad8f70881f90b6c7d2a1163 | 958 | cpp | C++ | g4g/1380.cpp | perryizgr8/scratchpad | d7dbd65d53fd0936df6e9112b9468855b9c5089e | [
"MIT"
] | null | null | null | g4g/1380.cpp | perryizgr8/scratchpad | d7dbd65d53fd0936df6e9112b9468855b9c5089e | [
"MIT"
] | null | null | null | g4g/1380.cpp | perryizgr8/scratchpad | d7dbd65d53fd0936df6e9112b9468855b9c5089e | [
"MIT"
] | null | null | null | //Set Bits
//bit Adobe Brocade Cisco Juniper Networks
//Given a positive integer N, print count of set bits in it. For example, if the given number is 6, output should be 2 as there are two set bits in it.
//
//Input:
//
//The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The next T lines will contain an integer N.
//
//Output:
//Corresponding to each test case, in a new line, print count of set bits in it.
//
//Constraints:
//
//1 ≤ T ≤ 100
//
//1 ≤ N ≤ 1000000
//
//
//Example:
//
//Input:
//
//2
//6
//11
//
//
//Output:
//2
//3
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
int main()
{
int N;
std::cin >> N;
for (int i = 0; i < N; i++) {
uint64_t num;
int count = 0;
std::cin >> num;
for (int j = 0; j < 64; j++) {
if ((num >> j) & 1) {
count++;
}
}
std::cout << count << std::endl;
}
return 0;
}
| 17.418182 | 152 | 0.598121 | [
"vector"
] |
d560ddcc68ae3743ed2a734b2af4c192d549879b | 2,502 | cpp | C++ | graph/mst/mst.cpp | fredyshox/Algorithms | f630231d8f34b9f3a3aed89741891e845501f75c | [
"MIT"
] | null | null | null | graph/mst/mst.cpp | fredyshox/Algorithms | f630231d8f34b9f3a3aed89741891e845501f75c | [
"MIT"
] | null | null | null | graph/mst/mst.cpp | fredyshox/Algorithms | f630231d8f34b9f3a3aed89741891e845501f75c | [
"MIT"
] | null | null | null | //
// spanning_trees.cpp
// lista5
//
// Created by Kacper Raczy on 02.06.2018.
// Copyright © 2018 Kacper Raczy. All rights reserved.
//
#include "mst.hpp"
bool mst_comp(edge e1, edge e2) {
return e1.weight < e2.weight;
}
// Subset operations
void make_set(subset* set, int x) {
set->parent = x;
set->rank = 0;
}
int find_set(subset* sets, int x) {
if (sets[x].parent != x) {
sets[x].parent = find_set(sets, sets[x].parent);
}
return sets[x].parent;
}
void union_set(subset* sets, int x, int y) {
int xRoot = find_set(sets, x);
int yRoot = find_set(sets, y);
if (sets[xRoot].rank > sets[yRoot].rank) {
sets[yRoot].parent = xRoot;
} else {
sets[xRoot].parent = yRoot;
if (sets[xRoot].rank == sets[yRoot].rank) {
sets[yRoot].rank += 1;
}
}
}
// MST Algorithms
graph* mst_kruskal(graph* g) {
int size = g->v_count();
vector<edge> edges = g->all_edges();
graph* tree = new graph(size);
subset* sets = new subset[size];
for (int i = 0; i < size; i++) {
make_set(&sets[i], i);
}
std::sort(edges.begin(), edges.end(), mst_comp);
for(edge &e : edges) {
if (find_set(sets, e.v1) != find_set(sets, e.v2)) {
tree->add_edge(e.v1, e.v2, e.weight);
union_set(sets, e.v1, e.v2);
}
}
return tree;
}
graph* mst_prim(graph* g) {
int size = g->v_count();
double** gMatrix = g->adjacency_matrix();
int root = 0; // first vertex as root (start)
vector<double> key(size, LONG_MAX);
vector<bool> inMst(size, false);
vector<int> parent(size, -1);
priority_queue<int> queue;
for (int i = 0; i < size; i++) {
queue.insert(i, LONG_MAX);
}
key[root] = 0;
queue.dec_priority(root, 0);
int current;
double weight;
while (!queue.is_empty()) {
current = queue.pop();
inMst[current] = true;
for (int v = 0; v < size; v++) {
weight = gMatrix[current][v];
if (weight && !inMst[v] && weight < key[v]) {
key[v] = weight;
queue.dec_priority(v, * (long *) &weight); // floating point bit level hack
parent[v] = current;
}
}
}
graph* parent_graph = new graph(size);
for(int i = 0; i < size; i++) {
if (parent[i] >= 0) {
parent_graph->add_edge(i, parent[i], gMatrix[i][parent[i]]);
}
}
return parent_graph;
}
| 23.828571 | 91 | 0.535572 | [
"vector"
] |
d56567d1f1ec58f2f20592427c873cac373828d4 | 4,369 | cxx | C++ | src/vtk/DRCFilters/vtkPlaneSegmentation.cxx | edrumwri/director | c82aff0ed2ad0083dc5ac9cf4b90994d2d852be8 | [
"BSD-3-Clause"
] | 18 | 2018-11-05T09:16:11.000Z | 2021-12-21T09:05:50.000Z | src/vtk/DRCFilters/vtkPlaneSegmentation.cxx | edrumwri/director | c82aff0ed2ad0083dc5ac9cf4b90994d2d852be8 | [
"BSD-3-Clause"
] | 36 | 2018-10-09T21:33:43.000Z | 2020-12-10T11:22:29.000Z | src/vtk/DRCFilters/vtkPlaneSegmentation.cxx | edrumwri/director | c82aff0ed2ad0083dc5ac9cf4b90994d2d852be8 | [
"BSD-3-Clause"
] | 5 | 2017-02-22T17:56:52.000Z | 2019-07-21T09:04:53.000Z | #include "vtkPlaneSegmentation.h"
//#include "vtkPCLConversions.h"
#include "vtkPolyData.h"
#include "vtkPointData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkSmartPointer.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkPlane.h"
#include "vtkNew.h"
#include "vtkFloatArray.h"
#include "vtkDoubleArray.h"
#include <plane-seg/PlaneFitter.hpp>
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPlaneSegmentation);
//----------------------------------------------------------------------------
vtkPlaneSegmentation::vtkPlaneSegmentation()
{
this->DistanceThreshold = 0.05;
this->MaxIterations = 200;
this->PlaneCoefficients[0] = 0.0;
this->PlaneCoefficients[1] = 0.0;
this->PlaneCoefficients[2] = 0.0;
this->PlaneCoefficients[3] = 0.0;
this->PerpendicularConstraintEnabled = false;
this->AngleEpsilon = 0.2;
this->PerpendicularAxis[0] = 1.0;
this->PerpendicularAxis[1] = 0.0;
this->PerpendicularAxis[2] = 0.0;
this->SetNumberOfInputPorts(1);
this->SetNumberOfOutputPorts(1);
}
//----------------------------------------------------------------------------
vtkPlaneSegmentation::~vtkPlaneSegmentation()
{
}
//----------------------------------------------------------------------------
int vtkPlaneSegmentation::RequestData(
vtkInformation* vtkNotUsed(request),
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
// get input and output data objects
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
vtkPolyData *input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkPolyData *output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
// convert point cloud
std::vector<Eigen::Vector3f> pointList;
const vtkIdType numberOfPoints = input->GetNumberOfPoints();
pointList.resize(numberOfPoints);
vtkFloatArray* floatPoints = vtkFloatArray::SafeDownCast(input->GetPoints()->GetData());
vtkDoubleArray* doublePoints = vtkDoubleArray::SafeDownCast(input->GetPoints()->GetData());
assert((floatPoints != NULL) || (doublePoints != NULL));
if (floatPoints != NULL) {
float* data = floatPoints->GetPointer(0);
for (vtkIdType i = 0; i < numberOfPoints; ++i) {
pointList[i] << data[i*3], data[i*3+1], data[i*3+2];
}
}
else if (doublePoints != NULL) {
double* data = doublePoints->GetPointer(0);
for (vtkIdType i = 0; i < numberOfPoints; ++i) {
pointList[i] << data[i*3], data[i*3+1], data[i*3+2];
}
}
// perform plane model fit
planeseg::PlaneFitter fitter;
fitter.setMaxDistance(this->DistanceThreshold);
fitter.setMaxIterations(this->MaxIterations, 10);
fitter.setRefineUsingInliers(true);
if (this->PerpendicularConstraintEnabled) {
Eigen::Vector3f prior(this->PerpendicularAxis[0],
this->PerpendicularAxis[1],
this->PerpendicularAxis[2]);
fitter.setNormalPrior(prior, this->AngleEpsilon);
}
planeseg::PlaneFitter::Result result = fitter.go(pointList);
if (!result.mSuccess) {
vtkErrorMacro("Error segmenting plane.");
return 0;
}
// store plane coefficients
if (result.mPlane[2] < 0) result.mPlane = -result.mPlane;
for (size_t i = 0; i < 4; ++i) {
this->PlaneCoefficients[i] = result.mPlane[i];
}
vtkNew<vtkPlane> plane;
Eigen::Vector3d normal = result.mPlane.head<3>().cast<double>();
plane->SetNormal(normal.data());
plane->Push(-result.mPlane[3]);
plane->GetOrigin(this->PlaneOrigin);
plane->GetNormal(this->PlaneNormal);
// pass thru input add labels
vtkSmartPointer<vtkIntArray> labels = vtkSmartPointer<vtkIntArray>::New();
labels->SetNumberOfComponents(1);
labels->SetNumberOfTuples(pointList.size());
labels->FillComponent(0, 0);
for (size_t k = 0; k < result.mInliers.size(); ++k) {
labels->SetValue(result.mInliers[k], 1);
}
labels->SetName("ransac_labels");
output->ShallowCopy(input);
output->GetPointData()->AddArray(labels);
return 1;
}
//----------------------------------------------------------------------------
void vtkPlaneSegmentation::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
| 33.868217 | 94 | 0.644999 | [
"vector",
"model"
] |
d5669ee64930074e95c62982d3765e8480bc67f5 | 786 | cpp | C++ | Kattis/kornislav.cpp | YourName0729/competitive-programming | 437ef18a46074f520e0bfa0bdd718bb6b1c92800 | [
"MIT"
] | 3 | 2021-02-19T17:01:11.000Z | 2021-03-11T16:50:19.000Z | Kattis/kornislav.cpp | YourName0729/competitive-programming | 437ef18a46074f520e0bfa0bdd718bb6b1c92800 | [
"MIT"
] | null | null | null | Kattis/kornislav.cpp | YourName0729/competitive-programming | 437ef18a46074f520e0bfa0bdd718bb6b1c92800 | [
"MIT"
] | null | null | null | //
// https://open.kattis.com/problems/kornislav
#include <vector>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <stack>
#include <cmath>
#include <map>
#include <utility>
#include <queue>
#include <iomanip>
#include <deque>
#include <set>
#define Forcase int __t;cin>>__t;getchar();for(int ___t=1;___t<=__t;___t++)
#define For(i, n) for(int i=0;i<n;i++)
#define Fore(e, arr) for(auto e:arr)
#define INF 1e9
#define EPS 1e-9
using ull = unsigned long long;
using ll = long long;
using namespace std;
int arr[4];
int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// cout.tie(NULL);
For (i, 4) {
cin >> arr[i];
}
sort(arr, arr + 4);
cout << arr[0] * arr[2] << '\n';
return 0;
}
| 18.27907 | 75 | 0.622137 | [
"vector"
] |
d5674b4251646c01465f357f0d0b21a64bbede82 | 517 | hpp | C++ | physics/physics.hpp | quyse/inanity | a39225c5a41f879abe5aa492bb22b500dbe77433 | [
"MIT"
] | 26 | 2015-04-22T05:25:25.000Z | 2020-11-15T11:07:56.000Z | physics/physics.hpp | quyse/inanity | a39225c5a41f879abe5aa492bb22b500dbe77433 | [
"MIT"
] | 2 | 2015-01-05T10:41:27.000Z | 2015-01-06T20:46:11.000Z | physics/physics.hpp | quyse/inanity | a39225c5a41f879abe5aa492bb22b500dbe77433 | [
"MIT"
] | 5 | 2016-08-02T11:13:57.000Z | 2018-10-26T11:19:27.000Z | #ifndef ___INANITY_PHYSICS_PHYSICS_HPP___
#define ___INANITY_PHYSICS_PHYSICS_HPP___
/* Общий файл для подсистемы физики.
По идее, физика может работать через различные бэкэнды.
Сейчас есть только подсистема Bullet.
*/
#include "../Object.hpp"
// Решено просто включать математику во всю физику.
#include "../inanity-math.hpp"
#define BEGIN_INANITY_PHYSICS BEGIN_INANITY namespace Physics {
#define END_INANITY_PHYSICS } END_INANITY
BEGIN_INANITY_PHYSICS
using namespace Inanity::Math;
END_INANITY_PHYSICS
#endif
| 24.619048 | 63 | 0.820116 | [
"object"
] |
d575a060f1c7ca9dd9647f3843d12e5dae737c85 | 6,566 | hh | C++ | src/Material/HelmholtzEquationOfState.hh | markguozhiming/spheral | bbb982102e61edb8a1d00cf780bfa571835e1b61 | [
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | 1 | 2020-10-21T01:56:55.000Z | 2020-10-21T01:56:55.000Z | src/Material/HelmholtzEquationOfState.hh | markguozhiming/spheral | bbb982102e61edb8a1d00cf780bfa571835e1b61 | [
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | null | null | null | src/Material/HelmholtzEquationOfState.hh | markguozhiming/spheral | bbb982102e61edb8a1d00cf780bfa571835e1b61 | [
"BSD-Source-Code",
"BSD-3-Clause-LBNL",
"FSFAP"
] | null | null | null | //
// HelmholtzEquationOfState.h
//
//
// Created by Raskin, Cody Dantes on 8/28/14.
//
//
#ifndef ____HelmholtzEquationOfState_hh__
#define ____HelmholtzEquationOfState_hh__
#include "EquationOfState.hh"
#include "Field/FieldList.hh"
namespace Spheral {
template<typename Dimension>
class HelmholtzEquationOfState: public EquationOfState<Dimension> {
public:
//--------------------------- Public Interface ---------------------------//
typedef typename Dimension::Scalar Scalar;
typedef typename Dimension::Vector Vector;
typedef typename Dimension::Tensor Tensor;
typedef typename Dimension::SymTensor SymTensor;
// Constructors, destructors.
HelmholtzEquationOfState(const PhysicalConstants& constants,
const double minimumPressure,
const double maximumPressure,
const double minimumTemperature,
const MaterialPressureMinType minPressureType,
const Scalar abar0,
const Scalar zbar0);
~HelmholtzEquationOfState();
// We require any equation of state to define the following properties.
virtual void setPressure(Field<Dimension, Scalar>& Pressure,
const Field<Dimension, Scalar>& massDensity,
const Field<Dimension, Scalar>& specificThermalEnergy) const;
virtual void setTemperature(Field<Dimension, Scalar>& temperature,
const Field<Dimension, Scalar>& massDensity,
const Field<Dimension, Scalar>& specificThermalEnergy) const;
virtual void setSpecificThermalEnergy(Field<Dimension, Scalar>& specificThermalEnergy,
const Field<Dimension, Scalar>& massDensity,
const Field<Dimension, Scalar>& temperature) const;
virtual void setSpecificHeat(Field<Dimension, Scalar>& specificHeat,
const Field<Dimension, Scalar>& massDensity,
const Field<Dimension, Scalar>& temperature) const;
virtual void setSoundSpeed(Field<Dimension, Scalar>& soundSpeed,
const Field<Dimension, Scalar>& massDensity,
const Field<Dimension, Scalar>& specificThermalEnergy) const;
virtual void setGammaField(Field<Dimension, Scalar>& gamma,
const Field<Dimension, Scalar>& massDensity,
const Field<Dimension, Scalar>& specificThermalEnergy) const;
virtual void setBulkModulus(Field<Dimension, Scalar>& bulkModulus,
const Field<Dimension, Scalar>& massDensity,
const Field<Dimension, Scalar>& specificThermalEnergy) const;
virtual void setEntropy(Field<Dimension, Scalar>& entropy,
const Field<Dimension, Scalar>& massDensity,
const Field<Dimension, Scalar>& specificThermalEnergy) const;
// Some of the following methods are disabled
virtual Scalar pressure(const Scalar massDensity,
const Scalar specificThermalEnergy) const { VERIFY2(false, "HelmholtzEquationOfState does not support individual state calls."); }
virtual Scalar temperature(const Scalar massDensity,
const Scalar specificThermalEnergy) const { VERIFY2(false, "HelmholtzEquationOfState does not support individual state calls."); }
virtual Scalar specificThermalEnergy(const Scalar massDensity,
const Scalar temperature) const { VERIFY2(false, "HelmholtzEquationOfState does not support individual state calls."); }
virtual Scalar specificHeat(const Scalar massDensity,
const Scalar temperature) const { VERIFY2(false, "HelmholtzEquationOfState does not support individual state calls."); }
virtual Scalar soundSpeed(const Scalar massDensity,
const Scalar specificThermalEnergy) const { VERIFY2(false, "HelmholtzEquationOfState does not support individual state calls."); }
// Get the effective gamma (ratio of specific heats) for this eos.
virtual Scalar gamma(const Scalar massDensity,
const Scalar specificThermalEnergy) const { VERIFY2(false, "HelmholtzEquationOfState does not support individual state calls."); }
// Get the bulk modulus.
virtual Scalar bulkModulus(const Scalar massDensity,
const Scalar specificThermalEnergy) const { VERIFY2(false, "HelmholtzEquationOfState does not support individual state calls."); }
virtual Scalar entropy(const Scalar massDensity,
const Scalar specificThermalEnergy) const { VERIFY2(false, "HelmholtzEquationOfState does not support individual state calls."); }
const Field<Dimension, Scalar>& abar() const;
const Field<Dimension, Scalar>& zbar() const;
const bool getUpdateStatus() const;
void setUpdateStatus(bool bSet);
virtual bool valid() const;
private:
//--------------------------- Private Interface ---------------------------//
mutable std::shared_ptr<Field<Dimension, Scalar> > myAbar;
mutable std::shared_ptr<Field<Dimension, Scalar> > myZbar;
mutable std::shared_ptr<Field<Dimension, Scalar> > mySpecificThermalEnergy;
mutable std::shared_ptr<Field<Dimension, Scalar> > myMassDensity;
mutable std::shared_ptr<Field<Dimension, Scalar> > myTemperature;
mutable std::shared_ptr<Field<Dimension, Scalar> > myPressure;
mutable std::shared_ptr<Field<Dimension, Scalar> > mySoundSpeed;
mutable std::shared_ptr<Field<Dimension, Scalar> > myGamma;
mutable std::shared_ptr<Field<Dimension, Scalar> > myEntropy;
Scalar mabar0, mzbar0, mPmin, mPmax;
mutable Scalar mTmin;
bool needUpdate;
const PhysicalConstants& mConstants;
Scalar mDistincm, mMassing, mEnergyinergpg, mTimeins, mPressureinbarye, mDensingpccm, mVelincmps;
void storeFields(const Field<Dimension, Scalar>& thisMassDensity, const Field<Dimension, Scalar>& thisSpecificThermalEnergy) const;
};
}
#else
namespace Spheral {
template<typename Dimension> class HelmholtzEquationOfState;
}
#endif
| 46.9 | 159 | 0.637527 | [
"vector"
] |
d578582e6e48fc01ee5923cb2f2b18777d57c717 | 5,310 | hpp | C++ | boost/boost/iostreams/filter/aggregate.hpp | randolphwong/mcsema | eb5b376736e7f57ff0a61f7e4e5a436bbb874720 | [
"BSD-3-Clause"
] | 1,210 | 2020-08-18T07:57:36.000Z | 2022-03-31T15:06:05.000Z | boost/boost/iostreams/filter/aggregate.hpp | randolphwong/mcsema | eb5b376736e7f57ff0a61f7e4e5a436bbb874720 | [
"BSD-3-Clause"
] | 61 | 2015-05-27T11:20:11.000Z | 2019-12-20T15:06:21.000Z | boost/boost/iostreams/filter/aggregate.hpp | randolphwong/mcsema | eb5b376736e7f57ff0a61f7e4e5a436bbb874720 | [
"BSD-3-Clause"
] | 275 | 2020-08-18T08:35:16.000Z | 2022-03-31T15:06:07.000Z | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
// (C) Copyright 2003-2007 Jonathan Turkanis
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
// See http://www.boost.org/libs/iostreams for documentation.
#ifndef BOOST_IOSTREAMS_AGGREGATE_FILTER_HPP_INCLUDED
#define BOOST_IOSTREAMS_AGGREGATE_FILTER_HPP_INCLUDED
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <algorithm> // copy, min.
#include <boost/assert.hpp>
#include <iterator> // back_inserter
#include <vector>
#include <boost/iostreams/constants.hpp> // default_device_buffer_size
#include <boost/iostreams/categories.hpp>
#include <boost/iostreams/detail/char_traits.hpp>
#include <boost/iostreams/detail/ios.hpp> // openmode, streamsize.
#include <boost/iostreams/pipeline.hpp>
#include <boost/iostreams/read.hpp> // check_eof
#include <boost/iostreams/write.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/type_traits/is_convertible.hpp>
// Must come last.
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
namespace boost { namespace iostreams {
//
// Template name: aggregate_filter.
// Template parameters:
// Ch - The character type.
// Alloc - The allocator type.
// Description: Utility for defining DualUseFilters which filter an
// entire stream at once. To use, override the protected virtual
// member do_filter.
// Note: This filter should not be copied while it is in use.
//
template<typename Ch, typename Alloc = std::allocator<Ch> >
class aggregate_filter {
public:
typedef Ch char_type;
struct category
: dual_use,
filter_tag,
multichar_tag,
closable_tag
{ };
aggregate_filter() : ptr_(0), state_(0) { }
virtual ~aggregate_filter() { }
template<typename Source>
std::streamsize read(Source& src, char_type* s, std::streamsize n)
{
using namespace std;
BOOST_ASSERT(!(state_ & f_write));
state_ |= f_read;
if (!(state_ & f_eof))
do_read(src);
std::streamsize amt =
(std::min)(n, static_cast<std::streamsize>(data_.size() - ptr_));
if (amt) {
BOOST_IOSTREAMS_CHAR_TRAITS(char_type)::copy(s, &data_[ptr_], amt);
ptr_ += amt;
}
return detail::check_eof(amt);
}
template<typename Sink>
std::streamsize write(Sink&, const char_type* s, std::streamsize n)
{
BOOST_ASSERT(!(state_ & f_read));
state_ |= f_write;
data_.insert(data_.end(), s, s + n);
return n;
}
template<typename Sink>
void close(Sink& sink, BOOST_IOS::openmode which)
{
if ((state_ & f_read) != 0 && which == BOOST_IOS::in)
close_impl();
if ((state_ & f_write) != 0 && which == BOOST_IOS::out) {
try {
vector_type filtered;
do_filter(data_, filtered);
do_write(
sink, &filtered[0],
static_cast<std::streamsize>(filtered.size())
);
} catch (...) {
close_impl();
throw;
}
close_impl();
}
}
protected:
typedef std::vector<Ch, Alloc> vector_type;
typedef typename vector_type::size_type size_type;
private:
virtual void do_filter(const vector_type& src, vector_type& dest) = 0;
virtual void do_close() { }
template<typename Source>
void do_read(Source& src)
{
using std::streamsize;
vector_type data;
while (true) {
const std::streamsize size = default_device_buffer_size;
Ch buf[size];
std::streamsize amt;
if ((amt = boost::iostreams::read(src, buf, size)) == -1)
break;
data.insert(data.end(), buf, buf + amt);
}
do_filter(data, data_);
state_ |= f_eof;
}
template<typename Sink>
void do_write(Sink& sink, const char_type* s, std::streamsize n)
{
typedef typename iostreams::category_of<Sink>::type category;
typedef is_convertible<category, output> can_write;
do_write(sink, s, n, can_write());
}
template<typename Sink>
void do_write(Sink& sink, const char_type* s, std::streamsize n, mpl::true_)
{ iostreams::write(sink, s, n); }
template<typename Sink>
void do_write(Sink&, const char_type*, std::streamsize, mpl::false_) { }
void close_impl()
{
data_.clear();
ptr_ = 0;
state_ = 0;
do_close();
}
enum flag_type {
f_read = 1,
f_write = f_read << 1,
f_eof = f_write << 1
};
// Note: typically will not be copied while vector contains data.
vector_type data_;
size_type ptr_;
int state_;
};
BOOST_IOSTREAMS_PIPABLE(aggregate_filter, 1)
} } // End namespaces iostreams, boost.
#include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC.
#endif // #ifndef BOOST_IOSTREAMS_AGGREGATE_FILTER_HPP_INCLUDED
| 31.420118 | 81 | 0.603578 | [
"vector"
] |
d57a2f952cbd889a8c4d8730110720fb588fe3fa | 23,739 | cc | C++ | gestop/proto/landmarkList.pb.cc | ofnote/gestop | 8534ae582c0fb6c6cd5f86d0d01d9ef0dd611093 | [
"Apache-2.0"
] | 24 | 2020-10-02T08:58:48.000Z | 2022-03-30T06:04:07.000Z | gestop/proto/landmarkList.pb.cc | ofnote/gestop | 8534ae582c0fb6c6cd5f86d0d01d9ef0dd611093 | [
"Apache-2.0"
] | 6 | 2020-10-02T09:26:35.000Z | 2022-03-12T00:48:54.000Z | gestop/proto/landmarkList.pb.cc | ofnote/gestop | 8534ae582c0fb6c6cd5f86d0d01d9ef0dd611093 | [
"Apache-2.0"
] | 6 | 2020-10-02T08:58:52.000Z | 2021-05-10T15:57:22.000Z | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: landmarkList.proto
#include "landmarkList.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
extern PROTOBUF_INTERNAL_EXPORT_landmarkList_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_LandmarkList_Landmark_landmarkList_2eproto;
namespace hand_tracking {
class LandmarkList_LandmarkDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<LandmarkList_Landmark> _instance;
} _LandmarkList_Landmark_default_instance_;
class LandmarkListDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<LandmarkList> _instance;
} _LandmarkList_default_instance_;
} // namespace hand_tracking
static void InitDefaultsscc_info_LandmarkList_landmarkList_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::hand_tracking::_LandmarkList_default_instance_;
new (ptr) ::hand_tracking::LandmarkList();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::hand_tracking::LandmarkList::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_LandmarkList_landmarkList_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_LandmarkList_landmarkList_2eproto}, {
&scc_info_LandmarkList_Landmark_landmarkList_2eproto.base,}};
static void InitDefaultsscc_info_LandmarkList_Landmark_landmarkList_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::hand_tracking::_LandmarkList_Landmark_default_instance_;
new (ptr) ::hand_tracking::LandmarkList_Landmark();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::hand_tracking::LandmarkList_Landmark::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_LandmarkList_Landmark_landmarkList_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_LandmarkList_Landmark_landmarkList_2eproto}, {}};
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_landmarkList_2eproto[2];
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_landmarkList_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_landmarkList_2eproto = nullptr;
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_landmarkList_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::hand_tracking::LandmarkList_Landmark, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::hand_tracking::LandmarkList_Landmark, x_),
PROTOBUF_FIELD_OFFSET(::hand_tracking::LandmarkList_Landmark, y_),
PROTOBUF_FIELD_OFFSET(::hand_tracking::LandmarkList_Landmark, z_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::hand_tracking::LandmarkList, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::hand_tracking::LandmarkList, landmark_),
PROTOBUF_FIELD_OFFSET(::hand_tracking::LandmarkList, handedness_),
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::hand_tracking::LandmarkList_Landmark)},
{ 8, -1, sizeof(::hand_tracking::LandmarkList)},
};
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::hand_tracking::_LandmarkList_Landmark_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::hand_tracking::_LandmarkList_default_instance_),
};
const char descriptor_table_protodef_landmarkList_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\022landmarkList.proto\022\rhand_tracking\"\207\001\n\014"
"LandmarkList\0226\n\010landmark\030\001 \003(\0132$.hand_tr"
"acking.LandmarkList.Landmark\022\022\n\nhandedne"
"ss\030\002 \001(\010\032+\n\010Landmark\022\t\n\001x\030\001 \001(\002\022\t\n\001y\030\002 \001"
"(\002\022\t\n\001z\030\003 \001(\002b\006proto3"
;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_landmarkList_2eproto_deps[1] = {
};
static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_landmarkList_2eproto_sccs[2] = {
&scc_info_LandmarkList_landmarkList_2eproto.base,
&scc_info_LandmarkList_Landmark_landmarkList_2eproto.base,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_landmarkList_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_landmarkList_2eproto = {
false, false, descriptor_table_protodef_landmarkList_2eproto, "landmarkList.proto", 181,
&descriptor_table_landmarkList_2eproto_once, descriptor_table_landmarkList_2eproto_sccs, descriptor_table_landmarkList_2eproto_deps, 2, 0,
schemas, file_default_instances, TableStruct_landmarkList_2eproto::offsets,
file_level_metadata_landmarkList_2eproto, 2, file_level_enum_descriptors_landmarkList_2eproto, file_level_service_descriptors_landmarkList_2eproto,
};
// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_landmarkList_2eproto = (static_cast<void>(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_landmarkList_2eproto)), true);
namespace hand_tracking {
// ===================================================================
void LandmarkList_Landmark::InitAsDefaultInstance() {
}
class LandmarkList_Landmark::_Internal {
public:
};
LandmarkList_Landmark::LandmarkList_Landmark(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) {
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:hand_tracking.LandmarkList.Landmark)
}
LandmarkList_Landmark::LandmarkList_Landmark(const LandmarkList_Landmark& from)
: ::PROTOBUF_NAMESPACE_ID::Message() {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::memcpy(&x_, &from.x_,
static_cast<size_t>(reinterpret_cast<char*>(&z_) -
reinterpret_cast<char*>(&x_)) + sizeof(z_));
// @@protoc_insertion_point(copy_constructor:hand_tracking.LandmarkList.Landmark)
}
void LandmarkList_Landmark::SharedCtor() {
::memset(&x_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&z_) -
reinterpret_cast<char*>(&x_)) + sizeof(z_));
}
LandmarkList_Landmark::~LandmarkList_Landmark() {
// @@protoc_insertion_point(destructor:hand_tracking.LandmarkList.Landmark)
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
void LandmarkList_Landmark::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
}
void LandmarkList_Landmark::ArenaDtor(void* object) {
LandmarkList_Landmark* _this = reinterpret_cast< LandmarkList_Landmark* >(object);
(void)_this;
}
void LandmarkList_Landmark::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void LandmarkList_Landmark::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const LandmarkList_Landmark& LandmarkList_Landmark::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_LandmarkList_Landmark_landmarkList_2eproto.base);
return *internal_default_instance();
}
void LandmarkList_Landmark::Clear() {
// @@protoc_insertion_point(message_clear_start:hand_tracking.LandmarkList.Landmark)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
::memset(&x_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&z_) -
reinterpret_cast<char*>(&x_)) + sizeof(z_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* LandmarkList_Landmark::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// float x = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 13)) {
x_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
ptr += sizeof(float);
} else goto handle_unusual;
continue;
// float y = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 21)) {
y_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
ptr += sizeof(float);
} else goto handle_unusual;
continue;
// float z = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 29)) {
z_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
ptr += sizeof(float);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* LandmarkList_Landmark::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:hand_tracking.LandmarkList.Landmark)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// float x = 1;
if (!(this->x() <= 0 && this->x() >= 0)) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(1, this->_internal_x(), target);
}
// float y = 2;
if (!(this->y() <= 0 && this->y() >= 0)) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(2, this->_internal_y(), target);
}
// float z = 3;
if (!(this->z() <= 0 && this->z() >= 0)) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(3, this->_internal_z(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:hand_tracking.LandmarkList.Landmark)
return target;
}
size_t LandmarkList_Landmark::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:hand_tracking.LandmarkList.Landmark)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// float x = 1;
if (!(this->x() <= 0 && this->x() >= 0)) {
total_size += 1 + 4;
}
// float y = 2;
if (!(this->y() <= 0 && this->y() >= 0)) {
total_size += 1 + 4;
}
// float z = 3;
if (!(this->z() <= 0 && this->z() >= 0)) {
total_size += 1 + 4;
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void LandmarkList_Landmark::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:hand_tracking.LandmarkList.Landmark)
GOOGLE_DCHECK_NE(&from, this);
const LandmarkList_Landmark* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<LandmarkList_Landmark>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:hand_tracking.LandmarkList.Landmark)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:hand_tracking.LandmarkList.Landmark)
MergeFrom(*source);
}
}
void LandmarkList_Landmark::MergeFrom(const LandmarkList_Landmark& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:hand_tracking.LandmarkList.Landmark)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (!(from.x() <= 0 && from.x() >= 0)) {
_internal_set_x(from._internal_x());
}
if (!(from.y() <= 0 && from.y() >= 0)) {
_internal_set_y(from._internal_y());
}
if (!(from.z() <= 0 && from.z() >= 0)) {
_internal_set_z(from._internal_z());
}
}
void LandmarkList_Landmark::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:hand_tracking.LandmarkList.Landmark)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void LandmarkList_Landmark::CopyFrom(const LandmarkList_Landmark& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:hand_tracking.LandmarkList.Landmark)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool LandmarkList_Landmark::IsInitialized() const {
return true;
}
void LandmarkList_Landmark::InternalSwap(LandmarkList_Landmark* other) {
using std::swap;
_internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(LandmarkList_Landmark, z_)
+ sizeof(LandmarkList_Landmark::z_)
- PROTOBUF_FIELD_OFFSET(LandmarkList_Landmark, x_)>(
reinterpret_cast<char*>(&x_),
reinterpret_cast<char*>(&other->x_));
}
::PROTOBUF_NAMESPACE_ID::Metadata LandmarkList_Landmark::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
void LandmarkList::InitAsDefaultInstance() {
}
class LandmarkList::_Internal {
public:
};
LandmarkList::LandmarkList(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena),
landmark_(arena) {
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:hand_tracking.LandmarkList)
}
LandmarkList::LandmarkList(const LandmarkList& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
landmark_(from.landmark_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
handedness_ = from.handedness_;
// @@protoc_insertion_point(copy_constructor:hand_tracking.LandmarkList)
}
void LandmarkList::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_LandmarkList_landmarkList_2eproto.base);
handedness_ = false;
}
LandmarkList::~LandmarkList() {
// @@protoc_insertion_point(destructor:hand_tracking.LandmarkList)
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
void LandmarkList::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
}
void LandmarkList::ArenaDtor(void* object) {
LandmarkList* _this = reinterpret_cast< LandmarkList* >(object);
(void)_this;
}
void LandmarkList::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void LandmarkList::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const LandmarkList& LandmarkList::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_LandmarkList_landmarkList_2eproto.base);
return *internal_default_instance();
}
void LandmarkList::Clear() {
// @@protoc_insertion_point(message_clear_start:hand_tracking.LandmarkList)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
landmark_.Clear();
handedness_ = false;
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* LandmarkList::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// repeated .hand_tracking.LandmarkList.Landmark landmark = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_landmark(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else goto handle_unusual;
continue;
// bool handedness = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
handedness_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* LandmarkList::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:hand_tracking.LandmarkList)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .hand_tracking.LandmarkList.Landmark landmark = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_landmark_size()); i < n; i++) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(1, this->_internal_landmark(i), target, stream);
}
// bool handedness = 2;
if (this->handedness() != 0) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_handedness(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:hand_tracking.LandmarkList)
return target;
}
size_t LandmarkList::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:hand_tracking.LandmarkList)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .hand_tracking.LandmarkList.Landmark landmark = 1;
total_size += 1UL * this->_internal_landmark_size();
for (const auto& msg : this->landmark_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
// bool handedness = 2;
if (this->handedness() != 0) {
total_size += 1 + 1;
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void LandmarkList::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:hand_tracking.LandmarkList)
GOOGLE_DCHECK_NE(&from, this);
const LandmarkList* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<LandmarkList>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:hand_tracking.LandmarkList)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:hand_tracking.LandmarkList)
MergeFrom(*source);
}
}
void LandmarkList::MergeFrom(const LandmarkList& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:hand_tracking.LandmarkList)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
landmark_.MergeFrom(from.landmark_);
if (from.handedness() != 0) {
_internal_set_handedness(from._internal_handedness());
}
}
void LandmarkList::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:hand_tracking.LandmarkList)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void LandmarkList::CopyFrom(const LandmarkList& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:hand_tracking.LandmarkList)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool LandmarkList::IsInitialized() const {
return true;
}
void LandmarkList::InternalSwap(LandmarkList* other) {
using std::swap;
_internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
landmark_.InternalSwap(&other->landmark_);
swap(handedness_, other->handedness_);
}
::PROTOBUF_NAMESPACE_ID::Metadata LandmarkList::GetMetadata() const {
return GetMetadataStatic();
}
// @@protoc_insertion_point(namespace_scope)
} // namespace hand_tracking
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::hand_tracking::LandmarkList_Landmark* Arena::CreateMaybeMessage< ::hand_tracking::LandmarkList_Landmark >(Arena* arena) {
return Arena::CreateMessageInternal< ::hand_tracking::LandmarkList_Landmark >(arena);
}
template<> PROTOBUF_NOINLINE ::hand_tracking::LandmarkList* Arena::CreateMaybeMessage< ::hand_tracking::LandmarkList >(Arena* arena) {
return Arena::CreateMessageInternal< ::hand_tracking::LandmarkList >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 39.433555 | 171 | 0.74426 | [
"object"
] |
d57b610438a635e5093796b641205ab68fc40866 | 5,145 | cpp | C++ | examples/aircraft/aircraft.cpp | yinanl/rocs | bf2483903e39f4c0ea254a9ef56720a1259955ad | [
"BSD-3-Clause"
] | null | null | null | examples/aircraft/aircraft.cpp | yinanl/rocs | bf2483903e39f4c0ea254a9ef56720a1259955ad | [
"BSD-3-Clause"
] | null | null | null | examples/aircraft/aircraft.cpp | yinanl/rocs | bf2483903e39f4c0ea254a9ef56720a1259955ad | [
"BSD-3-Clause"
] | null | null | null | /**
* Safe landing control of DC9-30 with the specification-guided engine.
*
* Created by Yinan Li on Feb. 10, 2020.
* Hybrid Systems Group, University of Waterloo.
*/
#include <iostream>
#include "src/system.hpp"
#include "src/csolver.h"
// #include "src/matlabio.h"
#include "src/hdf5io.h"
/* Parameters of the model */
double mg = 60000.0*9.81;
double mi = 1.0/60000; /* weight inverse: 1/m */
/* ODE of the longitudinal equation of motions for DC9-30 */
struct eomlong {
static const int n = 3; // state dimension
static const int m = 2; // control dimension
/**
* Constructors:
* @param[out] dx (dV, dgamma, dh)
* @param[in] x (V,gamma,h).
* @param[in] u (T, alpha) control input (thrust, angle of attack)
*/
template<typename S>
eomlong(S *dx, const S *x, rocs::Rn u) {
double c = 1.25+4.2*u[1];
dx[0] = mi*(u[0]*cos(u[1])-(2.7+3.08*c*c)*x[0]*x[0]-mg*sin(x[1]));
dx[1] = (1.0/(60000*x[0]))*(u[0]*sin(u[1])+68.6*c*x[0]*x[0]-mg*cos(x[1]));
dx[2] = x[0]*sin(x[1]);
}
};
/** A target set in the form of f(x)<=0:
* x(0)*sin(x(1)) >= -0.91
*
**/
template<typename T>
T target_area(const T &x) {
T y(7);
y[0] = -0.91-x[0]*sin(x[1]);
y[1] = 63 - x[0];
y[2] = x[0] - 75;
y[3] = -3*M_PI/180 - x[1];
y[4] = x[1];
y[5] = -x[2];
y[6] = x[2] - 2.5;
return y;
}
// auto target = [](const double[] x) {
// if(63 <= x[0] && x[0] <= 75 &&
// -3*M_PI/180 <= x[1] && x[1] <= 0 &&
// 0 <= x[2] && x[2] <= 2.5) {
// return true;
// }
// return false;
// };
int main(int argc, char *argv[])
{
/**
* Define the control system
**/
/* Set sampling time and disturbance */
double tau = 0.25;
double delta = 10;
/* Set parameters for computation */
int kmax = 5;
double tol = 0.01;
double alpha = 0.5;
double beta = 2;
rocs::params controlparams(kmax, tol, alpha, beta);
rocs::CTCntlSys<eomlong> aircraft("landing", tau, eomlong::n,
eomlong::m, delta, &controlparams);
/* set the state space */
double xlb[] = {58, -3*M_PI/180, 0};
double xub[] = {83, 0, 56};
double ulb[] = {0,0};
double uub[] = {32000, 8*M_PI/180};
double mu[] = {32000, 9.0/8.0*M_PI/180};
aircraft.init_workspace(xlb, xub);
aircraft.init_inputset(mu, ulb, uub);
// std::cout << "# of u= " << aircraft._ugrid._nv
// << ", dimension= " << aircraft._ugrid._dim << '\n';
// for(int i = 0; i < aircraft._ugrid._nv; ++i) {
// std::cout << aircraft._ugrid._data[i][0] << ','
// << aircraft._ugrid._data[i][1] << '\n';
// }
aircraft.allocate_flows();
/* Set the target set */
const double eta[] = {25.0/362*2, 3*M_PI/180/66*2, 56.0/334*2};
const double emin[] = {2.5/362,0.3*M_PI/180/66,5.6/334};
double glb[] = {63, -3*M_PI/180, 0};
double gub[] = {75, 0, 2.5};
/* Solve the reachability problem */
rocs::CSolver solver(&aircraft, 0, rocs::RELMAX, 100);
// solver.init(rocs::GOAL, glb, gub);
solver.init(rocs::GOAL, &target_area<rocs::ivec>, eta);
solver.init_goal_area(); /* save the goal area information */
solver.reachability_control(&aircraft, eta);
solver.print_controller_info();
/* save the problem data and the solution */
// rocs::matWriter wtr("data_safe_landing.mat");
// wtr.open();
// wtr.write_problem_setting(aircraft, solver);
// wtr.write_sptree_controller(solver);
// wtr.close();
std::string datafile = "controller_itvl_safelanding.h5";
rocs::h5FileHandler ctlrWtr(datafile, H5F_ACC_TRUNC);
ctlrWtr.write_problem_setting< rocs::CTCntlSys<eomlong> >(aircraft);
ctlrWtr.write_ivec_array(solver._goal, "G");
ctlrWtr.write_ivec_array(solver._obs, "xobs");
ctlrWtr.write_sptree_controller(solver);
// /* Simulate the closed-loop control */
// double x[3] = {81, -M_PI/180, 55};
// double u[2] = {0, 0};
// while (1) {
// if (target(x)) {
// std::cout << "Arrived: " << x[0] << " " << x[1] << " " << x[2] << std::endl;
// break;
// } else {
// u[0] = solver._ctlr._cntl[0]
// }
// }
// /**
// * DBA control synthesis
// **/
// std::vector<rocs::CSolver*> w(nNodes);
// for (rocs::UintSmall i = 0; i < nNodes; ++ i) {
// w[i] = new rocs::CSolver(&aircraft,nProps);
// w[i]->set_M(arrayM[i]);
// for (rocs::UintSmall j = 1; j < nProps; ++j) {
// if (arrayM[i][j] < nNodes) {
// w[i]->labeling(P[2*(j-1)], P[2*j+1], j);
// }
// }
// // std::cout << "Initial partition of w" << i <<":\n";
// // w[i]->print_controller();
// }
// rocs::dba_control< rocs::CTCntlSys<eomlong> >(w, &aircraft, nNodes, acc, e);
// /**
// * Display and save memoryless controllers.
// */
// rocs::write_results_to_mat(aircraft, specfile, w);
// /**
// * Release dynamic memory
// **/
// for (rocs::UintSmall i = 0; i < nNodes; ++i) {
// delete w[i];
// }
aircraft.release_flows();
return 0;
}
| 29.568966 | 90 | 0.535083 | [
"vector",
"model"
] |
d57ee9d3a0bf05ebdbe88211e44e388a44b5bebf | 12,954 | cxx | C++ | src/stra_nodes/stra_copy.cxx | flame/tblis-strassen | 6e929ab34c366c4ec6804ad2bf7cae4b84ee81ab | [
"BSD-3-Clause"
] | 9 | 2017-08-25T08:25:01.000Z | 2021-12-02T20:41:28.000Z | src/stra_nodes/stra_copy.cxx | flame/tblis-strassen | 6e929ab34c366c4ec6804ad2bf7cae4b84ee81ab | [
"BSD-3-Clause"
] | null | null | null | src/stra_nodes/stra_copy.cxx | flame/tblis-strassen | 6e929ab34c366c4ec6804ad2bf7cae4b84ee81ab | [
"BSD-3-Clause"
] | 3 | 2018-07-31T05:58:20.000Z | 2022-01-11T03:36:46.000Z |
template<typename T, int Mat, unsigned N>
void tensor2matrix(const communicator& comm, const config& cfg,
stra_tensor_view<T,N> A, matrix_view<T>& Ap) const
//stra_block_scatter_matrix<T,N> A, matrix_view<T>& Ap) const
{
// -1: before, allocate buffers for Ap.
//0. Some constants extraction. Note that stra_tensor_matrix contains offset information
//1. Computing stra_block_scatter/scatter vector, formatting stra_block_scatter_matrix
//constexpr bool Trans = (Mat == MAT_B);
constexpr bool Trans = 0;
using namespace matrix_constants;
const len_type MR = (Mat == MAT_A ? cfg.gemm_mr.def<T>() : Mat == MAT_B ? cfg.gemm_kr.def<T>() : cfg.gemm_mr.def<T>());
const len_type KR = (Mat == MAT_A ? cfg.gemm_kr.def<T>() : Mat == MAT_B ? cfg.gemm_nr.def<T>() : cfg.gemm_nr.def<T>());
len_type m = At.length(0);
len_type k = At.length(1);
//stride_type* scat_buffer = (stride_type*)malloc( sizeof(stride_type) * (m + k) * 2 * N );
allocate....
stride_type* rscat_a = scat_buffer;
stride_type* cscat_a = scat_buffer + m;
stride_type* rbs_a = cscat_a + k;
stride_type* cbs_a = rbs_a + m;
// Generate rs_c, cs_c;
for (unsigned idx=0; idx < stra_size(At); idx++)
{
const unsigned offset = idx*2*(m+n);
At.fill_block_scatter(idx, 0, parent.rscat+offset, MB, parent.rbs+offset);
At.fill_block_scatter(idx, 1, parent.cscat+offset, NB, parent.cbs+offset);
}
auto buf = At.data();
auto coeff = At.coeff_list();
stra_block_scatter_matrix<T, N> A(At.length(0), At.length(1), buf, coeff,
rscat_a, MB, rbs_a,
cscat_a, NB, cbs_a);
//2. copying/adding tensor to matrix / matrix to tensor
//std::cout << "MR: " << MR << ";ME: " << ME << ";KR: " << KR << std::endl;
//TBLIS_ASSERT(A.block_size(0) == (!Trans ? MR : KR));
//TBLIS_ASSERT(A.block_size(1) == (!Trans ? KR : MR));
//const len_type MR = A.block_size(0);
//const len_type KR = A.block_size(1);
//std::cout << "MR: " << MR << "; KR:" << KR << std::endl;
//std::cout << "A.block_size(0): " << A.block_size(0) << ";A.block_size(1): " << A.block_size(1) << std::endl;
len_type m_a = A.length( 0 );
len_type k_a = A.length( 1 );
T* p_ap = Ap.data();
//std::cout << "m_a: " << m_a << ";k_a: " << k_a << std::endl;
len_type m_first, m_last, k_first, k_last;
std::tie(m_first, m_last, std::ignore,
k_first, k_last, std::ignore) =
comm.distribute_over_threads_2d(m_a, k_a, MR, KR);
//p_ap += m_first*k_a + k_first*ME; //(m_first, k_first)
len_type rs_ap = Ap.stride(0), cs_ap = Ap.stride(1);
p_ap += m_first*rs_ap + k_first*cs_ap; //(m_first, k_first)
//std::cout << "m_first: " << m_first << ";m_last: " << m_last << ";k_first: " << k_first << ";k_last: " << k_last << std::endl;
len_type off_m = m_first;
//std::cout << "off_m: " << off_m << std::endl;
//exit( 0 );
//A.length(0, MR);
A.shift(0, off_m);
const T* p_a = A.raw_data();
//auto a_list = A.raw_data();
//const T* p_a_list[N];
//for (unsigned idx = 0; idx < N; idx++)
//{
// p_a_list[idx] = a_list[idx];
//}
auto my_coeff_list = A.coeff_list();
T coeff_list[N];
for (unsigned idx = 0; idx < N; idx++)
{
coeff_list[idx] = my_coeff_list[idx];
}
//const stride_type* cscat_a = A.scatter(!Trans) + k_first;
//const stride_type* cbs_a = A.block_scatter(!Trans) + k_first/KR;
const stride_type* cscat_a[N];
const stride_type* cbs_a[N];
for (unsigned idx = 0; idx < N; idx++)
{
cscat_a[idx] = A.scatter(idx, !Trans) + k_first;
cbs_a[idx] = A.block_scatter(idx, !Trans) + k_first/KR;
}
//while (off_m < m_last)
//{
// len_type off_k = k_first;
// const stride_type* rscat_a[N];
// for (unsigned idx = 0; idx < N; idx++)
// {
// rscat_a[idx] = A.scatter(idx,0);
// }
// //len_type m = std::min(MR, m_last-off_m);
// //len_type k = k_last-k_first;
// T* p_ap_tmp = p_ap;
// while (off_k < k_last)
// {
// for (len_type p = 0;p < KR;p++) //replace KR with k
// {
// for (len_type mr = 0;mr < MR;mr++) //replace MR with m
// {
// p_ap_tmp[mr + cs_ap*p] = 0;//p_a[rscat_a[mr] + cscat_a[p]];
// for (unsigned idx = 0; idx < N; idx++)
// {
// p_ap_tmp[mr + cs_ap*p] += coeff_list[idx] * p_a[rscat_a[idx][mr] + cscat_a[idx][p]];
// }
// }
// //for (len_type mr = m;mr < MR;mr++)
// //{
// // p_ap[mr + ME*p] = T();
// //}
// }
// p_ap_tmp += cs_ap*KR;
// A.shift_block(1, 1);
// off_k += KR;
// }
// p_ap += rs_ap*MR;
// A.shift_block(0, 1);
// off_m += MR;
//}
while (off_m < m_last)
{
//stride_type rs_a = A.stride(Trans);
stride_type rs_a = A.stride(0,0);
bool is_all_rs_a_nonzero_same = check_all_rs_a_nonzero_same<Trans>( A ) ;
//bool is_all_rs_a_nonzero_same = true;
//const stride_type* rscat_a = A.scatter(Trans);
//////const stride_type* rscat_a = A.scatter(0,Trans);
const stride_type* rscat_a[N];
for (unsigned idx = 0; idx < N; idx++)
{
rscat_a[idx] = A.scatter(idx,0);
}
len_type m = std::min(MR, m_last-off_m);
len_type k = k_last-k_first;
//std::cout << "p_a_list[0]:" << p_a_list[0] << std::endl;
////if (rs_a == 0)
//if ( !is_all_rs_a_nonzero_same )
{
//std::cout << "not is_all_rs_a_nonzero_same" << std::endl;
//printf("%d/%d in %d/%d: sb\n",
// comm.thread_num(), comm.num_threads(),
// comm.gang_num(), comm.num_gangs());
{
//add_sb_mr_ukr.call<T>(m, k, p_a, rscat_a[0], cscat_a[0], cbs_a[0], p_ap);
for (len_type p = 0;p < k;p++) //replace KR with k
{
for (len_type mr = 0;mr < m;mr++) //replace MR with m
{
p_ap_tmp[mr + cs_ap*p] = 0;//p_a[rscat_a[mr] + cscat_a[p]];
for (unsigned idx = 0; idx < N; idx++)
{
p_ap_tmp[mr + cs_ap*p] += coeff_list[idx] * p_a[rscat_a[idx][mr] + cscat_a[idx][p]];
}
}
for (len_type mr = m;mr < MR;mr++)
{
p_ap[mr + cs_ap*p] = T();
}
}
//if (N == 1) {
// cfg.pack_sb_mr_ukr.call<T>(m, k, p_a, rscat_a[0], cscat_a[0], cbs_a[0], p_ap);
//} else if ( N == 2 ) {
// cfg.stra_pack_two_sb_mr_ukr.call<T>(m, k, N, p_a, coeff_list, rscat_a, cscat_a, cbs_a, p_ap);
//} else if ( N == 4 ) {
// cfg.stra_pack_four_sb_mr_ukr.call<T>(m, k, N, p_a, coeff_list, rscat_a, cscat_a, cbs_a, p_ap);
//} else {
// std::cout << "N is not 1,2,4" << std::endl;
// cfg.stra_pack_sb_mr_ukr.call<T>(m, k, N, p_a, coeff_list, rscat_a, cscat_a, cbs_a, p_ap);
//}
}
}
//else
//{
// //std::cout << "is_all_rs_a_nonzero_same" << std::endl;
// const T* p_a_list2[N];
// const stride_type* cscat_a2[N];
// const stride_type* cbs_a2[N];
// for (unsigned idx = 0; idx < N; idx++)
// {
// p_a_list2[idx] = p_a + rscat_a[idx][0];
// cscat_a2[idx] = cscat_a[idx];
// cbs_a2[idx] = cbs_a[idx];
// }
// //printf("%d/%d in %d/%d: nb\n",
// // comm.thread_num(), comm.num_threads(),
// // comm.gang_num(), comm.num_gangs());
// {
// ////cfg.pack_nb_mr_ukr.call<T>(m, k, p_a+rscat_a[0], rs_a, cscat_a, cbs_a, p_ap);
// ////cfg.pack_nb_mr_ukr.call<T>(m, k, p_a_list[0]+rscat_a[0][0], rs_a, cscat_a[0], cbs_a[0], p_ap);
// //cfg.stra_pack_nb_mr_ukr.call<T>(m, k, N, p_a_list2, coeff_list, rs_a, cscat_a2, cbs_a2, p_ap);
// ////rscat_a[idx][0]
// //std::cout << "p_a_list0:" << p_a[ rscat_a[0][0] + cscat_a[0][0] ] << std::endl;
// //std::cout << "p_a_list1:" << p_a[ rscat_a[1][0] + cscat_a[1][0] ] << std::endl;
// if (N == 1) {
// cfg.pack_nb_mr_ukr.call<T>(m, k, p_a_list2[0], rs_a, cscat_a2[0], cbs_a2[0], p_ap);
// } else if ( N == 2 ) {
// cfg.stra_pack_two_nb_mr_ukr.call<T>(m, k, N, p_a_list2, coeff_list, rs_a, cscat_a2, cbs_a2, p_ap);
// } else if ( N == 4 ) {
// cfg.stra_pack_four_nb_mr_ukr.call<T>(m, k, N, p_a_list2, coeff_list, rs_a, cscat_a2, cbs_a2, p_ap);
// } else {
// std::cout << "N is not 1,2,4" << std::endl;
// cfg.stra_pack_nb_mr_ukr.call<T>(m, k, N, p_a_list2, coeff_list, rs_a, cscat_a2, cbs_a2, p_ap);
// }
// }
//
//}
//if (m == 4) {
//std::cout << "A[0]:\n";
//for (int i = 0; i < k; i++)
//{
// for (int j = 0; j < m; j++)
// {
// std::cout << p_a_list[0][i*4+j] << " ";
// }
// std::cout << std::endl;
//}
//if ( N == 2 )
//{
// std::cout << "A[1]:\n";
// for (int i = 0; i < k; i++)
// {
// for (int j = 0; j < m; j++)
// {
// std::cout << p_a_list[1][i*4+j] << " ";
// }
// std::cout << std::endl;
// }
//}
////std::cout << "p_a[0]: " << p_a[0] << std::endl;
//std::cout << "A_packed:\n";
//for (int i = 0; i < k; i++)
//{
// for (int j = 0; j < m; j++)
// {
// std::cout << p_ap[i*4+j] << " ";
// }
// std::cout << std::endl;
//}
//}
/*
T nrm1 = T();
T nrm2 = T();
for (len_type i = 0;i < m;i++)
{
for (len_type j = 0;j < k;j++)
{
nrm1 += norm2(p_ap[i + j*ME]);
if (rs_a == 0)
nrm1 += norm2(p_a[rscat_a[i] + cscat_a[j]]);
else
nrm2 += norm2(p_a[i*rs_a + cscat_a[j]]);
}
}
printf("%d/%d in %d/%d: %s sub: %.15f %.15f\n",
comm.thread_num(), comm.num_threads(),
comm.gang_num(), comm.num_gangs(),
(Trans ? "B" : "A"), sqrt(nrm1), sqrt(nrm2));
*/
//p_ap += ME*k_a;
p_ap += cs_ap*k_a;
A.shift_block(0, 1);
off_m += MR;
}
A.shift(0, -off_m);
A.length(0, m_a);
/*
comm.barrier();
norm = T();
for (len_type i = 0;i < m_a;i++)
{
for (len_type j = 0;j < k_a;j++)
{
norm += norm2(Ap.data()[(i/MR)*ME*k_a + (i%MR) + j*ME]);
}
}
printf("%d/%d in %d/%d: %s after: %.15f\n",
comm.thread_num(), comm.num_threads(),
comm.gang_num(), comm.num_gangs(),
(Trans ? "B" : "A"), sqrt(norm));
comm.barrier();
*/
}
| 37.547826 | 136 | 0.413 | [
"vector"
] |
d5827bbedd9941d05ce85f79eef5584207ab6b40 | 1,759 | cpp | C++ | problems/kickstart/2017/E/trapezoid-counting/code.cpp | brunodccarvalho/competitive | 4177c439174fbe749293b9da3445ce7303bd23c2 | [
"MIT"
] | 7 | 2020-10-15T22:37:10.000Z | 2022-02-26T17:23:49.000Z | problems/kickstart/2017/E/trapezoid-counting/code.cpp | brunodccarvalho/competitive | 4177c439174fbe749293b9da3445ce7303bd23c2 | [
"MIT"
] | null | null | null | problems/kickstart/2017/E/trapezoid-counting/code.cpp | brunodccarvalho/competitive | 4177c439174fbe749293b9da3445ce7303bd23c2 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
// *****
auto solve() {
int N;
cin >> N;
vector<int> sticks(N);
vector<int> counts;
for (int i = 0; i < N; ++i) {
cin >> sticks[i];
}
sort(begin(sticks), end(sticks));
int write = 0, read = 0;
while (read < N) {
int end = read + 1;
while (end < N && sticks[read] == sticks[end]) {
++end;
}
counts.push_back(end - read);
sticks[write++] = sticks[read];
read = end;
}
sticks.resize(write);
N = write;
uint64_t sets = 0;
for (int s = 0; s < N; ++s) {
if (counts[s] < 2) {
continue;
}
uint64_t choose2 = (counts[s] * (counts[s] - 1)) / 2;
uint64_t choose3 = (choose2 * (counts[s] - 2)) / 3;
int i = 0; // shorter, inclusive
int j = 1; // longer, exclusive
int long_count = 0;
do {
while (j < N && sticks[j] - sticks[i] < 2 * sticks[s]) {
long_count += counts[j++];
}
bool is_short = i == s;
bool is_long = i < s && s < j;
if (is_short) {
sets += choose3 * long_count;
} else if (is_long) {
sets += choose2 * counts[i] * (long_count - counts[s]);
sets += choose3 * counts[i];
} else {
sets += choose2 * counts[i] * long_count;
}
long_count -= counts[++i];
} while (i + 1 < N);
}
return sets;
}
// *****
int main() {
unsigned T;
cin >> T >> ws;
for (unsigned t = 1; t <= T; ++t) {
auto solution = solve();
cout << "Case #" << t << ": " << solution << '\n';
}
return 0;
}
| 24.430556 | 71 | 0.423536 | [
"vector"
] |
d587f791e631ec35cef20922d14156be9df97c09 | 109,021 | cpp | C++ | engine/tests/kernel_tests/window_overlap_kernel_test.cpp | drabastomek/blazingsql | 68414712019f19c4e967466fbf4ce7d54fdd4068 | [
"Apache-2.0"
] | null | null | null | engine/tests/kernel_tests/window_overlap_kernel_test.cpp | drabastomek/blazingsql | 68414712019f19c4e967466fbf4ce7d54fdd4068 | [
"Apache-2.0"
] | null | null | null | engine/tests/kernel_tests/window_overlap_kernel_test.cpp | drabastomek/blazingsql | 68414712019f19c4e967466fbf4ce7d54fdd4068 | [
"Apache-2.0"
] | null | null | null | #include <spdlog/spdlog.h>
#include "tests/utilities/BlazingUnitTest.h"
#include "utilities/DebuggingUtils.h"
#include "utilities/CommonOperations.h"
#include <chrono>
#include <thread>
//#include <gtest/gtest.h>
#include "cudf_test/column_wrapper.hpp"
#include "cudf_test/type_lists.hpp" // cudf::test::NumericTypes
#include <cudf_test/table_utilities.hpp>
#include "execution_graph/Context.h"
#include "execution_graph/logic_controllers/taskflow/kernel.h"
#include "execution_graph/logic_controllers/taskflow/graph.h"
#include "execution_graph/logic_controllers/taskflow/port.h"
#include "execution_graph/logic_controllers/BatchWindowFunctionProcessing.h"
#include "execution_graph/logic_controllers/taskflow/executor.h"
using blazingdb::transport::Node;
using ral::cache::kstatus;
using ral::cache::CacheMachine;
using ral::cache::CacheData;
using ral::frame::BlazingTable;
using ral::cache::kernel;
using Context = blazingdb::manager::Context;
struct WindowOverlapAccumulatorTest : public ::testing::Test {
virtual void SetUp() override {
BlazingRMMInitialize();
float host_memory_quota=0.75; //default value
blazing_host_memory_resource::getInstance().initialize(host_memory_quota);
ral::memory::set_allocation_pools(4000000, 10,
4000000, 10, false, {});
int executor_threads = 10;
ral::execution::executor::init_executor(executor_threads, 0.8);
}
virtual void TearDown() override {
ral::memory::empty_pools();
BlazingRMMFinalize();
}
};
struct WindowOverlapGeneratorTest : public ::testing::Test {
virtual void SetUp() override {
BlazingRMMInitialize();
float host_memory_quota=0.75; //default value
blazing_host_memory_resource::getInstance().initialize(host_memory_quota);
ral::memory::set_allocation_pools(4000000, 10,
4000000, 10, false, {});
int executor_threads = 10;
ral::execution::executor::init_executor(executor_threads, 0.8);
}
virtual void TearDown() override {
ral::memory::empty_pools();
BlazingRMMFinalize();
}
};
struct WindowOverlapTest : public ::testing::Test {
virtual void SetUp() override {
BlazingRMMInitialize();
float host_memory_quota=0.75; //default value
blazing_host_memory_resource::getInstance().initialize(host_memory_quota);
ral::memory::set_allocation_pools(4000000, 10,
4000000, 10, false, {});
int executor_threads = 10;
ral::execution::executor::init_executor(executor_threads, 0.8);
}
virtual void TearDown() override {
ral::memory::empty_pools();
BlazingRMMFinalize();
}
};
// Just creates a Context
std::shared_ptr<Context> make_context(int num_nodes) {
std::vector<Node> nodes(num_nodes);
for (int i = 0; i < num_nodes; i++){
nodes[i] = Node(std::to_string(i));
}
Node master_node("0");
std::string logicalPlan;
std::map<std::string, std::string> config_options;
std::shared_ptr<Context> context = std::make_shared<Context>(0, nodes, master_node, logicalPlan, config_options);
return context;
}
// Creates a OverlapAccumulatorKernel using a valid `project_plan`
std::tuple<std::shared_ptr<kernel>, std::shared_ptr<ral::cache::CacheMachine>, std::shared_ptr<ral::cache::CacheMachine>>
make_overlap_Accumulator_kernel(std::string project_plan, std::shared_ptr<Context> context) {
std::size_t kernel_id = 1;
std::shared_ptr<ral::cache::graph> graph = std::make_shared<ral::cache::graph>();
std::shared_ptr<ral::cache::CacheMachine> input_cache = std::make_shared<CacheMachine>(nullptr, "messages_in", false);
std::shared_ptr<ral::cache::CacheMachine> output_cache = std::make_shared<CacheMachine>(nullptr, "messages_out", false, ral::cache::CACHE_LEVEL_CPU );
graph->set_input_and_output_caches(input_cache, output_cache);
std::shared_ptr<kernel> overlap_accumulator_kernel = std::make_shared<ral::batch::OverlapAccumulatorKernel>(kernel_id, project_plan, context, graph);
return std::make_tuple(overlap_accumulator_kernel, input_cache, output_cache);
}
// Creates a OverlapGeneratorKernel using a valid `project_plan`
std::tuple<std::shared_ptr<kernel>, std::shared_ptr<ral::cache::CacheMachine>, std::shared_ptr<ral::cache::CacheMachine>>
make_overlap_Generator_kernel(std::string project_plan, std::shared_ptr<Context> context) {
std::size_t kernel_id = 1;
std::shared_ptr<ral::cache::graph> graph = std::make_shared<ral::cache::graph>();
std::shared_ptr<ral::cache::CacheMachine> input_cache = std::make_shared<CacheMachine>(nullptr, "messages_in", false);
std::shared_ptr<ral::cache::CacheMachine> output_cache = std::make_shared<CacheMachine>(nullptr, "messages_out", false, ral::cache::CACHE_LEVEL_CPU );
graph->set_input_and_output_caches(input_cache, output_cache);
std::shared_ptr<kernel> overlap_generator_kernel = std::make_shared<ral::batch::OverlapGeneratorKernel>(kernel_id, project_plan, context, graph);
return std::make_tuple(overlap_generator_kernel, input_cache, output_cache);
}
// Creates two CacheMachines and register them with the `project_kernel`
std::tuple<std::shared_ptr<CacheMachine>, std::shared_ptr<CacheMachine>, std::shared_ptr<CacheMachine>, std::shared_ptr<CacheMachine>> register_kernel_overlap_accumulator_with_cache_machines(
std::shared_ptr<kernel> overlap_accumulator_kernel,
std::shared_ptr<Context> context) {
std::shared_ptr<CacheMachine> batchesCacheMachine = std::make_shared<CacheMachine>(context, "batches");
std::shared_ptr<CacheMachine> precedingCacheMachine = std::make_shared<CacheMachine>(context, "preceding_overlaps");
std::shared_ptr<CacheMachine> followingCacheMachine = std::make_shared<CacheMachine>(context, "following_overlaps");
std::shared_ptr<CacheMachine> outputCacheMachine = std::make_shared<CacheMachine>(context, "1");
overlap_accumulator_kernel->input_.register_cache("batches", batchesCacheMachine);
overlap_accumulator_kernel->input_.register_cache("preceding_overlaps", precedingCacheMachine);
overlap_accumulator_kernel->input_.register_cache("following_overlaps", followingCacheMachine);
overlap_accumulator_kernel->output_.register_cache("1", outputCacheMachine);
return std::make_tuple(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine);
}
// Creates two CacheMachines and register them with the `project_kernel`
std::tuple<std::shared_ptr<CacheMachine>, std::shared_ptr<CacheMachine>, std::shared_ptr<CacheMachine>, std::shared_ptr<CacheMachine>>
register_kernel_overlap_generator_with_cache_machines(
std::shared_ptr<kernel> overlap_generator_kernel,
std::shared_ptr<Context> context) {
std::shared_ptr<CacheMachine> batchesCacheMachine = std::make_shared<CacheMachine>(context, "batches");
std::shared_ptr<CacheMachine> precedingCacheMachine = std::make_shared<CacheMachine>(context, "preceding_overlaps");
std::shared_ptr<CacheMachine> followingCacheMachine = std::make_shared<CacheMachine>(context, "following_overlaps");
std::shared_ptr<CacheMachine> inputCacheMachine = std::make_shared<CacheMachine>(context, "1");
overlap_generator_kernel->input_.register_cache("1", inputCacheMachine);
overlap_generator_kernel->output_.register_cache("batches", batchesCacheMachine);
overlap_generator_kernel->output_.register_cache("preceding_overlaps", precedingCacheMachine);
overlap_generator_kernel->output_.register_cache("following_overlaps", followingCacheMachine);
return std::make_tuple(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, inputCacheMachine);
}
// Feeds an input cache with time delays
void add_data_to_cache_with_delay(
std::shared_ptr<CacheMachine> cache_machine,
std::vector<std::unique_ptr<BlazingTable>> batches,
std::vector<int> delays_in_ms)
{
int total_batches = batches.size();
int total_delays = delays_in_ms.size();
EXPECT_EQ(total_delays, total_batches);
for (int i = 0; i < total_batches; ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(delays_in_ms[i]));
cache_machine->addToCache(std::move(batches[i]));
}
// default last delay
std::this_thread::sleep_for(std::chrono::milliseconds(50));
cache_machine->finish();
}
// this function takes one big vector and breaks it up into batch_sizes to generate a vector of batches and its corresponding preceding_overlaps and following_overlaps in a way similar to how
// the kernel which feeds OverlapAccumulatorKernel would do
std::tuple<std::vector<std::unique_ptr<CacheData>>, std::vector<std::unique_ptr<CacheData>>, std::vector<std::unique_ptr<CacheData>>> break_up_full_data(
CudfTableView full_data_cudf_view, int preceding_value, int following_value, std::vector<cudf::size_type> batch_sizes, std::vector<std::string> names){
std::vector<cudf::size_type> split_indexes = batch_sizes;
std::partial_sum(split_indexes.begin(), split_indexes.end(), split_indexes.begin());
split_indexes.erase(split_indexes.begin() + split_indexes.size() - 1);
auto split_views = cudf::split(full_data_cudf_view, split_indexes);
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::vector<std::unique_ptr<BlazingTable>> batch_tables;
// make batches
for (std::size_t i = 0; i < split_views.size(); i++){
auto cudf_table = std::make_unique<CudfTable>(split_views[i]);
auto blz_table = std::make_unique<BlazingTable>(std::move(cudf_table), names);
// ral::utilities::print_blazing_table_view(blz_table->toBlazingTableView(), "batch" + std::to_string(i));
batch_tables.push_back(std::move(blz_table));
}
// make preceding overlaps
// preceding_overlaps[n] goes with batch[n+1]
for (std::size_t i = 0; i < split_views.size() - 1; i++){
std::unique_ptr<CudfTable> cudf_table;
if (preceding_value > batch_tables[i]->num_rows()){
cudf_table = std::make_unique<CudfTable>(batch_tables[i]->view());
} else {
cudf::size_type split_value = preceding_value < batch_tables[i]->num_rows() ? batch_tables[i]->num_rows() - preceding_value : 0;
std::vector<cudf::size_type> presceding_split_index = {split_value};
auto preceding_split_views = cudf::split(batch_tables[i]->view(), presceding_split_index);
cudf_table = std::make_unique<CudfTable>(preceding_split_views[1]);
}
auto blz_table = std::make_unique<BlazingTable>(std::move(cudf_table), names);
// ral::utilities::print_blazing_table_view(blz_table->toBlazingTableView(), "preceding" + std::to_string(i));
std::string overlap_status = preceding_value > batch_tables[i]->num_rows() ? ral::batch::INCOMPLETE_OVERLAP_STATUS : ral::batch::DONE_OVERLAP_STATUS;
ral::cache::MetadataDictionary metadata;
metadata.add_value(ral::cache::OVERLAP_STATUS, overlap_status);
preceding_overlaps.push_back(std::make_unique<ral::cache::GPUCacheData>(std::move(blz_table),metadata));
}
// make following overlaps
// following_overlaps[n] goes with batch[n] but there is no following_overlaps[batch.size()-1]
for (std::size_t i = 1; i < split_views.size(); i++){
std::unique_ptr<CudfTable> cudf_table;
if (following_value > batch_tables[i]->num_rows()){
cudf_table = std::make_unique<CudfTable>(batch_tables[i]->view());
} else {
std::vector<cudf::size_type> following_split_index = {following_value};
auto following_split_views = cudf::split(batch_tables[i]->view(), following_split_index);
cudf_table = std::make_unique<CudfTable>(following_split_views[0]);
}
auto blz_table = std::make_unique<BlazingTable>(std::move(cudf_table), names);
// ral::utilities::print_blazing_table_view(blz_table->toBlazingTableView(), "following" + std::to_string(i));
std::string overlap_status = following_value > batch_tables[i]->num_rows() ? ral::batch::INCOMPLETE_OVERLAP_STATUS : ral::batch::DONE_OVERLAP_STATUS;
ral::cache::MetadataDictionary metadata;
metadata.add_value(ral::cache::OVERLAP_STATUS, overlap_status);
following_overlaps.push_back(std::make_unique<ral::cache::GPUCacheData>(std::move(blz_table),metadata));
}
// package the batches as CacheDatas
for (std::size_t i = 0; i < split_views.size(); i++){
batches.push_back(std::make_unique<ral::cache::GPUCacheData>(std::move(batch_tables[i])));
}
return std::make_tuple(std::move(preceding_overlaps), std::move(batches), std::move(following_overlaps));
}
// this function takes one big vector and breaks it up into batch_sizes to generate a vector of batches and its corresponding preceding_overlaps and following_overlaps in a way similar to how
// the kernel which feeds OverlapAccumulatorKernel would do, similar to break_up_full_data. But it assumes a multi node setup, and therefore all the batches in batch_sizes are not assumed to belong
// to the self_node_index node. It assumes that one or both of the edge batches belong to other nodes. It uses this assumption to produce previous_node_overlap and next_node_overlap
std::tuple<std::vector<std::unique_ptr<CacheData>>, std::vector<std::unique_ptr<CacheData>>, std::vector<std::unique_ptr<CacheData>>,
std::unique_ptr<CacheData>, std::unique_ptr<CacheData>> break_up_full_data_multinode(
CudfTableView full_data_cudf_view, int preceding_value, int following_value, std::vector<cudf::size_type> batch_sizes, std::vector<std::string> names,
int total_nodes, int self_node_index){
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::tie(preceding_overlaps, batches, following_overlaps) = break_up_full_data(full_data_cudf_view, preceding_value, following_value, batch_sizes, names);
std::unique_ptr<CacheData> previous_node_overlap, next_node_overlap;
if (total_nodes == 1){
return std::make_tuple(std::move(preceding_overlaps),std::move(batches),std::move(following_overlaps),std::move(previous_node_overlap),std::move(next_node_overlap));
} else if (self_node_index == 0) {
batches.erase(batches.begin() + batches.size() - 1);
next_node_overlap = std::move(following_overlaps.back());
following_overlaps.erase(following_overlaps.begin() + following_overlaps.size() - 1);
preceding_overlaps.erase(preceding_overlaps.begin() + preceding_overlaps.size() - 1);
} else if (self_node_index == total_nodes - 1) {
batches.erase(batches.begin());
previous_node_overlap = std::move(preceding_overlaps[0]);
following_overlaps.erase(following_overlaps.begin());
preceding_overlaps.erase(preceding_overlaps.begin());
} else {
batches.erase(batches.begin() + batches.size() - 1);
next_node_overlap = std::move(following_overlaps.back());
following_overlaps.erase(following_overlaps.begin() + following_overlaps.size() - 1);
preceding_overlaps.erase(preceding_overlaps.begin() + preceding_overlaps.size() - 1);
batches.erase(batches.begin());
previous_node_overlap = std::move(preceding_overlaps[0]);
following_overlaps.erase(following_overlaps.begin());
preceding_overlaps.erase(preceding_overlaps.begin());
}
return std::make_tuple(std::move(preceding_overlaps),std::move(batches),std::move(following_overlaps),std::move(previous_node_overlap),std::move(next_node_overlap));
}
std::vector<std::unique_ptr<BlazingTable>> make_expected_accumulator_output(
CudfTableView full_data_cudf_view, int preceding_value, int following_value, std::vector<cudf::size_type> batch_sizes, std::vector<std::string> names){
std::vector<cudf::size_type> split_indexes = batch_sizes;
std::partial_sum(split_indexes.begin(), split_indexes.end(), split_indexes.begin());
split_indexes.erase(split_indexes.begin() + split_indexes.size() - 1);
std::vector<std::unique_ptr<BlazingTable>> out_batches;
for (std::size_t i = 0; i < batch_sizes.size(); i++){
if (i == 0){
cudf::size_type split_value = split_indexes[i] + following_value > full_data_cudf_view.num_rows() ? full_data_cudf_view.num_rows() : split_indexes[i] + following_value;
std::vector<cudf::size_type> out_split_index = {split_value};
auto out_split_views = cudf::split(full_data_cudf_view, out_split_index);
auto cudf_table = std::make_unique<CudfTable>(out_split_views[0]);
out_batches.push_back(std::make_unique<BlazingTable>(std::move(cudf_table), names));
} else if (i == batch_sizes.size() - 1){
cudf::size_type split_value = full_data_cudf_view.num_rows() - batch_sizes[batch_sizes.size() - 1] - preceding_value > 0 ? full_data_cudf_view.num_rows() - batch_sizes[batch_sizes.size() - 1] - preceding_value : 0;
std::vector<cudf::size_type> out_split_index = {split_value};
auto out_split_views = cudf::split(full_data_cudf_view, out_split_index);
auto cudf_table = std::make_unique<CudfTable>(out_split_views[1]);
out_batches.push_back(std::make_unique<BlazingTable>(std::move(cudf_table), names));
} else {
cudf::size_type split_value1 = split_indexes[i - 1] - preceding_value > 0 ? split_indexes[i - 1] - preceding_value : 0;
cudf::size_type split_value2 = split_indexes[i] + following_value > full_data_cudf_view.num_rows() ? full_data_cudf_view.num_rows() : split_indexes[i] + following_value;
std::vector<cudf::size_type> out_split_index = {split_value1, split_value2};
auto out_split_views = cudf::split(full_data_cudf_view, out_split_index);
auto cudf_table = std::make_unique<CudfTable>(out_split_views[1]);
out_batches.push_back(std::make_unique<BlazingTable>(std::move(cudf_table), names));
}
}
return std::move(out_batches);
}
std::vector<std::unique_ptr<BlazingTable>> make_expected_generator_output(
CudfTableView full_data_cudf_view, std::vector<cudf::size_type> batch_sizes, std::vector<std::string> names){
std::vector<cudf::size_type> split_indexes = batch_sizes;
std::partial_sum(split_indexes.begin(), split_indexes.end(), split_indexes.begin());
split_indexes.erase(split_indexes.begin() + split_indexes.size() - 1);
auto split_views = cudf::split(full_data_cudf_view, split_indexes);
std::vector<std::unique_ptr<BlazingTable>> batch_tables;
for (std::size_t i = 0; i < split_views.size(); i++){
auto cudf_table = std::make_unique<CudfTable>(split_views[i]);
auto blz_table = std::make_unique<BlazingTable>(std::move(cudf_table), names);
batch_tables.push_back(std::move(blz_table));
}
return batch_tables;
}
TEST_F(WindowOverlapAccumulatorTest, BasicSingleNode) {
size_t size = 100000;
// size_t size = 55;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
int preceding_value = 50;
int following_value = 10;
std::vector<cudf::size_type> batch_sizes = {5000, 50000, 20000, 15000, 10000}; // need to sum up to size
// int preceding_value = 5;
// int following_value = 1;
// std::vector<cudf::size_type> batch_sizes = {20, 10, 25}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::tie(preceding_overlaps, batches, following_overlaps) = break_up_full_data(full_data_cudf_view, preceding_value, following_value, batch_sizes, names);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(1);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize("0", "/tmp");
// overlap kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_cache, output_cache;
std::tie(overlap_accumulator_kernel, input_cache, output_cache) = make_overlap_Accumulator_kernel(
"LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 50 PRECEDING AND 10 FOLLOWING)])", context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine;
std::tie(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel, context);
// run function
std::thread run_thread = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the CacheMachines
for (std::size_t i = 0; i < batches.size(); i++) {
batchesCacheMachine->addCacheData(std::move(batches[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachine->addCacheData(std::move(preceding_overlaps[i - 1]));
}
if (i != batches.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachine->addCacheData(std::move(following_overlaps[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
run_thread.join();
// get and validate output
auto batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
auto table_out = batches_pulled[i]->decache();
// ral::utilities::print_blazing_table_view(expected_out[i]->toBlazingTableView(), "expected" + std::to_string(i));
// ral::utilities::print_blazing_table_view(table_out->toBlazingTableView(), "got" + std::to_string(i));
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
}
TEST_F(WindowOverlapAccumulatorTest, BasicMultiNode_FirstNode) {
int self_node_index = 0;
int total_nodes = 5;
size_t size = 100000;
// size_t size = 55;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 50;
int following_value = 10;
std::vector<cudf::size_type> batch_sizes = {5000, 50000, 20000, 15000, 10000}; // need to sum up to size
// int preceding_value = 5;
// int following_value = 1;
// std::vector<cudf::size_type> batch_sizes = {20, 10, 25}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
// std::vector<std::string> names({"A"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::unique_ptr<CacheData> previous_node_overlap, next_node_overlap;
std::tie(preceding_overlaps, batches, following_overlaps, previous_node_overlap, next_node_overlap) = break_up_full_data_multinode(
full_data_cudf_view, preceding_value, following_value, batch_sizes, names, total_nodes, self_node_index);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
std::unique_ptr<BlazingTable> expected_request_response_table = ral::utilities::getLimitedRows(expected_out.back()->toBlazingTableView(), preceding_value, true);
expected_out.erase(expected_out.begin() + expected_out.size()-1);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(total_nodes);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize(std::to_string(self_node_index), "/tmp");
// overlap kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_message_cache, output_message_cache;
std::tie(overlap_accumulator_kernel, input_message_cache, output_message_cache) = make_overlap_Accumulator_kernel(
"LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 50 PRECEDING AND 10 FOLLOWING)])", context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine;
std::tie(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel, context);
// run function
std::thread run_thread = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the CacheMachines
for (std::size_t i = 0; i < batches.size(); i++) {
batchesCacheMachine->addCacheData(std::move(batches[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachine->addCacheData(std::move(preceding_overlaps[i - 1]));
}
if (i != batches.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachine->addCacheData(std::move(following_overlaps[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
// create overlap request and response from neighbor node
std::string sender_node_id = std::to_string(self_node_index + 1);
std::string message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + sender_node_id;
// create overlap request
auto empty_table =ral::utilities::create_empty_table(expected_out[0]->toBlazingTableView());
ral::cache::MetadataDictionary request_metadata;
request_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::PRECEDING_REQUEST);
request_metadata.add_value(ral::cache::OVERLAP_SIZE, std::to_string(preceding_value));
request_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, sender_node_id);
request_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, std::to_string(0));
request_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, std::to_string(self_node_index));
input_message_cache->addToCache(std::move(empty_table), ral::batch::PRECEDING_REQUEST + message_id, true, request_metadata, true);
// create overlap response
ral::cache::MetadataDictionary metadata;
metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::FOLLOWING_RESPONSE);
metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, sender_node_id);
metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, self_node_index);
metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, batches.size() - 1);
metadata.add_value(ral::cache::OVERLAP_STATUS, ral::batch::DONE_OVERLAP_STATUS);
next_node_overlap->setMetadata(metadata);
input_message_cache->addCacheData(std::move(next_node_overlap), ral::batch::FOLLOWING_RESPONSE + message_id, true);
run_thread.join();
// get and validate output
auto batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
auto table_out = batches_pulled[i]->decache();
// ral::utilities::print_blazing_table_view(expected_out[i]->toBlazingTableView(), "expected" + std::to_string(i));
// ral::utilities::print_blazing_table_view(table_out->toBlazingTableView(), "got" + std::to_string(i));
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
// get and validate request response
std::unique_ptr<CacheData> following_request = output_message_cache->pullCacheData();
std::unique_ptr<CacheData> request_response = output_message_cache->pullCacheData();
ral::cache::MetadataDictionary request_response_metadata = request_response->getMetadata();
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE), ral::batch::PRECEDING_RESPONSE);
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX), std::to_string(self_node_index));
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_NODE_INDEX), sender_node_id);
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX), std::to_string(0));
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
std::unique_ptr<BlazingTable> request_response_table = request_response->decache();
cudf::test::expect_tables_equivalent(expected_request_response_table->view(), request_response_table->view());
}
TEST_F(WindowOverlapAccumulatorTest, BasicMultiNode_LastNode) {
int self_node_index = 4;
int total_nodes = 5;
size_t size = 100000;
// size_t size = 55;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 50;
int following_value = 10;
std::vector<cudf::size_type> batch_sizes = {5000, 50000, 20000, 15000, 10000}; // need to sum up to size
// int preceding_value = 5;
// int following_value = 1;
// std::vector<cudf::size_type> batch_sizes = {20, 10, 25}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
// std::vector<std::string> names({"A"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::unique_ptr<CacheData> previous_node_overlap, next_node_overlap;
std::tie(preceding_overlaps, batches, following_overlaps, previous_node_overlap, next_node_overlap) = break_up_full_data_multinode(
full_data_cudf_view, preceding_value, following_value, batch_sizes, names, total_nodes, self_node_index);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
std::unique_ptr<BlazingTable> expected_request_response_table = ral::utilities::getLimitedRows(expected_out[0]->toBlazingTableView(), following_value, false);
expected_out.erase(expected_out.begin());
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(total_nodes);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize(std::to_string(self_node_index), "/tmp");
// overlap kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_message_cache, output_message_cache;
std::tie(overlap_accumulator_kernel, input_message_cache, output_message_cache) = make_overlap_Accumulator_kernel(
"LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 50 PRECEDING AND 10 FOLLOWING)])", context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine;
std::tie(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel, context);
// run function
std::thread run_thread = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the CacheMachines
for (std::size_t i = 0; i < batches.size(); i++) {
batchesCacheMachine->addCacheData(std::move(batches[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachine->addCacheData(std::move(preceding_overlaps[i - 1]));
}
if (i != batches.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachine->addCacheData(std::move(following_overlaps[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
// create overlap request and response from neighbor node
std::string sender_node_id = std::to_string(self_node_index - 1);
std::string message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + sender_node_id;
// create overlap request
auto empty_table =ral::utilities::create_empty_table(expected_out[0]->toBlazingTableView());
ral::cache::MetadataDictionary request_metadata;
request_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::FOLLOWING_REQUEST);
request_metadata.add_value(ral::cache::OVERLAP_SIZE, std::to_string(following_value));
request_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, sender_node_id);
request_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, std::to_string(batches.size() - 1));
request_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, std::to_string(self_node_index));
input_message_cache->addToCache(std::move(empty_table), ral::batch::FOLLOWING_REQUEST + message_id, true, request_metadata, true);
// create overlap response
ral::cache::MetadataDictionary metadata;
metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::PRECEDING_RESPONSE);
metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, sender_node_id);
metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, self_node_index);
metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, 0);
metadata.add_value(ral::cache::OVERLAP_STATUS, ral::batch::DONE_OVERLAP_STATUS);
previous_node_overlap->setMetadata(metadata);
input_message_cache->addCacheData(std::move(previous_node_overlap), ral::batch::PRECEDING_RESPONSE + message_id, true);
run_thread.join();
// get and validate output
auto batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
auto table_out = batches_pulled[i]->decache();
// ral::utilities::print_blazing_table_view(expected_out[i]->toBlazingTableView(), "expected" + std::to_string(i));
// ral::utilities::print_blazing_table_view(table_out->toBlazingTableView(), "got" + std::to_string(i));
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
// get and validate request response
std::unique_ptr<CacheData> following_request = output_message_cache->pullCacheData();
std::unique_ptr<CacheData> request_response = output_message_cache->pullCacheData();
ral::cache::MetadataDictionary request_response_metadata = request_response->getMetadata();
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE), ral::batch::FOLLOWING_RESPONSE);
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX), std::to_string(self_node_index));
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_NODE_INDEX), sender_node_id);
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX), std::to_string(batches.size() - 1));
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
std::unique_ptr<BlazingTable> request_response_table = request_response->decache();
cudf::test::expect_tables_equivalent(expected_request_response_table->view(), request_response_table->view());
}
TEST_F(WindowOverlapAccumulatorTest, BasicMultiNode_MiddleNode) {
int self_node_index = 2;
int total_nodes = 5;
size_t size = 100000;
// size_t size = 55;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 50;
int following_value = 10;
std::vector<cudf::size_type> batch_sizes = {5000, 50000, 20000, 15000, 10000}; // need to sum up to size
// int preceding_value = 5;
// int following_value = 1;
// std::vector<cudf::size_type> batch_sizes = {20, 10, 25}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
// std::vector<std::string> names({"A"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::unique_ptr<CacheData> previous_node_overlap, next_node_overlap;
std::tie(preceding_overlaps, batches, following_overlaps, previous_node_overlap, next_node_overlap) = break_up_full_data_multinode(
full_data_cudf_view, preceding_value, following_value, batch_sizes, names, total_nodes, self_node_index);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
std::unique_ptr<BlazingTable> expected_following_request_response_table = ral::utilities::getLimitedRows(expected_out[0]->toBlazingTableView(), following_value, false);
std::unique_ptr<BlazingTable> expected_preceding_request_response_table = ral::utilities::getLimitedRows(expected_out.back()->toBlazingTableView(), preceding_value, true);
expected_out.erase(expected_out.begin());
expected_out.erase(expected_out.begin() + expected_out.size()-1);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(total_nodes);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize(std::to_string(self_node_index), "/tmp");
// overlap kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_message_cache, output_message_cache;
std::tie(overlap_accumulator_kernel, input_message_cache, output_message_cache) = make_overlap_Accumulator_kernel(
"LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 50 PRECEDING AND 10 FOLLOWING)])", context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine;
std::tie(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel, context);
// run function
std::thread run_thread = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the CacheMachines
for (std::size_t i = 0; i < batches.size(); i++) {
batchesCacheMachine->addCacheData(std::move(batches[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachine->addCacheData(std::move(preceding_overlaps[i - 1]));
}
if (i != batches.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachine->addCacheData(std::move(following_overlaps[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
// create overlap request and response from neighbor node
std::string previous_node_id = std::to_string(self_node_index - 1);
std::string next_node_id = std::to_string(self_node_index + 1);
std::string previous_node_message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + previous_node_id;
std::string next_node_message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + next_node_id;
// create overlap request
ral::cache::MetadataDictionary following_request_metadata;
following_request_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::FOLLOWING_REQUEST);
following_request_metadata.add_value(ral::cache::OVERLAP_SIZE, std::to_string(following_value));
following_request_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, next_node_id);
following_request_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, std::to_string(batches.size() - 1));
following_request_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, std::to_string(self_node_index));
auto empty_table =ral::utilities::create_empty_table(expected_out[0]->toBlazingTableView());
input_message_cache->addToCache(std::move(empty_table), ral::batch::FOLLOWING_REQUEST + previous_node_message_id, true, following_request_metadata, true);
ral::cache::MetadataDictionary preceding_request_metadata;
preceding_request_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::PRECEDING_REQUEST);
preceding_request_metadata.add_value(ral::cache::OVERLAP_SIZE, std::to_string(preceding_value));
preceding_request_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, previous_node_id);
preceding_request_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, std::to_string(0));
preceding_request_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, std::to_string(self_node_index));
empty_table =ral::utilities::create_empty_table(expected_out[0]->toBlazingTableView());
input_message_cache->addToCache(std::move(empty_table), ral::batch::PRECEDING_REQUEST + next_node_message_id, true, preceding_request_metadata, true);
// create overlap response
ral::cache::MetadataDictionary preceding_response_metadata;
preceding_response_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::PRECEDING_RESPONSE);
preceding_response_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, next_node_id);
preceding_response_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, self_node_index);
preceding_response_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, 0);
preceding_response_metadata.add_value(ral::cache::OVERLAP_STATUS, ral::batch::DONE_OVERLAP_STATUS);
previous_node_overlap->setMetadata(preceding_response_metadata);
input_message_cache->addCacheData(std::move(previous_node_overlap), ral::batch::PRECEDING_RESPONSE + previous_node_message_id, true);
// create overlap response
ral::cache::MetadataDictionary following_response_metadata;
following_response_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::FOLLOWING_RESPONSE);
following_response_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, previous_node_id);
following_response_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, self_node_index);
following_response_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, batches.size() - 1);
following_response_metadata.add_value(ral::cache::OVERLAP_STATUS, ral::batch::DONE_OVERLAP_STATUS);
next_node_overlap->setMetadata(following_response_metadata);
input_message_cache->addCacheData(std::move(next_node_overlap), ral::batch::FOLLOWING_RESPONSE + next_node_message_id, true);
run_thread.join();
// get and validate output
auto batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
auto table_out = batches_pulled[i]->decache();
// ral::utilities::print_blazing_table_view(expected_out[i]->toBlazingTableView(), "expected" + std::to_string(i));
// ral::utilities::print_blazing_table_view(table_out->toBlazingTableView(), "got" + std::to_string(i));
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
// get and validate request response
std::unique_ptr<CacheData> preceding_request_response, following_request_response;
ral::cache::MetadataDictionary preceding_request_response_metadata, following_request_response_metadata;
for (std::size_t i = 0; i < 4; i++){
std::unique_ptr<CacheData> request = output_message_cache->pullCacheData();
ral::cache::MetadataDictionary metadata = request->getMetadata();
if (metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE) == ral::batch::PRECEDING_RESPONSE){
preceding_request_response = std::move(request);
preceding_request_response_metadata = metadata;
} else if (metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE) == ral::batch::FOLLOWING_RESPONSE){
following_request_response = std::move(request);
following_request_response_metadata = metadata;
}
}
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE), ral::batch::PRECEDING_RESPONSE);
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX), std::to_string(self_node_index));
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_NODE_INDEX), previous_node_id);
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX), std::to_string(0));
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
std::unique_ptr<BlazingTable> preceding_request_response_table = preceding_request_response->decache();
cudf::test::expect_tables_equivalent(expected_preceding_request_response_table->view(), preceding_request_response_table->view());
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE), ral::batch::FOLLOWING_RESPONSE);
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX), std::to_string(self_node_index));
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_NODE_INDEX), next_node_id);
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX), std::to_string(batches.size() - 1));
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
std::unique_ptr<BlazingTable> following_request_response_table = following_request_response->decache();
cudf::test::expect_tables_equivalent(expected_following_request_response_table->view(), following_request_response_table->view());
}
TEST_F(WindowOverlapAccumulatorTest, BigWindowMultiNode_FirstNode) {
int self_node_index = 0;
int total_nodes = 5;
size_t size = 14600;
// size_t size = 146;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 1500;
int following_value = 3000;
std::vector<cudf::size_type> batch_sizes = {1000, 1100, 1200, 1300, 10000}; // need to sum up to size
// int preceding_value = 15;
// int following_value = 30;
// std::vector<cudf::size_type> batch_sizes = {10, 11, 12, 13, 100}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
// std::vector<std::string> names({"A"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::unique_ptr<CacheData> previous_node_overlap, next_node_overlap;
std::tie(preceding_overlaps, batches, following_overlaps, previous_node_overlap, next_node_overlap) = break_up_full_data_multinode(
full_data_cudf_view, preceding_value, following_value, batch_sizes, names, total_nodes, self_node_index);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
std::unique_ptr<BlazingTable> expected_request_response_table = ral::utilities::getLimitedRows(expected_out.back()->toBlazingTableView(), preceding_value, true);
expected_out.erase(expected_out.begin() + expected_out.size()-1);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(total_nodes);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize(std::to_string(self_node_index), "/tmp");
// overlap kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_message_cache, output_message_cache;
std::tie(overlap_accumulator_kernel, input_message_cache, output_message_cache) = make_overlap_Accumulator_kernel(
"LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN " + std::to_string(preceding_value) +
" PRECEDING AND " + std::to_string(following_value) + " FOLLOWING)])", context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine;
std::tie(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel, context);
// run function
std::thread run_thread = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the CacheMachines
for (std::size_t i = 0; i < batches.size(); i++) {
batchesCacheMachine->addCacheData(std::move(batches[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachine->addCacheData(std::move(preceding_overlaps[i - 1]));
}
if (i != batches.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachine->addCacheData(std::move(following_overlaps[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
// create overlap request and response from neighbor node
std::string sender_node_id = std::to_string(self_node_index + 1);
std::string message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + sender_node_id;
// create overlap request
auto empty_table =ral::utilities::create_empty_table(expected_out[0]->toBlazingTableView());
ral::cache::MetadataDictionary request_metadata;
request_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::PRECEDING_REQUEST);
request_metadata.add_value(ral::cache::OVERLAP_SIZE, std::to_string(preceding_value));
request_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, sender_node_id);
request_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, std::to_string(0));
request_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, std::to_string(self_node_index));
input_message_cache->addToCache(std::move(empty_table), ral::batch::PRECEDING_REQUEST + message_id, true, request_metadata, true);
// create overlap response
ral::cache::MetadataDictionary metadata;
metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::FOLLOWING_RESPONSE);
metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, sender_node_id);
metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, self_node_index);
metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, batches.size() - 1);
metadata.add_value(ral::cache::OVERLAP_STATUS, ral::batch::DONE_OVERLAP_STATUS);
next_node_overlap->setMetadata(metadata);
input_message_cache->addCacheData(std::move(next_node_overlap), ral::batch::FOLLOWING_RESPONSE + message_id, true);
run_thread.join();
// get and validate output
auto batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
auto table_out = batches_pulled[i]->decache();
// ral::utilities::print_blazing_table_view(expected_out[i]->toBlazingTableView(), "expected" + std::to_string(i));
// ral::utilities::print_blazing_table_view(table_out->toBlazingTableView(), "got" + std::to_string(i));
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
// get and validate request response
std::unique_ptr<CacheData> following_request = output_message_cache->pullCacheData();
std::unique_ptr<CacheData> request_response = output_message_cache->pullCacheData();
ral::cache::MetadataDictionary request_response_metadata = request_response->getMetadata();
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE), ral::batch::PRECEDING_RESPONSE);
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX), std::to_string(self_node_index));
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_NODE_INDEX), sender_node_id);
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX), std::to_string(0));
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
std::unique_ptr<BlazingTable> request_response_table = request_response->decache();
cudf::test::expect_tables_equivalent(expected_request_response_table->view(), request_response_table->view());
}
TEST_F(WindowOverlapAccumulatorTest, BigWindowMultiNode_LastNode) {
int self_node_index = 4;
int total_nodes = 5;
size_t size = 14600;
// size_t size = 146;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 1500;
int following_value = 3000;
std::vector<cudf::size_type> batch_sizes = {10000, 1100, 1200, 1300, 1000}; // need to sum up to size
// int preceding_value = 15;
// int following_value = 30;
// std::vector<cudf::size_type> batch_sizes = {10, 11, 12, 13, 100}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
// std::vector<std::string> names({"A"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::unique_ptr<CacheData> previous_node_overlap, next_node_overlap;
std::tie(preceding_overlaps, batches, following_overlaps, previous_node_overlap, next_node_overlap) = break_up_full_data_multinode(
full_data_cudf_view, preceding_value, following_value, batch_sizes, names, total_nodes, self_node_index);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
std::unique_ptr<BlazingTable> expected_request_response_table = ral::utilities::getLimitedRows(expected_out[0]->toBlazingTableView(), following_value, false);
expected_out.erase(expected_out.begin());
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(total_nodes);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize(std::to_string(self_node_index), "/tmp");
// overlap kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_message_cache, output_message_cache;
std::tie(overlap_accumulator_kernel, input_message_cache, output_message_cache) = make_overlap_Accumulator_kernel(
"LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN " + std::to_string(preceding_value) +
" PRECEDING AND " + std::to_string(following_value) + " FOLLOWING)])", context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine;
std::tie(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel, context);
// run function
std::thread run_thread = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the CacheMachines
for (std::size_t i = 0; i < batches.size(); i++) {
batchesCacheMachine->addCacheData(std::move(batches[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachine->addCacheData(std::move(preceding_overlaps[i - 1]));
}
if (i != batches.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachine->addCacheData(std::move(following_overlaps[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
// create overlap request and response from neighbor node
std::string sender_node_id = std::to_string(self_node_index - 1);
std::string message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + sender_node_id;
// create overlap request
auto empty_table =ral::utilities::create_empty_table(expected_out[0]->toBlazingTableView());
ral::cache::MetadataDictionary request_metadata;
request_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::FOLLOWING_REQUEST);
request_metadata.add_value(ral::cache::OVERLAP_SIZE, std::to_string(following_value));
request_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, sender_node_id);
request_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, std::to_string(batches.size() - 1));
request_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, std::to_string(self_node_index));
input_message_cache->addToCache(std::move(empty_table), ral::batch::FOLLOWING_REQUEST + message_id, true, request_metadata, true);
// create overlap response
ral::cache::MetadataDictionary metadata;
metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::PRECEDING_RESPONSE);
metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, sender_node_id);
metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, self_node_index);
metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, 0);
metadata.add_value(ral::cache::OVERLAP_STATUS, ral::batch::DONE_OVERLAP_STATUS);
previous_node_overlap->setMetadata(metadata);
input_message_cache->addCacheData(std::move(previous_node_overlap), ral::batch::PRECEDING_RESPONSE + message_id, true);
run_thread.join();
// get and validate output
auto batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
auto table_out = batches_pulled[i]->decache();
// ral::utilities::print_blazing_table_view(expected_out[i]->toBlazingTableView(), "expected" + std::to_string(i));
// ral::utilities::print_blazing_table_view(table_out->toBlazingTableView(), "got" + std::to_string(i));
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
// get and validate request response
std::unique_ptr<CacheData> request_response = output_message_cache->pullCacheData();
ral::cache::MetadataDictionary request_response_metadata = request_response->getMetadata();
if (request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE) != ral::batch::FOLLOWING_RESPONSE){
request_response = output_message_cache->pullCacheData();
request_response_metadata = request_response->getMetadata();
}
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE), ral::batch::FOLLOWING_RESPONSE);
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX), std::to_string(self_node_index));
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_NODE_INDEX), sender_node_id);
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX), std::to_string(batches.size() - 1));
EXPECT_EQ(request_response_metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
std::unique_ptr<BlazingTable> request_response_table = request_response->decache();
cudf::test::expect_tables_equivalent(expected_request_response_table->view(), request_response_table->view());
}
TEST_F(WindowOverlapAccumulatorTest, BigWindowMultiNode_MiddleNode) {
int self_node_index = 2;
int total_nodes = 5;
size_t size = 14600;
// size_t size = 55;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 1500;
int following_value = 3000;
std::vector<cudf::size_type> batch_sizes = {5500, 1100, 1200, 1300, 5500}; // need to sum up to size
// int preceding_value = 5;
// int following_value = 1;
// std::vector<cudf::size_type> batch_sizes = {20, 10, 25}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
// std::vector<std::string> names({"A"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::unique_ptr<CacheData> previous_node_overlap, next_node_overlap;
std::tie(preceding_overlaps, batches, following_overlaps, previous_node_overlap, next_node_overlap) = break_up_full_data_multinode(
full_data_cudf_view, preceding_value, following_value, batch_sizes, names, total_nodes, self_node_index);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
std::unique_ptr<BlazingTable> expected_following_request_response_table = ral::utilities::getLimitedRows(expected_out[0]->toBlazingTableView(), following_value, false);
std::unique_ptr<BlazingTable> expected_preceding_request_response_table = ral::utilities::getLimitedRows(expected_out.back()->toBlazingTableView(), preceding_value, true);
expected_out.erase(expected_out.begin());
expected_out.erase(expected_out.begin() + expected_out.size()-1);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(total_nodes);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize(std::to_string(self_node_index), "/tmp");
// overlap kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_message_cache, output_message_cache;
std::tie(overlap_accumulator_kernel, input_message_cache, output_message_cache) = make_overlap_Accumulator_kernel(
"LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN " + std::to_string(preceding_value) +
" PRECEDING AND " + std::to_string(following_value) + " FOLLOWING)])", context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine;
std::tie(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel, context);
// run function
std::thread run_thread = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the CacheMachines
for (std::size_t i = 0; i < batches.size(); i++) {
batchesCacheMachine->addCacheData(std::move(batches[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachine->addCacheData(std::move(preceding_overlaps[i - 1]));
}
if (i != batches.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachine->addCacheData(std::move(following_overlaps[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
// create overlap request and response from neighbor node
std::string previous_node_id = std::to_string(self_node_index - 1);
std::string next_node_id = std::to_string(self_node_index + 1);
std::string previous_node_message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + previous_node_id;
std::string next_node_message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + next_node_id;
// create overlap request
ral::cache::MetadataDictionary following_request_metadata;
following_request_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::FOLLOWING_REQUEST);
following_request_metadata.add_value(ral::cache::OVERLAP_SIZE, std::to_string(following_value));
following_request_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, next_node_id);
following_request_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, std::to_string(batches.size() - 1));
following_request_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, std::to_string(self_node_index));
auto empty_table =ral::utilities::create_empty_table(expected_out[0]->toBlazingTableView());
input_message_cache->addToCache(std::move(empty_table), ral::batch::FOLLOWING_REQUEST + previous_node_message_id, true, following_request_metadata, true);
ral::cache::MetadataDictionary preceding_request_metadata;
preceding_request_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::PRECEDING_REQUEST);
preceding_request_metadata.add_value(ral::cache::OVERLAP_SIZE, std::to_string(preceding_value));
preceding_request_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, previous_node_id);
preceding_request_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, std::to_string(0));
preceding_request_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, std::to_string(self_node_index));
empty_table =ral::utilities::create_empty_table(expected_out[0]->toBlazingTableView());
input_message_cache->addToCache(std::move(empty_table), ral::batch::PRECEDING_REQUEST + next_node_message_id, true, preceding_request_metadata, true);
// create overlap response
ral::cache::MetadataDictionary preceding_response_metadata;
preceding_response_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::PRECEDING_RESPONSE);
preceding_response_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, next_node_id);
preceding_response_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, self_node_index);
preceding_response_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, 0);
preceding_response_metadata.add_value(ral::cache::OVERLAP_STATUS, ral::batch::DONE_OVERLAP_STATUS);
previous_node_overlap->setMetadata(preceding_response_metadata);
input_message_cache->addCacheData(std::move(previous_node_overlap), ral::batch::PRECEDING_RESPONSE + previous_node_message_id, true);
// create overlap response
ral::cache::MetadataDictionary following_response_metadata;
following_response_metadata.add_value(ral::cache::OVERLAP_MESSAGE_TYPE, ral::batch::FOLLOWING_RESPONSE);
following_response_metadata.add_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX, previous_node_id);
following_response_metadata.add_value(ral::cache::OVERLAP_TARGET_NODE_INDEX, self_node_index);
following_response_metadata.add_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX, batches.size() - 1);
following_response_metadata.add_value(ral::cache::OVERLAP_STATUS, ral::batch::DONE_OVERLAP_STATUS);
next_node_overlap->setMetadata(following_response_metadata);
input_message_cache->addCacheData(std::move(next_node_overlap), ral::batch::FOLLOWING_RESPONSE + next_node_message_id, true);
run_thread.join();
// get and validate output
auto batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
auto table_out = batches_pulled[i]->decache();
// ral::utilities::print_blazing_table_view(expected_out[i]->toBlazingTableView(), "expected" + std::to_string(i));
// ral::utilities::print_blazing_table_view(table_out->toBlazingTableView(), "got" + std::to_string(i));
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
std::string self_node_message_id = std::to_string(context->getContextToken()) + "_" + std::to_string(overlap_accumulator_kernel->get_id()) + "_" + std::to_string(self_node_index);
// get and validate request response
std::unique_ptr<CacheData> preceding_request_response, following_request_response;
ral::cache::MetadataDictionary preceding_request_response_metadata, following_request_response_metadata;
for (std::size_t i = 0; i < 4; i++){
std::unique_ptr<CacheData> request = output_message_cache->pullCacheData();
ral::cache::MetadataDictionary metadata = request->getMetadata();
if (metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE) == ral::batch::PRECEDING_RESPONSE){
preceding_request_response = std::move(request);
preceding_request_response_metadata = metadata;
} else if (metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE) == ral::batch::FOLLOWING_RESPONSE){
following_request_response = std::move(request);
following_request_response_metadata = metadata;
}
}
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE), ral::batch::PRECEDING_RESPONSE);
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX), std::to_string(self_node_index));
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_NODE_INDEX), previous_node_id);
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX), std::to_string(0));
EXPECT_EQ(preceding_request_response_metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
std::unique_ptr<BlazingTable> preceding_request_response_table = preceding_request_response->decache();
cudf::test::expect_tables_equivalent(expected_preceding_request_response_table->view(), preceding_request_response_table->view());
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_MESSAGE_TYPE), ral::batch::FOLLOWING_RESPONSE);
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_SOURCE_NODE_INDEX), std::to_string(self_node_index));
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_NODE_INDEX), next_node_id);
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_TARGET_BATCH_INDEX), std::to_string(batches.size() - 1));
EXPECT_EQ(following_request_response_metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
std::unique_ptr<BlazingTable> following_request_response_table = following_request_response->decache();
cudf::test::expect_tables_equivalent(expected_following_request_response_table->view(), following_request_response_table->view());
}
TEST_F(WindowOverlapAccumulatorTest, BigWindowSingleNode) {
int self_node_index = 0;
int total_nodes = 1;
size_t size = 14600;
// size_t size = 55;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 1500;
int following_value = 3000;
std::vector<cudf::size_type> batch_sizes = {5500, 1100, 1200, 1300, 5500}; // need to sum up to size
// int preceding_value = 5;
// int following_value = 1;
// std::vector<cudf::size_type> batch_sizes = {20, 10, 25}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
// std::vector<std::string> names({"A"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::tie(preceding_overlaps, batches, following_overlaps) = break_up_full_data(
full_data_cudf_view, preceding_value, following_value, batch_sizes, names);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(total_nodes);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize(std::to_string(self_node_index), "/tmp");
// overlap kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_message_cache, output_message_cache;
std::tie(overlap_accumulator_kernel, input_message_cache, output_message_cache) = make_overlap_Accumulator_kernel(
"LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN " + std::to_string(preceding_value) +
" PRECEDING AND " + std::to_string(following_value) + " FOLLOWING)])", context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine;
std::tie(batchesCacheMachine, precedingCacheMachine, followingCacheMachine, outputCacheMachine) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel, context);
// run function
std::thread run_thread = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the CacheMachines
for (std::size_t i = 0; i < batches.size(); i++) {
batchesCacheMachine->addCacheData(std::move(batches[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachine->addCacheData(std::move(preceding_overlaps[i - 1]));
}
if (i != batches.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachine->addCacheData(std::move(following_overlaps[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
run_thread.join();
// get and validate output
auto batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
auto table_out = batches_pulled[i]->decache();
// ral::utilities::print_blazing_table_view(expected_out[i]->toBlazingTableView(), "expected" + std::to_string(i));
// ral::utilities::print_blazing_table_view(table_out->toBlazingTableView(), "got" + std::to_string(i));
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
}
std::tuple<std::vector<std::unique_ptr<CacheData>>, std::vector<std::unique_ptr<CacheData>>, std::vector<std::unique_ptr<CacheData>>>
run_overlap_generator_kernel(const std::string& project_plan, std::shared_ptr<Context> context, std::vector<std::unique_ptr<CacheData>>& inputCacheData){
// overlap Generator kernel
std::shared_ptr<kernel> overlap_generator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_generator_cache, output_generator_cache;
std::tie(overlap_generator_kernel, input_generator_cache, output_generator_cache) = make_overlap_Generator_kernel(project_plan, context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachineGenerator,
precedingCacheMachineGenerator,
followingCacheMachineGenerator,
inputCacheMachineGenerator;
std::tie(batchesCacheMachineGenerator,
precedingCacheMachineGenerator,
followingCacheMachineGenerator,
inputCacheMachineGenerator) = register_kernel_overlap_generator_with_cache_machines(
overlap_generator_kernel,
context);
// run function in overlap generator
std::thread run_thread_generator = std::thread([overlap_generator_kernel]() {
kstatus process = overlap_generator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the Generator CacheMachines
for (std::size_t i = 0; i < inputCacheData.size(); i++) {
inputCacheMachineGenerator->addCacheData(std::move(inputCacheData[i]));
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
inputCacheMachineGenerator->finish();
run_thread_generator.join();
return {precedingCacheMachineGenerator->pull_all_cache_data(),
batchesCacheMachineGenerator->pull_all_cache_data(),
followingCacheMachineGenerator->pull_all_cache_data()};
}
std::vector<std::unique_ptr<CacheData>>
run_overlap_accumulator_kernel(const std::string& project_plan,
std::shared_ptr<Context> context,
std::vector<std::unique_ptr<CacheData>>& batchesCacheData,
std::vector<std::unique_ptr<CacheData>>& batchesPrecedingCacheData,
std::vector<std::unique_ptr<CacheData>>& batchesFollowingCacheData){
// overlap Accumulator kernel
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_accumulator_cache, output_accumulator_cache;
std::tie(overlap_accumulator_kernel, input_accumulator_cache, output_accumulator_cache) = make_overlap_Accumulator_kernel(
project_plan, context);
// register cache machines with the kernel
std::shared_ptr<CacheMachine> batchesCacheMachineAccumulator,
precedingCacheMachineAccumulator,
followingCacheMachineAccumulator,
outputCacheMachineAccumulator;
std::tie(batchesCacheMachineAccumulator,
precedingCacheMachineAccumulator,
followingCacheMachineAccumulator,
outputCacheMachineAccumulator) = register_kernel_overlap_accumulator_with_cache_machines(
overlap_accumulator_kernel,
context);
// run function in overlap accumulator
std::thread run_thread_accumulator = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the Accumulator CacheMachines
for (std::size_t i = 0; i < batchesCacheData.size(); i++) {
batchesCacheMachineAccumulator->addCacheData(std::move(batchesCacheData[i]));
if (i != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
precedingCacheMachineAccumulator->addCacheData(std::move(batchesPrecedingCacheData[i - 1]));
}
if (i != batchesCacheData.size() - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(2));
followingCacheMachineAccumulator->addCacheData(std::move(batchesFollowingCacheData[i]));
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
batchesCacheMachineAccumulator->finish();
precedingCacheMachineAccumulator->finish();
followingCacheMachineAccumulator->finish();
run_thread_accumulator.join();
// get and validate output
return outputCacheMachineAccumulator->pull_all_cache_data();
}
TEST_F(WindowOverlapGeneratorTest, BasicSingleNode) {
size_t size = 100000;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
int preceding_value = 50;
int following_value = 10;
std::vector<cudf::size_type> batch_sizes = {5000, 50000, 20000, 15000, 10000}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::vector<std::unique_ptr<CacheData>>& inputCacheData = batches;
std::tie(preceding_overlaps, batches, following_overlaps) = break_up_full_data(full_data_cudf_view, preceding_value, following_value, batch_sizes, names);
std::vector<std::unique_ptr<BlazingTable>> expected_batch_out = make_expected_generator_output(full_data_cudf_view,
batch_sizes, names);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(1);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize("0", "/tmp");
std::vector<std::unique_ptr<CacheData>> batches_preceding_pulled,
batches_pulled,
batches_following_pulled;
std::string project_plan = "LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 50 PRECEDING AND 10 FOLLOWING)])";
std::tie(batches_preceding_pulled,
batches_pulled,
batches_following_pulled)
= run_overlap_generator_kernel(project_plan,
context,
inputCacheData);
EXPECT_EQ(batches_preceding_pulled.size(), preceding_overlaps.size());
EXPECT_EQ(batches_pulled.size(), expected_batch_out.size());
EXPECT_EQ(batches_following_pulled.size(), following_overlaps.size());
//Validate metadata
for (const auto &batch : batches_preceding_pulled){
ral::cache::MetadataDictionary metadata = batch->getMetadata();
EXPECT_EQ(metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
}
for (const auto &batch : batches_following_pulled){
ral::cache::MetadataDictionary metadata = batch->getMetadata();
EXPECT_EQ(metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
}
//Validate the data
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
if (i < batches_preceding_pulled.size()) {
auto table_out_preceding = batches_preceding_pulled[i]->decache();
auto expected_out_preceding = preceding_overlaps[i]->decache();
cudf::test::expect_tables_equivalent(expected_out_preceding->view(), table_out_preceding->view());
}
if (i < batches_following_pulled.size()) {
auto table_out_following = batches_following_pulled[i]->decache();
auto expected_out_following = following_overlaps[i]->decache();
cudf::test::expect_tables_equivalent(expected_out_following->view(), table_out_following->view());
}
auto table_out_batches = batches_pulled[i]->decache();
cudf::test::expect_tables_equivalent(expected_batch_out[i]->view(), table_out_batches->view());
}
}
TEST_F(WindowOverlapGeneratorTest, BigWindowSingleNode) {
size_t size = 14600;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 1500;
int following_value = 3000;
std::vector<cudf::size_type> batch_sizes = {5500, 1100, 1200, 1300, 5500}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::vector<std::unique_ptr<CacheData>>& inputCacheData = batches;
std::tie(preceding_overlaps, batches, following_overlaps) = break_up_full_data(
full_data_cudf_view, preceding_value, following_value, batch_sizes, names);
std::vector<std::unique_ptr<BlazingTable>> expected_batch_out = make_expected_generator_output(full_data_cudf_view,
batch_sizes, names);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(1);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize("0", "/tmp");
std::vector<std::unique_ptr<CacheData>> batches_preceding_pulled,
batches_pulled,
batches_following_pulled;
std::string project_plan = "LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 1500 PRECEDING AND 3000 FOLLOWING)])";
std::tie(batches_preceding_pulled,
batches_pulled,
batches_following_pulled)
= run_overlap_generator_kernel(project_plan,
context,
inputCacheData);
EXPECT_EQ(batches_preceding_pulled.size(), preceding_overlaps.size());
EXPECT_EQ(batches_pulled.size(), expected_batch_out.size());
EXPECT_EQ(batches_following_pulled.size(), following_overlaps.size());
//Validate metadata
for (std::size_t i = 0; i < batches_preceding_pulled.size(); ++i) {
ral::cache::MetadataDictionary metadata = batches_preceding_pulled[i]->getMetadata();
if (i == 0) {
EXPECT_EQ(metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
} else {
EXPECT_EQ(metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::INCOMPLETE_OVERLAP_STATUS);
}
}
for (std::size_t i = 0; i < batches_following_pulled.size(); ++i) {
ral::cache::MetadataDictionary metadata = batches_following_pulled[i]->getMetadata();
if (i == batches_following_pulled.size() - 1) {
EXPECT_EQ(metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::DONE_OVERLAP_STATUS);
} else {
EXPECT_EQ(metadata.get_value(ral::cache::OVERLAP_STATUS), ral::batch::INCOMPLETE_OVERLAP_STATUS);
}
}
//Validate the data
for (std::size_t i = 0; i < batches_pulled.size(); i++) {
if (i < batches_preceding_pulled.size()) {
auto table_out_preceding = batches_preceding_pulled[i]->decache();
auto expected_out_preceding = preceding_overlaps[i]->decache();
cudf::test::expect_tables_equivalent(expected_out_preceding->view(), table_out_preceding->view());
}
if (i < batches_following_pulled.size()) {
auto table_out_following = batches_following_pulled[i]->decache();
auto expected_out_following = following_overlaps[i]->decache();
cudf::test::expect_tables_equivalent(expected_out_following->view(), table_out_following->view());
}
auto table_out_batches = batches_pulled[i]->decache();
cudf::test::expect_tables_equivalent(expected_batch_out[i]->view(), table_out_batches->view());
}
}
TEST_F(WindowOverlapTest, BasicSingleNode) {
size_t size = 100000;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
int preceding_value = 50;
int following_value = 10;
std::vector<cudf::size_type> batch_sizes = {5000, 50000, 20000, 15000, 10000}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::vector<std::unique_ptr<CacheData>>& inputCacheData = batches;
std::tie(preceding_overlaps, batches, following_overlaps) = break_up_full_data(full_data_cudf_view, preceding_value, following_value, batch_sizes, names);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(1);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize("0", "/tmp");
std::vector<std::unique_ptr<CacheData>> batches_preceding_pulled,
batches_pulled,
batches_following_pulled;
std::string project_plan = "LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 50 PRECEDING AND 10 FOLLOWING)])";
std::tie(batches_preceding_pulled,
batches_pulled,
batches_following_pulled)
= run_overlap_generator_kernel(project_plan,
context,
inputCacheData);
std::vector<std::unique_ptr<CacheData>> last_batches_pulled = run_overlap_accumulator_kernel(project_plan,
context,
batches_pulled,
batches_preceding_pulled,
batches_following_pulled);
EXPECT_EQ(last_batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < last_batches_pulled.size(); i++) {
auto table_out = last_batches_pulled[i]->decache();
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
}
TEST_F(WindowOverlapTest, BigWindowSingleNode) {
size_t size = 14600;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
// CudfTableView full_data_cudf_view ({col0});
int preceding_value = 1500;
int following_value = 3000;
std::vector<cudf::size_type> batch_sizes = {5500, 1100, 1200, 1300, 5500}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::vector<std::unique_ptr<CacheData>>& inputCacheData = batches;
std::tie(preceding_overlaps, batches, following_overlaps) = break_up_full_data(full_data_cudf_view, preceding_value, following_value, batch_sizes, names);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(1);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize("0", "/tmp");
std::vector<std::unique_ptr<CacheData>> batches_preceding_pulled,
batches_pulled,
batches_following_pulled;
std::string project_plan = "LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 1500 PRECEDING AND 3000 FOLLOWING)])";
std::tie(batches_preceding_pulled,
batches_pulled,
batches_following_pulled)
= run_overlap_generator_kernel(project_plan,
context,
inputCacheData);
std::vector<std::unique_ptr<CacheData>> last_batches_pulled = run_overlap_accumulator_kernel(project_plan,
context,
batches_pulled,
batches_preceding_pulled,
batches_following_pulled);
EXPECT_EQ(last_batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < last_batches_pulled.size(); i++) {
auto table_out = last_batches_pulled[i]->decache();
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
}
TEST_F(WindowOverlapTest, BasicSingleNode2) {
size_t size = 100000;
// Define full dataset
auto iter0 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i);});
auto iter1 = cudf::detail::make_counting_transform_iterator(1000, [](auto i) { return int32_t(i * 2);});
auto iter2 = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return int32_t(i % 5);});
auto valids_iter = cudf::detail::make_counting_transform_iterator(0, [](auto /*i*/) { return true; });
cudf::test::fixed_width_column_wrapper<int32_t> col0(iter0, iter0 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col1(iter1, iter1 + size, valids_iter);
cudf::test::fixed_width_column_wrapper<int32_t> col2(iter2, iter2 + size, valids_iter);
CudfTableView full_data_cudf_view ({col0, col1, col2});
int preceding_value = 50;
int following_value = 10;
std::vector<cudf::size_type> batch_sizes = {5000, 50000, 20000, 15000, 10000}; // need to sum up to size
// define how its broken up into batches and overlaps
std::vector<std::string> names({"A", "B", "C"});
std::vector<std::unique_ptr<CacheData>> preceding_overlaps, batches, following_overlaps;
std::vector<std::unique_ptr<CacheData>>& inputCacheData = batches;
std::tie(preceding_overlaps, batches, following_overlaps) = break_up_full_data(full_data_cudf_view, preceding_value, following_value, batch_sizes, names);
std::vector<std::unique_ptr<BlazingTable>> expected_out = make_expected_accumulator_output(full_data_cudf_view,
preceding_value,
following_value,
batch_sizes, names);
// create and start kernel
// Context
std::shared_ptr<Context> context = make_context(1);
auto & communicationData = ral::communication::CommunicationData::getInstance();
communicationData.initialize("0", "/tmp");
std::string project_plan = "LogicalProject(min_val=[MIN($0) OVER (ORDER BY $1 ROWS BETWEEN 50 PRECEDING AND 10 FOLLOWING)])";
// overlap Generator kernel
std::shared_ptr<kernel> overlap_generator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_generator_cache, output_generator_cache;
std::tie(overlap_generator_kernel, input_generator_cache, output_generator_cache) = make_overlap_Generator_kernel(project_plan, context);
std::shared_ptr<kernel> overlap_accumulator_kernel;
std::shared_ptr<ral::cache::CacheMachine> input_accumulator_cache, output_accumulator_cache;
std::tie(overlap_accumulator_kernel, input_accumulator_cache, output_accumulator_cache) = make_overlap_Accumulator_kernel(project_plan, context);
std::shared_ptr<CacheMachine> batchesCacheMachine = std::make_shared<CacheMachine>(context, "batches");
std::shared_ptr<CacheMachine> precedingCacheMachine = std::make_shared<CacheMachine>(context, "preceding_overlaps");
std::shared_ptr<CacheMachine> followingCacheMachine = std::make_shared<CacheMachine>(context, "following_overlaps");
std::shared_ptr<CacheMachine> inputCacheMachine = std::make_shared<CacheMachine>(context, "1");
std::shared_ptr<CacheMachine> outputCacheMachine = std::make_shared<CacheMachine>(context, "1");
overlap_generator_kernel->input_.register_cache("1", inputCacheMachine);
overlap_generator_kernel->output_.register_cache("batches", batchesCacheMachine);
overlap_generator_kernel->output_.register_cache("preceding_overlaps", precedingCacheMachine);
overlap_generator_kernel->output_.register_cache("following_overlaps", followingCacheMachine);
overlap_accumulator_kernel->input_.register_cache("batches", batchesCacheMachine);
overlap_accumulator_kernel->input_.register_cache("preceding_overlaps", precedingCacheMachine);
overlap_accumulator_kernel->input_.register_cache("following_overlaps", followingCacheMachine);
overlap_accumulator_kernel->output_.register_cache("1", outputCacheMachine);
// run function in overlap generator
std::thread run_thread_generator = std::thread([overlap_generator_kernel]() {
kstatus process = overlap_generator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
// run function in overlap accumulator
std::thread run_thread_accumulator = std::thread([overlap_accumulator_kernel](){
kstatus process = overlap_accumulator_kernel->run();
EXPECT_EQ(kstatus::proceed, process);
});
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// add data into the Generator CacheMachines
for (std::size_t i = 0; i < inputCacheData.size(); i++) {
inputCacheMachine->addCacheData(std::move(inputCacheData[i]));
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
inputCacheMachine->finish();
std::this_thread::sleep_for(std::chrono::milliseconds(500));
batchesCacheMachine->finish();
precedingCacheMachine->finish();
followingCacheMachine->finish();
std::this_thread::sleep_for(std::chrono::milliseconds(500));
outputCacheMachine->finish();
run_thread_generator.join();
run_thread_accumulator.join();
// get and validate output
auto last_batches_pulled = outputCacheMachine->pull_all_cache_data();
EXPECT_EQ(last_batches_pulled.size(), expected_out.size());
for (std::size_t i = 0; i < last_batches_pulled.size(); i++) {
auto table_out = last_batches_pulled[i]->decache();
cudf::test::expect_tables_equivalent(expected_out[i]->view(), table_out->view());
}
} | 56.167439 | 226 | 0.726924 | [
"vector"
] |
d58aec8c0919094a40b7dacc2c2bd58f63c43b40 | 7,184 | cpp | C++ | old/md5/md5.cpp | CodeCrackerSND/BarsWF_v2 | 6f77a7bca11f9b6044abde7f16984ddf1a68e31d | [
"MIT"
] | 12 | 2020-02-10T12:55:41.000Z | 2021-07-08T14:28:51.000Z | old/md5/md5.cpp | CodeCrackerSND/BarsWF_v1 | 68cdf3acc89d659b4d1f80393e2782908118c5a9 | [
"MIT"
] | 1 | 2020-12-30T04:45:48.000Z | 2020-12-30T04:45:48.000Z | old/md5/md5.cpp | CodeCrackerSND/BarsWF_v2 | 6f77a7bca11f9b6044abde7f16984ddf1a68e31d | [
"MIT"
] | 7 | 2020-02-09T12:20:21.000Z | 2021-07-25T20:14:08.000Z | // md5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <assert.h>
#include <iostream>
#include <sstream>
#include <string>
#include <conio.h>
#include <windows.h>
using namespace std;
typedef unsigned char hl_uint8;
typedef unsigned short int hl_uint16;
typedef unsigned long int hl_uint32;
typedef unsigned long long int hl_uint64;
typedef hl_uint8 *POINTER;
/** state (ABCD) */
unsigned long int state[4];
int target[4] = {0xb182b498, 0xf4d2ac41, 0x1f636569, 0xaf4caf00};
unsigned long int num_ok = 0;
/** number of bits, modulo 2^64 (lsb first) */
unsigned long int bit_count;
/** input buffer */
union encode_data
{
unsigned char c_buffer[64];
unsigned int x[16];
} data;
// Constants for MD5Transform routine.
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
/* F, G, H and I are basic MD5 functions. */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/*
* ROTATE_LEFT rotates x left n bits.
* cast to unsigned int to guarantee support for 64Bit System
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | (( (unsigned int) x) >> (32-(n))))
/*
FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (unsigned long int)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (unsigned long int)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (unsigned long int)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (unsigned long int)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define unrollII(a, b, c, d, x, s, ac) { \
(a) -= (b); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) -= I ((b), (c), (d)) + (x) + (unsigned long int)(ac); \
}
//----------------------------------------------------------------------
//private member-functions
/**
* @brief Basic transformation. Transforms state based on block.
* @param state state to transform
* @param block block to transform
*/
inline bool MD5Transform ()
{
unsigned long int a = 0x67452301, b = 0xefcdab89, c = 0x98badcfe, d = 0x10325476;
/* Round 1 */
FF (a, b, c, d, data.x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, data.x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, data.x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, data.x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, 0, S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, 0, S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, 0, S13, 0xa8304613); /* 7 */
FF (b, c, d, a, 0, S14, 0xfd469501); /* 8 */
FF (a, b, c, d, 0, S11, 0x698098d8); /* 9 */
FF (d, a, b, c, 0, S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, 0, S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, 0, S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, 0, S11, 0x6b901122); /* 13 */
FF (d, a, b, c, 0, S12, 0xfd987193); /* 14 */
FF (c, d, a, b, 96, S13, 0xa679438e); /* 15 */
FF (b, c, d, a, 0, S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, data.x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, 0, S22, 0xc040b340); /* 18 */
GG (c, d, a, b, 0, S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, data.x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, 0, S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, 0, S22, 0x2441453); /* 22 */
GG (c, d, a, b, 0, S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, 0, S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, 0, S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, 96, S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, data.x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, 0, S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, 0, S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, data.x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, 0, S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, 0, S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, 0, S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, 0, S32, 0x8771f681); /* 34 */
HH (c, d, a, b, 0, S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, 96, S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, data.x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, 0, S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, 0, S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, 0, S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, 0, S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, data.x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, data.x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, 0, S34, 0x4881d05); /* 44 */
HH (a, b, c, d, 0, S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, 0, S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, 0, S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, data.x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, data.x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, 0, S42, 0x432aff97); /* 50 */
II (c, d, a, b, 96, S43, 0xab9423a7); /* 51 */
II (b, c, d, a, 0, S44, 0xfc93a039); /* 52 */
II (a, b, c, d, 0, S41, 0x655b59c3); /* 53 */
II (d, a, b, c, data.x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, 0, S43, 0xffeff47d); /* 55 */
II (b, c, d, a, data.x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, 0, S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, 0, S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, 0, S43, 0xa3014314); /* 59 */
II (b, c, d, a, 0, S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, 0, S41, 0xf7537e82); /* 61 */
//early a check, as a is finalized here
if(a != target[0])return false;//hash incorrect
II (d, a, b, c, 0, S42, 0xbd3af235); /* 62 */
II (c, d, a, b, data.x[ 2], S43, 0x2ad7d2bb); /* 63 */
// II (b, c, d, a, 0, S44, 0xeb86d391); /* 64 */ - this step was unrolled
if( b == target[1] &&
c == target[2] &&
d == target[3]
)num_ok++;
}
std::string printHash(unsigned char *bytes)
{
std::ostringstream os;
for(int i=0; i<16; ++i)
{
os.width(2);
os.fill('0');
os << std::hex << static_cast<unsigned int>(bytes[i]);
}
return os.str();
}
int _tmain(int argc, _TCHAR* argv[])
{
unsigned int time = GetTickCount();
unsigned char pass[] = "Testpasswor";
unsigned char buff[16] = "";
strcpy((char*)data.c_buffer, (char*)pass);
data.c_buffer[strlen((char*)pass)]=0x80;
data.c_buffer[56]=strlen((char*)pass)*8;
//unroll last addition
target[0]-=0x67452301;
target[1]-=0xefcdab89;
target[2]-=0x98badcfe;
target[3]-=0x10325476;
//unroll step 64
unrollII (target[1], target[2], target[3], target[0], 0, 32-S44, 0xeb86d391); /* 64 */
//do the math
for(int i=0;i<50000000;i++)
{
MD5Transform ();
}
printf("Speed: %3.3f Mh/s", 50000000.0/(GetTickCount()-time)/1000.0);
string res = printHash((unsigned char *)state);
/* if(res == "98b482b141acd2f46965631f00af4caf")
cout<<"Hash correct!";else cout<<"Hash incorrect :-[";*/
cout<<endl<<"Num of correct hashes: "<<num_ok<<endl;
getch();
return 0;
}
| 29.933333 | 87 | 0.534243 | [
"transform"
] |
d5928633e6a569f29e231710f6878edab6e47d8d | 2,796 | cpp | C++ | examples/ARC/main.cpp | emarc99/SLib | 4e492d6c550f845fd1b3f40bf10183097eb0e53c | [
"MIT"
] | 146 | 2017-03-21T07:50:43.000Z | 2022-03-19T03:32:22.000Z | examples/ARC/main.cpp | Crasader/SLib | 4e492d6c550f845fd1b3f40bf10183097eb0e53c | [
"MIT"
] | 50 | 2017-03-22T04:08:15.000Z | 2019-10-21T16:55:48.000Z | examples/ARC/main.cpp | Crasader/SLib | 4e492d6c550f845fd1b3f40bf10183097eb0e53c | [
"MIT"
] | 55 | 2017-03-21T07:52:58.000Z | 2021-12-27T13:02:08.000Z | /*
* Copyright (c) 2008-2018 SLIBIO <https://github.com/SLIBIO>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <slib/core.h>
using namespace slib;
class ExampleNode : public Object
{
private:
String name;
WeakRef<ExampleNode> parent;
List<Ref<ExampleNode>> children;
public:
ExampleNode()
{
Println("Constructor called");
// Not safe to access `this` reference
}
~ExampleNode()
{
Println("Destructor called: %s", name);
}
void init() override
{
Object::init();
Println("Initializer called");
// Safe to access `this` reference
}
void init(const String& name, Ref<ExampleNode> parent = nullptr)
{
this->name = name;
Println("Init called: %s", name);
if (parent != nullptr) {
this->parent = parent;
parent->children.add(this);
}
}
void print()
{
Ref<ExampleNode> parent = this->parent;
if (parent == nullptr) {
Println("[Print] Root Node: %s", name);
} else {
if (children.getCount() > 0) {
Println("[Print] Node: %s, Parent: %s", name, parent->name);
} else {
Println("[Print] Leaf Node: %s, Parent: %s", name, parent->name);
}
}
for (auto& child : children) {
child->print();
}
}
};
int main(int argc, const char * argv[]) {
Ref<ExampleNode> node0 = New<ExampleNode>();
Ref<ExampleNode> node = New<ExampleNode>("Root");
Ref<ExampleNode> node1 = New<ExampleNode>("Node1", node);
Ref<ExampleNode> node11 = New<ExampleNode>("Node1-1", node1);
Ref<ExampleNode> node12 = New<ExampleNode>("Node1-2", node1);
Ref<ExampleNode> node2 = New<ExampleNode>("Node2", node);
Ref<ExampleNode> node21 = New<ExampleNode>("Node2-1", node2);
Ref<ExampleNode> node22 = New<ExampleNode>("Node2-2", node2);
node->print();
return 0;
}
| 28.242424 | 82 | 0.683119 | [
"object"
] |
d5928a3353dd44ab4d5e93d209a3e971b115d60b | 8,970 | cc | C++ | chromium/ui/views/touchui/touch_selection_menu_runner_views.cc | wedataintelligence/vivaldi-source | 22a46f2c969f6a0b7ca239a05575d1ea2738768c | [
"BSD-3-Clause"
] | 27 | 2016-04-27T01:02:03.000Z | 2021-12-13T08:53:19.000Z | chromium/ui/views/touchui/touch_selection_menu_runner_views.cc | wedataintelligence/vivaldi-source | 22a46f2c969f6a0b7ca239a05575d1ea2738768c | [
"BSD-3-Clause"
] | 2 | 2017-03-09T09:00:50.000Z | 2017-09-21T15:48:20.000Z | chromium/ui/views/touchui/touch_selection_menu_runner_views.cc | wedataintelligence/vivaldi-source | 22a46f2c969f6a0b7ca239a05575d1ea2738768c | [
"BSD-3-Clause"
] | 17 | 2016-04-27T02:06:39.000Z | 2019-12-18T08:07:00.000Z | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/touchui/touch_selection_menu_runner_views.h"
#include <stddef.h>
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/text_utils.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/layout/box_layout.h"
namespace views {
namespace {
const int kMenuCommands[] = {IDS_APP_CUT, IDS_APP_COPY, IDS_APP_PASTE};
const int kSpacingBetweenButtons = 2;
const int kButtonSeparatorColor = SkColorSetARGB(13, 0, 0, 0);
const int kMenuButtonMinHeight = 38;
const int kMenuButtonMinWidth = 63;
const int kMenuMargin = 1;
const char kEllipsesButtonText[] = "...";
const int kEllipsesButtonTag = -1;
} // namespace
// A bubble that contains actions available for the selected text. An object of
// this type, as a BubbleDelegateView, manages its own lifetime.
class TouchSelectionMenuRunnerViews::Menu : public BubbleDelegateView,
public ButtonListener {
public:
Menu(TouchSelectionMenuRunnerViews* owner,
ui::TouchSelectionMenuClient* client,
const gfx::Rect& anchor_rect,
const gfx::Size& handle_image_size,
aura::Window* context);
// Checks whether there is any command available to show in the menu.
static bool IsMenuAvailable(const ui::TouchSelectionMenuClient* client);
// Closes the menu. This will eventually self-destroy the object.
void Close();
private:
friend class TouchSelectionMenuRunnerViews::TestApi;
~Menu() override;
// Queries the |client_| for what commands to show in the menu and sizes the
// menu appropriately.
void CreateButtons();
// Helper method to create a single button.
Button* CreateButton(const base::string16& title, int tag);
// Helper to disconnect this menu object from its owning menu runner.
void DisconnectOwner();
// BubbleDelegateView:
void OnPaint(gfx::Canvas* canvas) override;
void WindowClosing() override;
// ButtonListener:
void ButtonPressed(Button* sender, const ui::Event& event) override;
TouchSelectionMenuRunnerViews* owner_;
ui::TouchSelectionMenuClient* const client_;
DISALLOW_COPY_AND_ASSIGN(Menu);
};
TouchSelectionMenuRunnerViews::Menu::Menu(TouchSelectionMenuRunnerViews* owner,
ui::TouchSelectionMenuClient* client,
const gfx::Rect& anchor_rect,
const gfx::Size& handle_image_size,
aura::Window* context)
: BubbleDelegateView(nullptr, BubbleBorder::BOTTOM_CENTER),
owner_(owner),
client_(client) {
DCHECK(owner_);
DCHECK(client_);
set_shadow(BubbleBorder::SMALL_SHADOW);
set_parent_window(context);
set_margins(gfx::Insets(kMenuMargin, kMenuMargin, kMenuMargin, kMenuMargin));
set_can_activate(false);
set_adjust_if_offscreen(true);
EnableCanvasFlippingForRTLUI(true);
SetLayoutManager(
new BoxLayout(BoxLayout::kHorizontal, 0, 0, kSpacingBetweenButtons));
CreateButtons();
// After buttons are created, check if there is enough room between handles to
// show the menu and adjust anchor rect properly if needed, just in case the
// menu is needed to be shown under the selection.
gfx::Rect adjusted_anchor_rect(anchor_rect);
int menu_width = GetPreferredSize().width();
// TODO(mfomitchev): This assumes that the handles are center-aligned to the
// |achor_rect| edges, which is not true. We should fix this, perhaps by
// passing down the cumulative width occupied by the handles within
// |anchor_rect| plus the handle image height instead of |handle_image_size|.
// Perhaps we should also allow for some minimum padding.
if (menu_width > anchor_rect.width() - handle_image_size.width())
adjusted_anchor_rect.Inset(0, 0, 0, -handle_image_size.height());
SetAnchorRect(adjusted_anchor_rect);
BubbleDelegateView::CreateBubble(this);
GetWidget()->Show();
}
bool TouchSelectionMenuRunnerViews::Menu::IsMenuAvailable(
const ui::TouchSelectionMenuClient* client) {
DCHECK(client);
for (size_t i = 0; i < arraysize(kMenuCommands); i++) {
if (client->IsCommandIdEnabled(kMenuCommands[i]))
return true;
}
return false;
}
TouchSelectionMenuRunnerViews::Menu::~Menu() {
}
void TouchSelectionMenuRunnerViews::Menu::CreateButtons() {
for (size_t i = 0; i < arraysize(kMenuCommands); i++) {
int command_id = kMenuCommands[i];
if (!client_->IsCommandIdEnabled(command_id))
continue;
Button* button =
CreateButton(l10n_util::GetStringUTF16(command_id), command_id);
AddChildView(button);
}
// Finally, add ellipses button.
AddChildView(
CreateButton(base::UTF8ToUTF16(kEllipsesButtonText), kEllipsesButtonTag));
Layout();
}
Button* TouchSelectionMenuRunnerViews::Menu::CreateButton(
const base::string16& title,
int tag) {
base::string16 label =
gfx::RemoveAcceleratorChar(title, '&', nullptr, nullptr);
LabelButton* button = new LabelButton(this, label);
button->SetMinSize(gfx::Size(kMenuButtonMinWidth, kMenuButtonMinHeight));
button->SetFocusable(true);
button->set_request_focus_on_press(false);
const gfx::FontList& font_list =
ui::ResourceBundle::GetSharedInstance().GetFontList(
ui::ResourceBundle::SmallFont);
button->SetFontList(font_list);
button->SetHorizontalAlignment(gfx::ALIGN_CENTER);
button->set_tag(tag);
return button;
}
void TouchSelectionMenuRunnerViews::Menu::Close() {
DisconnectOwner();
// Closing the widget will self-destroy this object.
Widget* widget = GetWidget();
if (widget && !widget->IsClosed())
widget->Close();
}
void TouchSelectionMenuRunnerViews::Menu::DisconnectOwner() {
DCHECK(owner_);
owner_->menu_ = nullptr;
owner_ = nullptr;
}
void TouchSelectionMenuRunnerViews::Menu::OnPaint(gfx::Canvas* canvas) {
BubbleDelegateView::OnPaint(canvas);
// Draw separator bars.
for (int i = 0; i < child_count() - 1; ++i) {
View* child = child_at(i);
int x = child->bounds().right() + kSpacingBetweenButtons / 2;
canvas->FillRect(gfx::Rect(x, 0, 1, child->height()),
kButtonSeparatorColor);
}
}
void TouchSelectionMenuRunnerViews::Menu::WindowClosing() {
DCHECK(!owner_ || owner_->menu_ == this);
BubbleDelegateView::WindowClosing();
if (owner_)
DisconnectOwner();
}
void TouchSelectionMenuRunnerViews::Menu::ButtonPressed(
Button* sender,
const ui::Event& event) {
Close();
if (sender->tag() != kEllipsesButtonTag)
client_->ExecuteCommand(sender->tag(), event.flags());
else
client_->RunContextMenu();
}
TouchSelectionMenuRunnerViews::TestApi::TestApi(
TouchSelectionMenuRunnerViews* menu_runner)
: menu_runner_(menu_runner) {
DCHECK(menu_runner_);
}
TouchSelectionMenuRunnerViews::TestApi::~TestApi() {}
gfx::Rect TouchSelectionMenuRunnerViews::TestApi::GetAnchorRect() const {
TouchSelectionMenuRunnerViews::Menu* menu = menu_runner_->menu_;
return menu ? menu->GetAnchorRect() : gfx::Rect();
}
Button* TouchSelectionMenuRunnerViews::TestApi::GetFirstButton() const {
TouchSelectionMenuRunnerViews::Menu* menu = menu_runner_->menu_;
return menu ? static_cast<Button*>(menu->child_at(0)) : nullptr;
}
Widget* TouchSelectionMenuRunnerViews::TestApi::GetWidget() const {
TouchSelectionMenuRunnerViews::Menu* menu = menu_runner_->menu_;
return menu ? menu->GetWidget() : nullptr;
}
TouchSelectionMenuRunnerViews::TouchSelectionMenuRunnerViews()
: menu_(nullptr) {
}
TouchSelectionMenuRunnerViews::~TouchSelectionMenuRunnerViews() {
CloseMenu();
}
bool TouchSelectionMenuRunnerViews::IsMenuAvailable(
const ui::TouchSelectionMenuClient* client) const {
return TouchSelectionMenuRunnerViews::Menu::IsMenuAvailable(client);
}
void TouchSelectionMenuRunnerViews::OpenMenu(
ui::TouchSelectionMenuClient* client,
const gfx::Rect& anchor_rect,
const gfx::Size& handle_image_size,
aura::Window* context) {
CloseMenu();
if (TouchSelectionMenuRunnerViews::Menu::IsMenuAvailable(client))
menu_ = new Menu(this, client, anchor_rect, handle_image_size, context);
}
void TouchSelectionMenuRunnerViews::CloseMenu() {
if (!menu_)
return;
// Closing the menu sets |menu_| to nullptr and eventually deletes the object.
menu_->Close();
DCHECK(!menu_);
}
bool TouchSelectionMenuRunnerViews::IsRunning() const {
return menu_ != nullptr;
}
} // namespace views
| 32.5 | 80 | 0.722631 | [
"geometry",
"object"
] |
d593aef5921a54e9e01fb241279f0291d6f36180 | 10,417 | cpp | C++ | be/src/olap/delta_writer.cpp | Xuxue1/incubator-doris | 3ea12dd5932b90ea949782e7ebf6a282cb75652b | [
"Apache-2.0"
] | 2 | 2020-08-05T05:23:51.000Z | 2021-01-27T06:31:13.000Z | be/src/olap/delta_writer.cpp | imay/incubator-doris | cefe1794d4b9feb9e5e8377750994b53c411cab9 | [
"Apache-2.0"
] | null | null | null | be/src/olap/delta_writer.cpp | imay/incubator-doris | cefe1794d4b9feb9e5e8377750994b53c411cab9 | [
"Apache-2.0"
] | null | null | null | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "olap/delta_writer.h"
#include "olap/schema.h"
#include "olap/data_dir.h"
#include "olap/rowset/alpha_rowset_writer.h"
#include "olap/rowset/rowset_meta_manager.h"
#include "olap/rowset/rowset_id_generator.h"
namespace doris {
OLAPStatus DeltaWriter::open(WriteRequest* req, DeltaWriter** writer) {
*writer = new DeltaWriter(req);
return OLAP_SUCCESS;
}
DeltaWriter::DeltaWriter(WriteRequest* req)
: _req(*req), _tablet(nullptr),
_cur_rowset(nullptr), _new_rowset(nullptr), _new_tablet(nullptr),
_rowset_writer(nullptr), _mem_table(nullptr),
_schema(nullptr), _tablet_schema(nullptr),
_delta_written_success(false) {}
DeltaWriter::~DeltaWriter() {
if (!_delta_written_success) {
_garbage_collection();
}
SAFE_DELETE(_mem_table);
SAFE_DELETE(_schema);
if (_rowset_writer != nullptr) {
_rowset_writer->data_dir()->remove_pending_ids(ROWSET_ID_PREFIX + std::to_string(_rowset_writer->rowset_id()));
}
}
void DeltaWriter::_garbage_collection() {
OLAPStatus rollback_status = OLAP_SUCCESS;
if (_tablet != nullptr) {
rollback_status = StorageEngine::instance()->txn_manager()->rollback_txn(_req.partition_id,
_req.txn_id,_req.tablet_id, _req.schema_hash, _tablet->tablet_uid());
}
// has to check rollback status, because the rowset maybe committed in this thread and
// published in another thread, then rollback will failed
// when rollback failed should not delete rowset
if (rollback_status == OLAP_SUCCESS) {
StorageEngine::instance()->add_unused_rowset(_cur_rowset);
}
if (_new_tablet != nullptr) {
rollback_status = StorageEngine::instance()->txn_manager()->rollback_txn(_req.partition_id, _req.txn_id,
_new_tablet->tablet_id(), _new_tablet->schema_hash(), _new_tablet->tablet_uid());
if (rollback_status == OLAP_SUCCESS) {
StorageEngine::instance()->add_unused_rowset(_new_rowset);
}
}
}
OLAPStatus DeltaWriter::init() {
_tablet = StorageEngine::instance()->tablet_manager()->get_tablet(_req.tablet_id, _req.schema_hash);
if (_tablet == nullptr) {
LOG(WARNING) << "tablet_id: " << _req.tablet_id << ", "
<< "schema_hash: " << _req.schema_hash << " not found";
return OLAP_ERR_TABLE_NOT_FOUND;
}
{
ReadLock base_migration_rlock(_tablet->get_migration_lock_ptr(), TRY_LOCK);
if (!base_migration_rlock.own_lock()) {
return OLAP_ERR_RWLOCK_ERROR;
}
MutexLock push_lock(_tablet->get_push_lock());
RETURN_NOT_OK(StorageEngine::instance()->txn_manager()->prepare_txn(
_req.partition_id, _req.txn_id,
_req.tablet_id, _req.schema_hash, _tablet->tablet_uid(), _req.load_id));
if (_req.need_gen_rollup) {
AlterTabletTaskSharedPtr alter_task = _tablet->alter_task();
if (alter_task != nullptr && alter_task->alter_state() != ALTER_FAILED) {
TTabletId new_tablet_id = alter_task->related_tablet_id();
TSchemaHash new_schema_hash = alter_task->related_schema_hash();
LOG(INFO) << "load with schema change." << "old_tablet_id: " << _tablet->tablet_id() << ", "
<< "old_schema_hash: " << _tablet->schema_hash() << ", "
<< "new_tablet_id: " << new_tablet_id << ", "
<< "new_schema_hash: " << new_schema_hash << ", "
<< "transaction_id: " << _req.txn_id;
_new_tablet = StorageEngine::instance()->tablet_manager()->get_tablet(new_tablet_id, new_schema_hash);
if (_new_tablet == nullptr) {
LOG(WARNING) << "find alter task, but could not find new tablet tablet_id: " << new_tablet_id
<< ", schema_hash: " << new_schema_hash;
return OLAP_ERR_TABLE_NOT_FOUND;
}
ReadLock new_migration_rlock(_new_tablet->get_migration_lock_ptr(), TRY_LOCK);
if (!new_migration_rlock.own_lock()) {
return OLAP_ERR_RWLOCK_ERROR;
}
StorageEngine::instance()->txn_manager()->prepare_txn(
_req.partition_id, _req.txn_id,
new_tablet_id, new_schema_hash, _new_tablet->tablet_uid(), _req.load_id);
}
}
}
RowsetId rowset_id = 0; // get rowset_id from id generator
OLAPStatus status = _tablet->next_rowset_id(&rowset_id);
if (status != OLAP_SUCCESS) {
LOG(WARNING) << "generate rowset id failed, status:" << status;
return OLAP_ERR_ROWSET_GENERATE_ID_FAILED;
}
RowsetWriterContext writer_context;
writer_context.rowset_id = rowset_id;
writer_context.tablet_uid = _tablet->tablet_uid();
writer_context.tablet_id = _req.tablet_id;
writer_context.partition_id = _req.partition_id;
writer_context.tablet_schema_hash = _req.schema_hash;
writer_context.rowset_type = ALPHA_ROWSET;
writer_context.rowset_path_prefix = _tablet->tablet_path();
writer_context.tablet_schema = &(_tablet->tablet_schema());
writer_context.rowset_state = PREPARED;
writer_context.data_dir = _tablet->data_dir();
writer_context.txn_id = _req.txn_id;
writer_context.load_id = _req.load_id;
// TODO: new RowsetBuilder according to tablet storage type
_rowset_writer.reset(new AlphaRowsetWriter());
status = _rowset_writer->init(writer_context);
if (status != OLAP_SUCCESS) {
return OLAP_ERR_ROWSET_WRITER_INIT;
}
const std::vector<SlotDescriptor*>& slots = _req.tuple_desc->slots();
const TabletSchema& schema = _tablet->tablet_schema();
for (size_t col_id = 0; col_id < schema.num_columns(); ++col_id) {
const TabletColumn& column = schema.column(col_id);
for (size_t i = 0; i < slots.size(); ++i) {
if (slots[i]->col_name() == column.name()) {
_col_ids.push_back(i);
}
}
}
_tablet_schema = &(_tablet->tablet_schema());
_schema = new Schema(*_tablet_schema);
_mem_table = new MemTable(_schema, _tablet_schema, &_col_ids,
_req.tuple_desc, _tablet->keys_type());
_is_init = true;
return OLAP_SUCCESS;
}
OLAPStatus DeltaWriter::write(Tuple* tuple) {
if (!_is_init) {
auto st = init();
if (st != OLAP_SUCCESS) {
return st;
}
}
_mem_table->insert(tuple);
if (_mem_table->memory_usage() >= config::write_buffer_size) {
RETURN_NOT_OK(_mem_table->flush(_rowset_writer));
SAFE_DELETE(_mem_table);
_mem_table = new MemTable(_schema, _tablet_schema, &_col_ids,
_req.tuple_desc, _tablet->keys_type());
}
return OLAP_SUCCESS;
}
OLAPStatus DeltaWriter::close(google::protobuf::RepeatedPtrField<PTabletInfo>* tablet_vec) {
if (!_is_init) {
auto st = init();
if (st != OLAP_SUCCESS) {
return st;
}
}
RETURN_NOT_OK(_mem_table->close(_rowset_writer));
OLAPStatus res = OLAP_SUCCESS;
// use rowset meta manager to save meta
_cur_rowset = _rowset_writer->build();
if (_cur_rowset == nullptr) {
LOG(WARNING) << "fail to build rowset";
return OLAP_ERR_MALLOC_ERROR;
}
res = StorageEngine::instance()->txn_manager()->commit_txn(_tablet->data_dir()->get_meta(),
_req.partition_id, _req.txn_id,_req.tablet_id, _req.schema_hash, _tablet->tablet_uid(),
_req.load_id, _cur_rowset, false);
if (res != OLAP_SUCCESS && res != OLAP_ERR_PUSH_TRANSACTION_ALREADY_EXIST) {
LOG(WARNING) << "commit txn: " << _req.txn_id
<< " for rowset: " << _cur_rowset->rowset_id()
<< " failed.";
return res;
}
if (_new_tablet != nullptr) {
LOG(INFO) << "convert version for schema change";
SchemaChangeHandler schema_change;
res = schema_change.schema_version_convert(_tablet, _new_tablet, &_cur_rowset, &_new_rowset);
if (res != OLAP_SUCCESS) {
LOG(WARNING) << "failed to convert delta for new tablet in schema change."
<< "res: " << res << ", "
<< "new_tablet: " << _new_tablet->full_name();
return res;
}
res = StorageEngine::instance()->txn_manager()->commit_txn(_new_tablet->data_dir()->get_meta(),
_req.partition_id, _req.txn_id, _new_tablet->tablet_id(),
_new_tablet->schema_hash(), _new_tablet->tablet_uid(),
_req.load_id, _new_rowset, false);
if (res != OLAP_SUCCESS && res != OLAP_ERR_PUSH_TRANSACTION_ALREADY_EXIST) {
LOG(WARNING) << "save pending rowset failed. rowset_id:"
<< _new_rowset->rowset_id();
return res;
}
}
#ifndef BE_TEST
PTabletInfo* tablet_info = tablet_vec->Add();
tablet_info->set_tablet_id(_tablet->tablet_id());
tablet_info->set_schema_hash(_tablet->schema_hash());
if (_new_tablet != nullptr) {
tablet_info = tablet_vec->Add();
tablet_info->set_tablet_id(_new_tablet->tablet_id());
tablet_info->set_schema_hash(_new_tablet->schema_hash());
}
#endif
_delta_written_success = true;
return OLAP_SUCCESS;
}
OLAPStatus DeltaWriter::cancel() {
DCHECK(!_is_init);
return OLAP_SUCCESS;
}
} // namespace doris
| 41.501992 | 119 | 0.635884 | [
"vector"
] |
d5ab0294ea5ea1e4847c59390715c28d4890ce01 | 5,442 | cpp | C++ | src/game/shared/tf/tf_weapon_bonesaw.cpp | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | 6 | 2022-01-23T09:40:33.000Z | 2022-03-20T20:53:25.000Z | src/game/shared/tf/tf_weapon_bonesaw.cpp | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | null | null | null | src/game/shared/tf/tf_weapon_bonesaw.cpp | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | 1 | 2022-02-06T21:05:23.000Z | 2022-02-06T21:05:23.000Z | //========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#include "cbase.h"
#include "tf_weapon_bonesaw.h"
#include "tf_weapon_medigun.h"
#ifdef GAME_DLL
#include "tf_player.h"
#else
#include "c_tf_player.h"
#endif
#define UBERSAW_CHARGE_POSEPARAM "syringe_charge_level"
//=============================================================================
//
// Weapon Bonesaw tables.
//
IMPLEMENT_NETWORKCLASS_ALIASED( TFBonesaw, DT_TFWeaponBonesaw )
BEGIN_NETWORK_TABLE( CTFBonesaw, DT_TFWeaponBonesaw )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFBonesaw )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_bonesaw, CTFBonesaw );
PRECACHE_WEAPON_REGISTER( tf_weapon_bonesaw );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFBonesaw::Activate( void )
{
BaseClass::Activate();
}
//-----------------------------------------------------------------------------
void CTFBonesaw::SecondaryAttack( void )
{
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( !pPlayer )
return;
#ifdef GAME_DLL
int iSpecialTaunt = 0;
CALL_ATTRIB_HOOK_INT( iSpecialTaunt, special_taunt );
if ( iSpecialTaunt )
{
pPlayer->Taunt( TAUNT_BASE_WEAPON );
return;
}
#endif
BaseClass::SecondaryAttack();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFBonesaw::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iActivity, char *szAnimExt )
{
if ( BaseClass::DefaultDeploy( szViewModel, szWeaponModel, iActivity, szAnimExt ) )
{
#ifdef CLIENT_DLL
UpdateChargePoseParam();
#endif
return true;
}
return false;
}
//-----------------------------------------------------------------------------
void CTFBonesaw::DoMeleeDamage( CBaseEntity* ent, trace_t& trace )
{
// We hit a target, take a head
CTFPlayer *pPlayer = ToTFPlayer( GetOwnerEntity() );
CTFPlayer *pVictim = ToTFPlayer( ent );
int iTakeHeads = 0;
CALL_ATTRIB_HOOK_INT( iTakeHeads, add_head_on_hit );
if ( pPlayer && pVictim && iTakeHeads && (pVictim->GetTeamNumber() != pPlayer->GetTeamNumber() ) )
{
int iDecaps = pPlayer->m_Shared.GetDecapitations() + 1;
pPlayer->m_Shared.SetDecapitations( iDecaps );
pPlayer->TeamFortress_SetSpeed();
}
BaseClass::DoMeleeDamage( ent, trace );
}
//-----------------------------------------------------------------------------
float CTFBonesaw::GetBoneSawSpeedMod( void )
{
const int MAX_HEADS_FOR_SPEED = 10;
// Calculate Speed based on heads
CTFPlayer *pPlayer = ToTFPlayer( GetOwnerEntity() );
int iTakeHeads = 0;
CALL_ATTRIB_HOOK_INT( iTakeHeads, add_head_on_hit );
if ( pPlayer && iTakeHeads )
{
int iDecaps = Min( MAX_HEADS_FOR_SPEED, pPlayer->m_Shared.GetDecapitations() );
return 1.f + (iDecaps * 0.05f);
}
return 1.f;
}
//-----------------------------------------------------------------------------
int CTFBonesaw::GetCount( void )
{
CTFPlayer *pOwner = ToTFPlayer( GetOwner() );
if ( !pOwner )
return 0;
return pOwner->m_Shared.GetDecapitations();
}
#ifdef CLIENT_DLL
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFBonesaw::OnDataChanged( DataUpdateType_t updateType )
{
BaseClass::OnDataChanged( updateType );
UpdateChargePoseParam();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFBonesaw::UpdateAttachmentModels( void )
{
BaseClass::UpdateAttachmentModels();
if ( m_hViewmodelAttachment )
{
m_iUberChargePoseParam = m_hViewmodelAttachment->LookupPoseParameter( m_hViewmodelAttachment->GetModelPtr(), UBERSAW_CHARGE_POSEPARAM );
}
else
{
m_iUberChargePoseParam = LookupPoseParameter( GetModelPtr(), UBERSAW_CHARGE_POSEPARAM );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFBonesaw::UpdateChargePoseParam( void )
{
if ( m_iUberChargePoseParam >= 0 )
{
CTFPlayer *pTFPlayer = ToTFPlayer( GetOwner() );
if ( pTFPlayer && pTFPlayer->IsPlayerClass( TF_CLASS_MEDIC ) )
{
CWeaponMedigun *pMedigun = (CWeaponMedigun *)pTFPlayer->Weapon_OwnsThisID( TF_WEAPON_MEDIGUN );
if ( pMedigun )
{
m_flChargeLevel = pMedigun->GetChargeLevel();
// On the local client, we push the pose parameters onto the attached model
if ( m_hViewmodelAttachment )
{
m_hViewmodelAttachment->SetPoseParameter( m_iUberChargePoseParam, pMedigun->GetChargeLevel() );
}
}
}
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFBonesaw::GetPoseParameters( CStudioHdr *pStudioHdr, float poseParameter[MAXSTUDIOPOSEPARAM] )
{
if ( !pStudioHdr )
return;
BaseClass::GetPoseParameters( pStudioHdr, poseParameter );
if ( m_iUberChargePoseParam >= 0 )
{
poseParameter[m_iUberChargePoseParam] = m_flChargeLevel;
}
}
#endif | 28.492147 | 138 | 0.538956 | [
"model"
] |
d5b07fa21fcbeb867731b4fc3054f322d1c2d36a | 1,321 | cpp | C++ | source/scenes/dsItem2D.cpp | nczeroshift/entropia | 26e71e8c2acf608d3050482e2ce450635f51bb64 | [
"MIT"
] | null | null | null | source/scenes/dsItem2D.cpp | nczeroshift/entropia | 26e71e8c2acf608d3050482e2ce450635f51bb64 | [
"MIT"
] | null | null | null | source/scenes/dsItem2D.cpp | nczeroshift/entropia | 26e71e8c2acf608d3050482e2ce450635f51bb64 | [
"MIT"
] | null | null | null |
#include "dsItem2D.h"
#include "../dsUtils.h"
dsItem2D::dsItem2D(DS::Data * data) : DS::Stage(data), m_Alpha(255), m_ScaleX(1.0), m_ScaleY(1.0){
}
dsItem2D::~dsItem2D() {
}
void dsItem2D::Load() {
}
void dsItem2D::Update(DS::StageProxy * proxy, double start, double end, double time) {
const double off = time - start;
m_CurrentX = m_X.GetValue(off);
m_CurrentY = m_Y.GetValue(off);
m_CurrentWidth = m_Width.GetValue(off);
m_CurrentHeight = m_Height.GetValue(off);
m_CurrentAlpha = m_Alpha.GetValue(off);
m_CurrentScaleX = m_ScaleX.GetValue(off);
m_CurrentScaleY = m_ScaleY.GetValue(off);
}
void dsItem2D::Render(DS::StageProxy * proxy, double start, double end, double time) {
}
void dsItem2D::Parse(const JSONObject & node) {
if (node.find("x") != node.end())
m_X.Parse(*node.find("x")->second);
if (node.find("y") != node.end())
m_Y.Parse(*node.find("y")->second);
if (node.find("sx") != node.end())
m_ScaleX.Parse(*node.find("sx")->second);
if (node.find("sy") != node.end())
m_ScaleY.Parse(*node.find("sy")->second);
if (node.find("width") != node.end())
m_Width.Parse(*node.find("width")->second);
if (node.find("height") != node.end())
m_Height.Parse(*node.find("height")->second);
if (node.find("alpha") != node.end())
m_Alpha.Parse(*node.find("alpha")->second);
} | 24.462963 | 98 | 0.660863 | [
"render"
] |
d5b332c114daa6f893be60869eec1e9722e4c56e | 19,476 | cpp | C++ | Extensions/GlyphRift/RiftHMD.cpp | zgpxgame/hieroglyph3 | bb1c59d82a69062bb76431b691fbcb381930768a | [
"MIT"
] | 25 | 2017-08-05T07:29:00.000Z | 2022-02-02T06:28:27.000Z | Extensions/GlyphRift/RiftHMD.cpp | zgpxgame/hieroglyph3 | bb1c59d82a69062bb76431b691fbcb381930768a | [
"MIT"
] | null | null | null | Extensions/GlyphRift/RiftHMD.cpp | zgpxgame/hieroglyph3 | bb1c59d82a69062bb76431b691fbcb381930768a | [
"MIT"
] | 9 | 2018-07-14T08:40:29.000Z | 2021-03-19T08:51:30.000Z | //--------------------------------------------------------------------------------
// This file is a portion of the Hieroglyph 3 Rendering Engine. It is distributed
// under the MIT License, available in the root of this distribution and
// at the following URL:
//
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) Jason Zink
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
#include "GlyphRift/RiftHMD.h"
#include <stdexcept>
// Include the Oculus SDK
#define OVR_D3D_VERSION 11
#include "OVR_CAPI_D3D.h"
//--------------------------------------------------------------------------------
#include "Extras/OVR_Math.h"
#include "RendererDX11.h"
#include "SwapChainDX11.h"
#include "Texture2dDX11.h"
#include "RenderTargetViewDX11.h"
#include "ShaderResourceViewDX11.h"
#include "Log.h"
#include "EvtErrorMessage.h"
#include "EventManager.h"
//--------------------------------------------------------------------------------
using namespace Glyph3;
//--------------------------------------------------------------------------------
struct RiftHMD::Impl
{
Impl( RiftManagerPtr RiftMgr ) :
m_RiftMgr( RiftMgr ),
m_hmd( nullptr ),
frame( 0 ),
mirrorTexture( nullptr )
{
// Create the first device available. If it isn't available then we throw an
// exception to let the user know.
ovrResult result = ovr_Create( &m_hmd, &m_luid );
if ( !m_hmd ) {
Log::Get().Write( L"Unable to find hardware Rift device!" );
throw std::exception( "No HMD Devices were found!" );
}
ovrHmdDesc hmdDesc = ovr_GetHmdDesc( m_hmd );
// Initialize FovSideTanMax, which allows us to change all Fov sides at once - Fov
// starts at default and is clamped to this value.
float FovSideTanLimit = OVR::FovPort::Max( hmdDesc.MaxEyeFov[0], hmdDesc.MaxEyeFov[1] ).GetMaxSideTan();
float FovSideTanMax = OVR::FovPort::Max( hmdDesc.DefaultEyeFov[0], hmdDesc.DefaultEyeFov[1] ).GetMaxSideTan();
// Clamp Fov based on our dynamically adjustable FovSideTanMax.
// Most apps should use the default, but reducing Fov does reduce rendering cost.
eyeFov[0] = OVR::FovPort::Min( hmdDesc.DefaultEyeFov[0], OVR::FovPort(FovSideTanMax) );
eyeFov[1] = OVR::FovPort::Min( hmdDesc.DefaultEyeFov[1], OVR::FovPort(FovSideTanMax) );
// Initialize the frame time for future delta calculations.
last_frame_time = ovr_GetTimeInSeconds();
}
//--------------------------------------------------------------------------------
~Impl()
{
if ( mirrorTexture != nullptr ) {
ovr_DestroyMirrorTexture( m_hmd, mirrorTexture );
}
for ( int eye = 0; eye < 2; ++eye ) {
if ( textureSets[eye] != nullptr ) {
ovr_DestroyTextureSwapChain( m_hmd, textureSets[eye] );
}
}
if ( m_hmd ) {
ovr_Destroy( m_hmd );
m_hmd = nullptr;
}
}
//--------------------------------------------------------------------------------
unsigned int HmdDisplayWidth()
{
ovrHmdDesc hmdDesc = ovr_GetHmdDesc( m_hmd );
return hmdDesc.Resolution.w;
}
//--------------------------------------------------------------------------------
unsigned int HmdDisplayHeight()
{
ovrHmdDesc hmdDesc = ovr_GetHmdDesc( m_hmd );
return hmdDesc.Resolution.h;
}
//--------------------------------------------------------------------------------
unsigned int DesiredEyeTextureWidth()
{
// Get the desired texture sizes for the render targets. Note that these are
// typically larger than the resolution of the display panel itself.
ovrHmdDesc hmdDesc = ovr_GetHmdDesc( m_hmd );
OVR::Sizei tex0Size = ovr_GetFovTextureSize( m_hmd, ovrEye_Left, hmdDesc.DefaultEyeFov[ovrEye_Left], 1.0f );
OVR::Sizei tex1Size = ovr_GetFovTextureSize( m_hmd, ovrEye_Right, hmdDesc.DefaultEyeFov[ovrEye_Right], 1.0f );
return max( tex0Size.w, tex1Size.w );
}
//--------------------------------------------------------------------------------
unsigned int DesiredEyeTextureHeight()
{
// Get the desired texture sizes for the render targets. Note that these are
// typically larger than the resolution of the display panel itself.
ovrHmdDesc hmdDesc = ovr_GetHmdDesc( m_hmd );
OVR::Sizei tex0Size = ovr_GetFovTextureSize( m_hmd, ovrEye_Left, hmdDesc.DefaultEyeFov[ovrEye_Left], 1.0f );
OVR::Sizei tex1Size = ovr_GetFovTextureSize( m_hmd, ovrEye_Right, hmdDesc.DefaultEyeFov[ovrEye_Right], 1.0f );
return max( tex0Size.h, tex1Size.h );
}
//--------------------------------------------------------------------------------
void ReadEyeData()
{
// Get both eye poses simultaneously, with IPD offset already included.
ovrVector3f HmdToEyeViewOffset[2] = { eyeRenderDesc[0].HmdToEyeOffset,
eyeRenderDesc[1].HmdToEyeOffset };
double timing = ovr_GetPredictedDisplayTime( m_hmd, 0 );
ovrTrackingState hmdState = ovr_GetTrackingState( m_hmd, timing, ovrTrue );
ovr_CalcEyePoses( hmdState.HeadPose.ThePose, HmdToEyeViewOffset, eyePose );
// Update the layer information with our new pose information.
for ( int eye = 0; eye < 2; eye++ ) {
layer.RenderPose[eye] = eyePose[eye];
}
}
//--------------------------------------------------------------------------------
Matrix3f GetOrientation( double time )
{
// Query the HMD for the sensor state at a given time. "0.0" means "most recent time".
// The last parameter indicates if this is the call to get the tracking state
// immediately before rendering, which in this case it is not. That is in the
// ReadEyeData function above.
ovrTrackingState ts = ovr_GetTrackingState( m_hmd, time, ovrFalse );
Matrix3f orientation;
orientation.MakeIdentity();
if ( ts.StatusFlags & ( ovrStatus_OrientationTracked | ovrStatus_PositionTracked ) )
{
float yaw, eyePitch, eyeRoll = 0.0f;
// Get the pos of the head, and then extract the rotation angles
OVR::Posef pose = ts.HeadPose.ThePose;
pose.Rotation.GetEulerAngles<OVR::Axis_Y, OVR::Axis_X, OVR::Axis_Z>(&yaw, &eyePitch, &eyeRoll);
// Apply those angles to our rotation matrix
orientation.Rotation( Vector3f( eyePitch, yaw, -eyeRoll ) );
}
return( orientation );
}
//--------------------------------------------------------------------------------
Matrix4f GetPerspectiveFov( unsigned int eye, float zn, float zf )
{
// This method is based on the perspective matrix in the Oculus SDK. It is
// reimplemented here to allow direct initialization of the Hieroglyph 3
// specific matrix object.
Matrix4f p;
float xScale = 2.0f / ( eyeFov[eye].LeftTan + eyeFov[eye].RightTan );
float xOffset = ( eyeFov[eye].LeftTan - eyeFov[eye].RightTan ) * xScale * 0.5f;
float yScale = 2.0f / ( eyeFov[eye].UpTan + eyeFov[eye].DownTan );
float yOffset = ( eyeFov[eye].UpTan - eyeFov[eye].DownTan ) * yScale * 0.5f;
// row 0
p[ 0] = xScale;
p[ 1] = 0.0f;
p[ 2] = 0.0f;
p[ 3] = 0.0f;
// row 1
p[ 4] = 0.0f;
p[ 5] = yScale;
p[ 6] = 0.0f;
p[ 7] = 0.0f;
// row 2
p[ 8] = xOffset;
p[ 9] = -yOffset;
p[10] = zf / ( zf-zn );
p[11] = 1.0f;
// row 3
p[12] = 0.0f;
p[13] = 0.0f;
p[14] = -zn*zf / ( zf-zn );
p[15] = 0.0f;
return p;
}
//--------------------------------------------------------------------------------
Matrix4f GetEyeTranslation( unsigned int eye )
{
return Matrix4f::TranslationMatrix( eyeRenderDesc[eye].HmdToEyeOffset.x,
eyeRenderDesc[eye].HmdToEyeOffset.y,
eyeRenderDesc[eye].HmdToEyeOffset.z );
}
//--------------------------------------------------------------------------------
Matrix4f GetEyeSpatialState( unsigned int eye )
{
float yaw, eyePitch, eyeRoll = 0.0f;
OVR::Posef pose = eyePose[eye];
pose.Rotation.GetEulerAngles<OVR::Axis_Z, OVR::Axis_X, OVR::Axis_Y>(&eyeRoll, &eyePitch, &yaw);
// Apply those angles to our rotation matrix
Matrix4f orientation =
Matrix4f::RotationMatrixZ( -eyeRoll ) *
Matrix4f::RotationMatrixX( eyePitch ) *
Matrix4f::RotationMatrixY( yaw );
Matrix4f translation = Matrix4f::TranslationMatrix( -5.0f*pose.Translation.x, -5.0f*pose.Translation.y, 5.0f*pose.Translation.z );
return translation * orientation;
}
//--------------------------------------------------------------------------------
float BeginFrame()
{
// Increment the frame number, and then read the predicted time for the next
// frame. We store the predicted frame time for calculating the delta time
// used in the simulation.
frame++;
double frame_time = ovr_GetPredictedDisplayTime( m_hmd, frame );
// The delta time is returned to the application, and is subsequently used
// to update the state of the application.
float delta = static_cast<float>( frame_time - last_frame_time );
last_frame_time = frame_time;
// The eye pose is read out from the API using RiftHMD::ReadEyeData() which
// collects the information for both eyes simultaneously.
ReadEyeData();
return( delta );
}
//--------------------------------------------------------------------------------
void EndFrame()
{
// Commit the current swap chain buffers for each eye.
//
// TODO: It may be worth it to move this to its own method in RiftHMD (something
// like RiftHMD::EyeRenderComplete() or similar) if there is a performance
// difference. This needs to be tested, then either remove this note, or
// move the commit calls.
ovr_CommitTextureSwapChain( m_hmd, textureSets[ovrEye_Left] );
ovr_CommitTextureSwapChain( m_hmd, textureSets[ovrEye_Right] );
const unsigned int layer_count = 1;
ovrLayerHeader* headers[layer_count] = { &layer.Header };
ovrResult result = ovr_SubmitFrame( m_hmd, frame, nullptr, headers, layer_count );
}
//--------------------------------------------------------------------------------
ovrTextureFormat TranslateDXGItoOVR( DXGI_FORMAT format )
{
ovrTextureFormat ovrFormat = ovrTextureFormat::OVR_FORMAT_UNKNOWN;
switch ( format )
{
case DXGI_FORMAT_B5G6R5_UNORM:
ovrFormat = OVR_FORMAT_B5G6R5_UNORM; ///< Not currently supported on PC. Would require a DirectX 11.1 device.
break;
case DXGI_FORMAT_B5G5R5A1_UNORM:
ovrFormat = OVR_FORMAT_B5G5R5A1_UNORM; ///< Not currently supported on PC. Would require a DirectX 11.1 device.
break;
case DXGI_FORMAT_B4G4R4A4_UNORM:
ovrFormat = OVR_FORMAT_B4G4R4A4_UNORM; ///< Not currently supported on PC. Would require a DirectX 11.1 device.
break;
case DXGI_FORMAT_R8G8B8A8_UNORM:
ovrFormat = OVR_FORMAT_R8G8B8A8_UNORM;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
ovrFormat = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM:
ovrFormat = OVR_FORMAT_B8G8R8A8_UNORM;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
ovrFormat = OVR_FORMAT_B8G8R8A8_UNORM_SRGB; ///< Not supported for OpenGL applications
break;
case DXGI_FORMAT_B8G8R8X8_UNORM:
ovrFormat = OVR_FORMAT_B8G8R8X8_UNORM; ///< Not supported for OpenGL applications
break;
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
ovrFormat = OVR_FORMAT_B8G8R8X8_UNORM_SRGB; ///< Not supported for OpenGL applications
break;
case DXGI_FORMAT_R16G16B16A16_FLOAT:
ovrFormat = OVR_FORMAT_R16G16B16A16_FLOAT;
break;
case DXGI_FORMAT_D16_UNORM:
ovrFormat = OVR_FORMAT_D16_UNORM;
break;
case DXGI_FORMAT_D24_UNORM_S8_UINT:
ovrFormat = OVR_FORMAT_D24_UNORM_S8_UINT;
break;
case DXGI_FORMAT_D32_FLOAT:
ovrFormat = OVR_FORMAT_D32_FLOAT;
break;
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
ovrFormat = OVR_FORMAT_D32_FLOAT_S8X24_UINT;
break;
}
return ovrFormat;
}
//--------------------------------------------------------------------------------
void ConfigureRendering( unsigned int max_w, unsigned int max_h, DXGI_FORMAT format )
{
// Get the rendering description for each eye, based on an input FOV.
// TODO: This FOV calculation could be modified to not use the default...
ovrHmdDesc hmdDesc = ovr_GetHmdDesc( m_hmd );
eyeRenderDesc[0] = ovr_GetRenderDesc( m_hmd, ovrEye_Left, hmdDesc.DefaultEyeFov[0] );
eyeRenderDesc[1] = ovr_GetRenderDesc( m_hmd, ovrEye_Right, hmdDesc.DefaultEyeFov[1] );
// Get the desired texture sizes for the eye render targets. Note that these
// are typically larger than the resolution of the HMD's display panel itself.
unsigned int width = min( DesiredEyeTextureWidth(), max_w );
unsigned int height = min( DesiredEyeTextureHeight(), max_h );
// Create two render targets - one for each eye. These are created with both
// render target and shader resource bind points so that they can be used by
// the Oculus SDK to do the distortion rendering at the end of the frame.
textureSets[0] = nullptr;
textureSets[1] = nullptr;
ovrTextureSwapChainDesc config;
config.Type = ovrTexture_2D;
config.Format = TranslateDXGItoOVR( format );
config.ArraySize = 1;
config.Width = width;
config.Height = height;
config.MipLevels = 1;
config.SampleCount = 1;
config.StaticImage = ovrFalse;
config.MiscFlags = ovrTextureMisc_None;
config.BindFlags = ovrTextureBind_DX_RenderTarget;
if ( ovr_CreateTextureSwapChainDX( m_hmd, RendererDX11::Get()->GetDevice(), &config, &textureSets[0] ) != ovrSuccess ) {
Log::Get().Write( L"ERROR: Could not create swap texture sets!" );
}
if ( ovr_CreateTextureSwapChainDX( m_hmd, RendererDX11::Get()->GetDevice(), &config, &textureSets[1] ) != ovrSuccess ) {
Log::Get().Write( L"ERROR: Could not create swap texture sets!" );
}
// Create render target views for each of the texture surfaces in our texture sets.
// We just store those in a vector for reference later on, with one vector for
// each eye.
for ( unsigned int eye = 0; eye < 2; ++eye )
{
int count = 0;
ovr_GetTextureSwapChainLength( m_hmd, textureSets[eye], &count );
for ( int i = 0; i < count; ++i )
{
ID3D11Texture2D* texture = nullptr;
ovr_GetTextureSwapChainBufferDX( m_hmd, textureSets[eye], i, IID_PPV_ARGS(&texture));
ResourcePtr resource = RendererDX11::Get()->LoadTexture( texture );
resource->m_iResourceRTV =
RendererDX11::Get()->CreateRenderTargetView(resource->m_iResource, nullptr );
textureRTVs[eye].push_back( resource );
texture->Release();
}
}
// Initialize a single full screen FOV layer.
layer.Header.Type = ovrLayerType_EyeFov;
layer.Header.Flags = 0;
layer.ColorTexture[0] = textureSets[0];
layer.ColorTexture[1] = textureSets[1];
layer.Fov[0] = eyeRenderDesc[0].Fov;
layer.Fov[1] = eyeRenderDesc[1].Fov;
layer.Viewport[0] = OVR::Recti(0, 0, width, height);
layer.Viewport[1] = OVR::Recti(0, 0, width, height);
}
//--------------------------------------------------------------------------------
ResourcePtr GetEyeTexture( unsigned int eye )
{
assert( eye == 0 || eye == 1 );
int currentIndex = 0;
ovr_GetTextureSwapChainCurrentIndex( m_hmd, textureSets[eye], ¤tIndex );
return textureRTVs[eye][currentIndex];
}
//--------------------------------------------------------------------------------
ResourcePtr GetMirrorTexture( unsigned int w, unsigned int h, DXGI_FORMAT format )
{
// If the texture already exists, then delete it.
if ( mirrorTexture != nullptr )
{
ovr_DestroyMirrorTexture( m_hmd, mirrorTexture );
mirrorTexture = nullptr;
}
// Ensure that an appropriately sized mirror texture is available.
if ( mirrorTexture == nullptr )
{
ovrMirrorTextureDesc config = { };
config.Format = TranslateDXGItoOVR( format );
config.Width = w;
config.Height = h;
config.MiscFlags = 0;
ovr_CreateMirrorTextureDX( m_hmd, RendererDX11::Get()->GetDevice(), &config, &mirrorTexture );
}
ID3D11Texture2D* tex = nullptr;
ovr_GetMirrorTextureBufferDX( m_hmd, mirrorTexture, IID_PPV_ARGS(&tex));
ResourcePtr resource = RendererDX11::Get()->LoadTexture( tex );
tex->Release();
return resource;
}
//--------------------------------------------------------------------------------
RiftManagerPtr m_RiftMgr;
ovrSession m_hmd;
ovrGraphicsLuid m_luid;
ovrFovPort eyeFov[2];
ovrEyeRenderDesc eyeRenderDesc[2];
ovrPosef eyePose[2];
ovrLayerEyeFov layer;
ovrTextureSwapChain textureSets[2];
std::vector<ResourcePtr> textureRTVs[2];
ovrMirrorTexture mirrorTexture;
unsigned int frame;
double last_frame_time;
};
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
RiftHMD::RiftHMD( RiftManagerPtr RiftMgr ) :
m_pImpl( new Impl( RiftMgr ) )
{
}
//--------------------------------------------------------------------------------
RiftHMD::~RiftHMD()
{
delete m_pImpl;
}
//--------------------------------------------------------------------------------
unsigned int RiftHMD::HmdDisplayWidth()
{
return m_pImpl->HmdDisplayWidth();
}
//--------------------------------------------------------------------------------
unsigned int RiftHMD::HmdDisplayHeight()
{
return m_pImpl->HmdDisplayHeight();
}
//--------------------------------------------------------------------------------
unsigned int RiftHMD::DesiredEyeTextureWidth()
{
return m_pImpl->DesiredEyeTextureWidth();
}
//--------------------------------------------------------------------------------
unsigned int RiftHMD::DesiredEyeTextureHeight()
{
return m_pImpl->DesiredEyeTextureHeight();
}
//--------------------------------------------------------------------------------
void RiftHMD::ReadEyeData()
{
return m_pImpl->ReadEyeData();
}
//--------------------------------------------------------------------------------
Matrix3f RiftHMD::GetOrientation( double time )
{
return m_pImpl->GetOrientation( time );
}
//--------------------------------------------------------------------------------
Matrix4f RiftHMD::GetPerspectiveFov( unsigned int eye, float zn, float zf )
{
return m_pImpl->GetPerspectiveFov( eye, zn, zf );
}
//--------------------------------------------------------------------------------
Matrix4f RiftHMD::GetEyeTranslation( unsigned int eye )
{
return m_pImpl->GetEyeTranslation( eye );
}
//--------------------------------------------------------------------------------
Matrix4f RiftHMD::GetEyeSpatialState( unsigned int eye )
{
return m_pImpl->GetEyeSpatialState( eye );
}
//--------------------------------------------------------------------------------
float RiftHMD::BeginFrame()
{
return m_pImpl->BeginFrame();
}
//--------------------------------------------------------------------------------
void RiftHMD::EndFrame()
{
return m_pImpl->EndFrame();
}
//--------------------------------------------------------------------------------
void RiftHMD::ConfigureRendering( unsigned int max_w, unsigned int max_h, DXGI_FORMAT format )
{
return m_pImpl->ConfigureRendering( max_w, max_h, format );
}
//--------------------------------------------------------------------------------
ResourcePtr RiftHMD::GetEyeTexture( unsigned int eye )
{
return m_pImpl->GetEyeTexture( eye );
}
//--------------------------------------------------------------------------------
ResourcePtr RiftHMD::GetMirrorTexture( unsigned int w, unsigned int h, DXGI_FORMAT format )
{
return m_pImpl->GetMirrorTexture( w, h, format );
}
//-------------------------------------------------------------------------------- | 34.716578 | 132 | 0.588417 | [
"render",
"object",
"vector"
] |
d5b60a31014e1275b9ffe6f1a1f83d0b79b949a5 | 13,851 | cpp | C++ | media_driver/agnostic/common/vp/hal/vphal_mdf_wrapper.cpp | ashakhno/media-driver | 79c20b78a539afdb55b5fd0006e959f92c12fa64 | [
"Intel",
"BSD-3-Clause",
"MIT"
] | 660 | 2017-11-21T15:55:52.000Z | 2022-03-31T06:31:00.000Z | media_driver/agnostic/common/vp/hal/vphal_mdf_wrapper.cpp | ashakhno/media-driver | 79c20b78a539afdb55b5fd0006e959f92c12fa64 | [
"Intel",
"BSD-3-Clause",
"MIT"
] | 1,070 | 2017-12-01T00:26:10.000Z | 2022-03-31T17:55:26.000Z | media_driver/agnostic/common/vp/hal/vphal_mdf_wrapper.cpp | ashakhno/media-driver | 79c20b78a539afdb55b5fd0006e959f92c12fa64 | [
"Intel",
"BSD-3-Clause",
"MIT"
] | 309 | 2017-11-30T08:34:09.000Z | 2022-03-30T18:52:07.000Z | /*
* Copyright (c) 2009-2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file vphal_mdf_wrapper.cpp
//! \brief Abstraction for MDF related operations.
//! \details It is a thin wrapper layer based on MDF APIs.
//!
#include "vphal_mdf_wrapper.h"
#include <algorithm>
#include <cstdio>
void EventManager::OnEventAvailable(CmEvent *event, const std::string &name)
{
AddEvent(name, event);
}
void EventManager::AddEvent(const std::string &name, CmEvent *event)
{
if (mEventCount >= (128 * 1024) / sizeof(CmEvent))
{
if (mReport)
{
Profiling();
}
Clear();
}
mEventMap[name].push_back(event);
mLastEvent = event;
mEventCount++;
}
void EventManager::Clear()
{
VPHAL_RENDER_CHK_NULL_NO_STATUS_RETURN(m_cmContext);
CmQueue *queue = m_cmContext->GetCmQueue();
VPHAL_RENDER_CHK_NULL_NO_STATUS_RETURN(queue);
for (auto it : mEventMap)
{
for (CmEvent *event : it.second)
{
queue->DestroyEvent(event);
}
}
mEventMap.clear();
mEventCount = 0;
mLastEvent = nullptr;
}
void EventManager::Profiling() const
{
VPHAL_RENDER_NORMALMESSAGE("------------------------%s Profiling Report------------------------\n", mOwner.c_str());
for (auto it : mEventMap)
{
int count = 0;
double totalTimeInMS = 0.0;
for (CmEvent *event : it.second)
{
uint64_t executionTimeInNS = 0;
int result = event->GetExecutionTime(executionTimeInNS);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: CM GetExecutionTime error: %d\n", it.first.c_str(), result);
continue;
}
totalTimeInMS += executionTimeInNS / 1000000.0;
count++;
}
VPHAL_RENDER_NORMALMESSAGE("[%s]: execution count %llu, average time %f ms.\n", it.first.c_str(), it.second.size(), totalTimeInMS / count);
}
VPHAL_RENDER_NORMALMESSAGE("------------------------%s Profiling Report End------------------------\n", mOwner.c_str());
}
CmEvent* EventManager::GetLastEvent() const
{
return mLastEvent;
}
CmContext::CmContext(PMOS_CONTEXT OsContext) :
mRefCount(0),
mCmDevice(nullptr),
mCmQueue(nullptr),
mCmVebox(nullptr),
mBatchTask(nullptr),
mHasBatchedTask(false),
mConditionalBatchBuffer(nullptr),
mCondParam({ 0 }),
mEventListener(nullptr)
{
VPHAL_RENDER_ASSERT(OsContext);
const unsigned int MDF_DEVICE_CREATE_OPTION =
((CM_DEVICE_CREATE_OPTION_SCRATCH_SPACE_DISABLE) |
(CM_DEVICE_CONFIG_DSH_DISABLE_MASK) |
(CM_DEVICE_CONFIG_TASK_NUM_16 << CM_DEVICE_CONFIG_TASK_NUM_OFFSET) |
(CM_DEVICE_CONFIG_MEDIA_RESET_ENABLE) |
(CM_DEVICE_CONFIG_EXTRA_TASK_NUM_4 << CM_DEVICE_CONFIG_EXTRA_TASK_NUM_OFFSET) |
(CM_DEVICE_CONFIG_GPUCONTEXT_ENABLE) |
(32 << CM_DEVICE_CONFIG_KERNELBINARYGSH_OFFSET));
int result = CreateCmDevice(OsContext, mCmDevice, MDF_DEVICE_CREATE_OPTION);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("CmDevice creation error %d\n", result);
return;
}
result = mCmDevice->CreateQueue(mCmQueue);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("CmQueue creation error %d\n", result);
return;
}
result = mCmDevice->CreateVebox(mCmVebox);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("CmVebox creation error %d\n", result);
return;
}
#if (_DEBUG || _RELEASE_INTERNAL)
result = mCmDevice->InitPrintBuffer(32768);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("Init printf error: %d\n", result);
return;
}
#endif
result = mCmDevice->CreateTask(mBatchTask);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("Create batch task error: %d\n", result);
return;
}
}
CmKernel* CmContext::CloneKernel(CmKernel *kernel)
{
auto it = std::find(mAddedKernels.begin(), mAddedKernels.end(), kernel);
if (it != mAddedKernels.end())
{
CmKernel *newKernel = nullptr;
int result = mCmDevice->CloneKernel(newKernel, kernel);
if (result != CM_SUCCESS)
{
// Clone kernel failed, try to use the old one.
VPHAL_RENDER_ASSERTMESSAGE("Clone kernel failed: %d\n", result);
return kernel;
}
mKernelsToPurge.push_back(newKernel);
return newKernel;
}
else
{
return kernel;
}
}
void CmContext::BatchKernel(CmKernel *kernel, CmThreadSpace *threadSpace, bool bFence)
{
int result;
if (mConditionalBatchBuffer && mAddedKernels.empty())
{
result = mBatchTask->AddConditionalEnd(mConditionalBatchBuffer->GetCmSurfaceIndex(), 0, &mCondParam);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("Batch task AddConditionalEnd error: %d\n", result);
return;
}
}
if (bFence)
{
result = mBatchTask->AddSync();
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("Batch task add sync error: %d\n", result);
return;
}
}
result = mBatchTask->AddKernel(kernel);
if (result == CM_EXCEED_MAX_KERNEL_PER_ENQUEUE)
{
// Reach max kernels per task, flush and try again.
bool needAddBack = false;
if (mKernelsToPurge.back() == kernel)
{
mKernelsToPurge.pop_back();
needAddBack = true;
}
FlushBatchTask(false);
BatchKernel(kernel, threadSpace, false);
if (needAddBack)
{
mKernelsToPurge.push_back(kernel);
}
return;
}
else if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("Batch task add sync error: %d\n", result);
return;
}
mAddedKernels.push_back(kernel);
mThreadSpacesToPurge.push_back(threadSpace);
mHasBatchedTask = true;
}
void CmContext::FlushBatchTask(bool waitForFinish)
{
if (mAddedKernels.empty())
{
return;
}
EnqueueTask(mBatchTask, nullptr, "BatchTask", waitForFinish);
for(auto it : mThreadSpacesToPurge)
{
mCmDevice->DestroyThreadSpace(it);
}
for(auto it : mKernelsToPurge)
{
mCmDevice->DestroyKernel(it);
}
mThreadSpacesToPurge.clear();
mKernelsToPurge.clear();
mAddedKernels.clear();
mBatchTask->Reset();
}
void CmContext::RunSingleKernel(
CmKernel *kernel,
CmThreadSpace *threadSpace,
const std::string &name,
bool waitForFinish)
{
FlushBatchTask(false);
CmTask *task = nullptr;
int result = mCmDevice->CreateTask(task);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: CmDevice CreateTask error: %d\n", name.c_str(), result);
return;
}
if (mConditionalBatchBuffer)
{
result = task->AddConditionalEnd(mConditionalBatchBuffer->GetCmSurfaceIndex(), 0, &mCondParam);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: AddConditionalEnd error: %d\n", name.c_str(), result);
mCmDevice->DestroyTask(task);
return;
}
}
result = task->AddKernel(kernel);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: CmDevice AddKernel error: %d\n", name.c_str(), result);
mCmDevice->DestroyTask(task);
return;
}
EnqueueTask(task, threadSpace, name, waitForFinish);
}
void CmContext::EnqueueTask(CmTask *task, CmThreadSpace *threadSpace, const std::string &name, bool waitForFinish)
{
CmEvent *event = nullptr;
int result = mCmQueue->Enqueue(task, event, threadSpace);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: CmDevice enqueue error: %d\n", name.c_str(), result);
return;
}
if (waitForFinish)
{
event->WaitForTaskFinished(-1);
#if (_DEBUG || _RELEASE_INTERNAL)
result = mCmDevice->FlushPrintBuffer();
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: Flush printf buffer error: %d", name.c_str(), result);
}
std::fflush(stdout);
#endif
}
if (mEventListener)
{
mEventListener->OnEventAvailable(event, name);
}
}
void CmContext::Destroy()
{
FlushBatchTask(false);
if (mBatchTask)
{
mCmDevice->DestroyTask(mBatchTask);
}
if (mCmVebox)
{
mCmDevice->DestroyVebox(mCmVebox);
}
if (mCmDevice)
{
DestroyCmDevice(mCmDevice);
}
mBatchTask = nullptr;
mCmVebox = nullptr;
mCmDevice = nullptr;
}
CmContext::~CmContext()
{
Destroy();
}
VPCmRenderer::VPCmRenderer(const std::string &name, CmContext *cmContext) :
mName(name),
m_cmContext(cmContext),
mBatchDispatch(true),
mBlockingMode(false),
mEnableDump(false)
{
}
VPCmRenderer::~VPCmRenderer()
{
}
CmProgram* VPCmRenderer::LoadProgram(const std::string& binaryFileName)
{
std::ifstream isa(binaryFileName, std::ifstream::ate | std::ifstream::binary);
if (!isa.is_open())
{
VPHAL_RENDER_ASSERTMESSAGE("Error in opening ISA file: %s.\n", binaryFileName.c_str());
return nullptr;
}
int size = static_cast<int>(isa.tellg());
if (size == 0)
{
VPHAL_RENDER_ASSERTMESSAGE("Code size is 0.\n");
return nullptr;
}
isa.seekg(0, isa.beg);
std::vector<char> code(size);
isa.read(code.data(), size);
CmProgram *program = nullptr;
if (!m_cmContext)
{
return nullptr;
}
CmDevice *dev = m_cmContext->GetCmDevice();
if (!dev)
{
return nullptr;
}
int result = dev->LoadProgram(code.data(), size, program, "-nojitter");
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: CM LoadProgram error %d\n", mName.c_str(), result);
return nullptr;
}
return program;
}
CmProgram* VPCmRenderer::LoadProgram(const void *binary, int size)
{
if (!binary || size == 0)
{
VPHAL_RENDER_ASSERTMESSAGE("Invalid program to load.\n");
return nullptr;
}
CmProgram *program = nullptr;
if (!m_cmContext)
{
return nullptr;
}
CmDevice *dev = m_cmContext->GetCmDevice();
if (!dev)
{
return nullptr;
}
int result = dev->LoadProgram(const_cast<void *>(binary), size, program, "-nojitter");
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: CM LoadProgram error %d\n", mName.c_str(), result);
return nullptr;
}
return program;
}
void VPCmRenderer::Render(void *payload)
{
AttachPayload(payload);
std::string kernelName;
CmKernel *kernel = GetKernelToRun(kernelName);
if (!kernel)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: Did not find proper kernel to run\n", mName.c_str());
return;
}
int tsWidth, tsHeight, tsColor;
GetThreadSpaceDimension(tsWidth, tsHeight, tsColor);
if (!tsWidth || !tsHeight || !tsColor)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: Degenerate thread space, return immediately.\n", mName.c_str());
return;
}
VPHAL_RENDER_CHK_NULL_NO_STATUS_RETURN(m_cmContext);
CmThreadSpace *threadSpace = nullptr;
CmDevice *dev = m_cmContext->GetCmDevice();
VPHAL_RENDER_CHK_NULL_NO_STATUS_RETURN(dev);
int result = dev->CreateThreadSpace(tsWidth, tsHeight, threadSpace);
if (result != CM_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("[%s]: CM Create ThreadSpace error: %d\n", mName.c_str(), result);
return;
}
SetupThreadSpace(threadSpace, tsWidth, tsHeight, tsColor);
// We need to use CloneKernel API to add the same kernel multiple times into one task.
bool bBatch = mBatchDispatch && !mBlockingMode && !mEnableDump && !CannotAssociateThreadSpace();
if (bBatch)
{
kernel = m_cmContext->CloneKernel(kernel);
}
kernel->SetThreadCount(tsWidth * tsHeight * tsColor);
if (!CannotAssociateThreadSpace())
{
kernel->AssociateThreadSpace(threadSpace);
}
PrepareKernel(kernel);
if (bBatch)
{
m_cmContext->BatchKernel(kernel, threadSpace, NeedAddSync());
}
else
{
m_cmContext->RunSingleKernel(kernel, CannotAssociateThreadSpace() ? threadSpace : nullptr, kernelName, mBlockingMode);
dev->DestroyThreadSpace(threadSpace);
}
if (mEnableDump)
{
Dump();
}
AttachPayload(nullptr);
} | 27.212181 | 147 | 0.623782 | [
"render",
"vector"
] |
d5b8ef0bf0e2462366e16fc7e38ffd71ca6d8fc4 | 5,428 | cpp | C++ | clients/cpp-pistache-server/generated/model/PipelineRunImpllinks.cpp | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | clients/cpp-pistache-server/generated/model/PipelineRunImpllinks.cpp | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | clients/cpp-pistache-server/generated/model/PipelineRunImpllinks.cpp | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | /**
* Swaggy Jenkins
* Jenkins API clients generated from Swagger / Open API specification
*
* The version of the OpenAPI document: 1.1.2-pre.0
* Contact: blah@cliffano.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "PipelineRunImpllinks.h"
#include "Helpers.h"
#include <sstream>
namespace org::openapitools::server::model
{
PipelineRunImpllinks::PipelineRunImpllinks()
{
m_NodesIsSet = false;
m_LogIsSet = false;
m_SelfIsSet = false;
m_ActionsIsSet = false;
m_StepsIsSet = false;
m__class = "";
m__classIsSet = false;
}
void PipelineRunImpllinks::validate() const
{
std::stringstream msg;
if (!validate(msg))
{
throw org::openapitools::server::helpers::ValidationException(msg.str());
}
}
bool PipelineRunImpllinks::validate(std::stringstream& msg) const
{
return validate(msg, "");
}
bool PipelineRunImpllinks::validate(std::stringstream& msg, const std::string& pathPrefix) const
{
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "PipelineRunImpllinks" : pathPrefix;
return success;
}
bool PipelineRunImpllinks::operator==(const PipelineRunImpllinks& rhs) const
{
return
((!nodesIsSet() && !rhs.nodesIsSet()) || (nodesIsSet() && rhs.nodesIsSet() && getNodes() == rhs.getNodes())) &&
((!logIsSet() && !rhs.logIsSet()) || (logIsSet() && rhs.logIsSet() && getLog() == rhs.getLog())) &&
((!selfIsSet() && !rhs.selfIsSet()) || (selfIsSet() && rhs.selfIsSet() && getSelf() == rhs.getSelf())) &&
((!actionsIsSet() && !rhs.actionsIsSet()) || (actionsIsSet() && rhs.actionsIsSet() && getActions() == rhs.getActions())) &&
((!stepsIsSet() && !rhs.stepsIsSet()) || (stepsIsSet() && rhs.stepsIsSet() && getSteps() == rhs.getSteps())) &&
((!r_classIsSet() && !rhs.r_classIsSet()) || (r_classIsSet() && rhs.r_classIsSet() && getClass() == rhs.getClass()))
;
}
bool PipelineRunImpllinks::operator!=(const PipelineRunImpllinks& rhs) const
{
return !(*this == rhs);
}
void to_json(nlohmann::json& j, const PipelineRunImpllinks& o)
{
j = nlohmann::json();
if(o.nodesIsSet())
j["nodes"] = o.m_Nodes;
if(o.logIsSet())
j["log"] = o.m_Log;
if(o.selfIsSet())
j["self"] = o.m_Self;
if(o.actionsIsSet())
j["actions"] = o.m_Actions;
if(o.stepsIsSet())
j["steps"] = o.m_Steps;
if(o.r_classIsSet())
j["_class"] = o.m__class;
}
void from_json(const nlohmann::json& j, PipelineRunImpllinks& o)
{
if(j.find("nodes") != j.end())
{
j.at("nodes").get_to(o.m_Nodes);
o.m_NodesIsSet = true;
}
if(j.find("log") != j.end())
{
j.at("log").get_to(o.m_Log);
o.m_LogIsSet = true;
}
if(j.find("self") != j.end())
{
j.at("self").get_to(o.m_Self);
o.m_SelfIsSet = true;
}
if(j.find("actions") != j.end())
{
j.at("actions").get_to(o.m_Actions);
o.m_ActionsIsSet = true;
}
if(j.find("steps") != j.end())
{
j.at("steps").get_to(o.m_Steps);
o.m_StepsIsSet = true;
}
if(j.find("_class") != j.end())
{
j.at("_class").get_to(o.m__class);
o.m__classIsSet = true;
}
}
Link PipelineRunImpllinks::getNodes() const
{
return m_Nodes;
}
void PipelineRunImpllinks::setNodes(Link const& value)
{
m_Nodes = value;
m_NodesIsSet = true;
}
bool PipelineRunImpllinks::nodesIsSet() const
{
return m_NodesIsSet;
}
void PipelineRunImpllinks::unsetNodes()
{
m_NodesIsSet = false;
}
Link PipelineRunImpllinks::getLog() const
{
return m_Log;
}
void PipelineRunImpllinks::setLog(Link const& value)
{
m_Log = value;
m_LogIsSet = true;
}
bool PipelineRunImpllinks::logIsSet() const
{
return m_LogIsSet;
}
void PipelineRunImpllinks::unsetLog()
{
m_LogIsSet = false;
}
Link PipelineRunImpllinks::getSelf() const
{
return m_Self;
}
void PipelineRunImpllinks::setSelf(Link const& value)
{
m_Self = value;
m_SelfIsSet = true;
}
bool PipelineRunImpllinks::selfIsSet() const
{
return m_SelfIsSet;
}
void PipelineRunImpllinks::unsetSelf()
{
m_SelfIsSet = false;
}
Link PipelineRunImpllinks::getActions() const
{
return m_Actions;
}
void PipelineRunImpllinks::setActions(Link const& value)
{
m_Actions = value;
m_ActionsIsSet = true;
}
bool PipelineRunImpllinks::actionsIsSet() const
{
return m_ActionsIsSet;
}
void PipelineRunImpllinks::unsetActions()
{
m_ActionsIsSet = false;
}
Link PipelineRunImpllinks::getSteps() const
{
return m_Steps;
}
void PipelineRunImpllinks::setSteps(Link const& value)
{
m_Steps = value;
m_StepsIsSet = true;
}
bool PipelineRunImpllinks::stepsIsSet() const
{
return m_StepsIsSet;
}
void PipelineRunImpllinks::unsetSteps()
{
m_StepsIsSet = false;
}
std::string PipelineRunImpllinks::getClass() const
{
return m__class;
}
void PipelineRunImpllinks::setClass(std::string const& value)
{
m__class = value;
m__classIsSet = true;
}
bool PipelineRunImpllinks::r_classIsSet() const
{
return m__classIsSet;
}
void PipelineRunImpllinks::unset_class()
{
m__classIsSet = false;
}
} // namespace org::openapitools::server::model
| 21.975709 | 127 | 0.635962 | [
"model"
] |
d5b98ffb89d935b7caa9262030522a210c996a2d | 5,044 | cpp | C++ | src/rtl/AdaptiveRenderer.cpp | potato3d/rtrt | cac9f2f80d94bf60adf0bbd009f5076973ee10c6 | [
"MIT"
] | 2 | 2021-02-13T14:18:39.000Z | 2021-11-04T07:21:21.000Z | src/rtl/AdaptiveRenderer.cpp | potato3d/rtrt | cac9f2f80d94bf60adf0bbd009f5076973ee10c6 | [
"MIT"
] | null | null | null | src/rtl/AdaptiveRenderer.cpp | potato3d/rtrt | cac9f2f80d94bf60adf0bbd009f5076973ee10c6 | [
"MIT"
] | null | null | null | #include <rtl/AdaptiveRenderer.h>
#include <rtu/random.h>
#include <omp.h>
namespace rtl {
void AdaptiveRenderer::init()
{
rtu::Random::autoSeed();
_epsilon = 0.01f;
_maxRecursionDepth = 3;
}
void AdaptiveRenderer::render()
{
unsigned int width;
unsigned int height;
rtsViewport( width, height );
int w = (int)width;
int h = (int)height;
float* frameBuffer = rtsFrameBuffer();
rtu::float3 resultColor;
int x, y;
int chunk = 16;
#pragma omp parallel for shared( frameBuffer, h, w ) private( y ) schedule( dynamic, chunk )
for( y = 0; y < h; ++y )
{
#pragma omp parallel for shared( frameBuffer, h, w, y ) private( x, resultColor ) schedule( dynamic, chunk )
for( x = 0; x < w; ++x )
{
adaptiveSupersample( x, y, resultColor, 1 );
frameBuffer[(x+y*w)*3] = resultColor.r;
frameBuffer[(x+y*w)*3+1] = resultColor.g;
frameBuffer[(x+y*w)*3+2] = resultColor.b;
}
}
}
void AdaptiveRenderer::adaptiveSupersample( float x, float y, rtu::float3& resultColor, unsigned int recursionDepth )
{
const float deltaRatio = 0.5f / (float)recursionDepth;
float deltaX;
float deltaY;
rts::RTstate upperLeftSample;
rts::RTstate upperRightSample;
rts::RTstate lowerLeftSample;
rts::RTstate lowerRightSample;
// Upper left (A)
deltaX = rtu::Random::real( -deltaRatio, 0.0f );
deltaY = rtu::Random::real( 0.0f, deltaRatio );
rtsInitPrimaryRayState( upperLeftSample, x + deltaX, y + deltaY );
rtsTraceRay( upperLeftSample );
rtu::float3 upperLeftColor = rtsResultColor( upperLeftSample );
// Upper right (B)
deltaX = rtu::Random::real( 0.0f, deltaRatio );
deltaY = rtu::Random::real( 0.0f, deltaRatio );
rtsInitPrimaryRayState( upperRightSample, x + deltaX, y + deltaY );
rtsTraceRay( upperRightSample );
rtu::float3 upperRightColor = rtsResultColor( upperRightSample );
// Lower left (C)
deltaX = rtu::Random::real( -deltaRatio, 0.0f );
deltaY = rtu::Random::real( -deltaRatio, 0.0f );
rtsInitPrimaryRayState( lowerLeftSample, x + deltaX, y + deltaY );
rtsTraceRay( lowerLeftSample );
rtu::float3 lowerLeftColor = rtsResultColor( lowerLeftSample );
// Lower right (D)
deltaX = rtu::Random::real( 0.0f, deltaRatio );
deltaY = rtu::Random::real( -deltaRatio, 0.0f );
rtsInitPrimaryRayState( lowerRightSample, x + deltaX, y + deltaY );
rtsTraceRay( lowerRightSample );
rtu::float3 lowerRightColor = rtsResultColor( lowerRightSample );
if( recursionDepth < _maxRecursionDepth )
{
// If too much difference in sample values
rtu::float3& ab = upperLeftColor - upperRightColor;
ab.set( rtu::mathf::abs( ab.r ), rtu::mathf::abs( ab.g ), rtu::mathf::abs( ab.b ) );
rtu::float3& ac = upperLeftColor - lowerLeftColor;
ac.set( rtu::mathf::abs( ac.r ), rtu::mathf::abs( ac.g ), rtu::mathf::abs( ac.b ) );
rtu::float3& ad = upperLeftColor - lowerRightColor;
ad.set( rtu::mathf::abs( ad.r ), rtu::mathf::abs( ad.g ), rtu::mathf::abs( ad.b ) );
rtu::float3& bc = upperRightColor - lowerLeftColor;
bc.set( rtu::mathf::abs( bc.r ), rtu::mathf::abs( bc.g ), rtu::mathf::abs( bc.b ) );
rtu::float3& bd = upperRightColor - lowerRightColor;
bd.set( rtu::mathf::abs( bd.r ), rtu::mathf::abs( bd.g ), rtu::mathf::abs( bd.b ) );
rtu::float3& cd = upperLeftColor - lowerRightColor;
cd.set( rtu::mathf::abs( cd.r ), rtu::mathf::abs( cd.g ), rtu::mathf::abs( cd.b ) );
if( ( ab.r > _epsilon ) || ( ab.g > _epsilon ) || ( ab.b > _epsilon ) ||
( ac.r > _epsilon ) || ( ac.g > _epsilon ) || ( ac.b > _epsilon ) ||
( ad.r > _epsilon ) || ( ad.g > _epsilon ) || ( ad.b > _epsilon ) ||
( bc.r > _epsilon ) || ( bc.g > _epsilon ) || ( bc.b > _epsilon ) ||
( bd.r > _epsilon ) || ( bd.g > _epsilon ) || ( bd.b > _epsilon ) ||
( cd.r > _epsilon ) || ( cd.g > _epsilon ) || ( cd.b > _epsilon ) )
{
// Recursive supersample
const float recDelta = 0.5f / ( (float)recursionDepth + 1.0f );
rtu::float3 recUpperLeft;
rtu::float3 recUpperRight;
rtu::float3 recLowerLeft;
rtu::float3 recLowerRight;
adaptiveSupersample( x - recDelta, y + recDelta, recUpperLeft, recursionDepth + 1 );
adaptiveSupersample( x + recDelta, y + recDelta, recUpperRight, recursionDepth + 1 );
adaptiveSupersample( x - recDelta, y - recDelta, recLowerLeft, recursionDepth + 1 );
adaptiveSupersample( x + recDelta, y - recDelta, recLowerRight, recursionDepth + 1 );
// Average results
resultColor = ( upperLeftColor * 0.125f ) + ( recUpperLeft * 0.125f ) +
( upperRightColor * 0.125f ) + ( recUpperRight * 0.125f ) +
( lowerLeftColor * 0.125f ) + ( recLowerLeft * 0.125f ) +
( lowerRightColor * 0.125f ) + ( recLowerRight * 0.125f );
}
else
{
// Average results
resultColor = ( upperLeftColor * 0.25f ) + ( upperRightColor * 0.25f ) + ( lowerLeftColor * 0.25f ) +
( lowerRightColor * 0.25f );
}
}
else
{
// Average results
resultColor = ( upperLeftColor * 0.25f ) + ( upperRightColor * 0.25f ) + ( lowerLeftColor * 0.25f ) +
( lowerRightColor * 0.25f );
}
}
} // namespace rtl
| 35.027778 | 117 | 0.646114 | [
"render"
] |
d5bd99efb939b3a74cd3ef497e9424af5ee745ae | 4,976 | cpp | C++ | src/analysis/processing/qgsalgorithmintersection.cpp | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | null | null | null | src/analysis/processing/qgsalgorithmintersection.cpp | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | null | null | null | src/analysis/processing/qgsalgorithmintersection.cpp | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | 1 | 2021-12-25T08:40:30.000Z | 2021-12-25T08:40:30.000Z | /***************************************************************************
qgsalgorithmintersection.cpp
---------------------
Date : April 2018
Copyright : (C) 2018 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsalgorithmintersection.h"
#include "qgsgeometrycollection.h"
#include "qgsgeometryengine.h"
#include "qgsoverlayutils.h"
///@cond PRIVATE
QString QgsIntersectionAlgorithm::name() const
{
return QStringLiteral( "intersection" );
}
QString QgsIntersectionAlgorithm::displayName() const
{
return QObject::tr( "Intersection" );
}
QString QgsIntersectionAlgorithm::group() const
{
return QObject::tr( "Vector overlay" );
}
QString QgsIntersectionAlgorithm::groupId() const
{
return QStringLiteral( "vectoroverlay" );
}
QString QgsIntersectionAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm extracts the overlapping portions of features in the Input and Overlay layers. "
"Features in the output Intersection layer are assigned the attributes of the overlapping features "
"from both the Input and Overlay layers." );
}
QgsProcessingAlgorithm *QgsIntersectionAlgorithm::createInstance() const
{
return new QgsIntersectionAlgorithm();
}
void QgsIntersectionAlgorithm::initAlgorithm( const QVariantMap & )
{
addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "OVERLAY" ), QObject::tr( "Overlay layer" ) ) );
addParameter( new QgsProcessingParameterField(
QStringLiteral( "INPUT_FIELDS" ),
QObject::tr( "Input fields to keep (leave empty to keep all fields)" ), QVariant(),
QStringLiteral( "INPUT" ), QgsProcessingParameterField::Any, true, true ) );
addParameter( new QgsProcessingParameterField(
QStringLiteral( "OVERLAY_FIELDS" ),
QObject::tr( "Overlay fields to keep (leave empty to keep all fields)" ), QVariant(),
QStringLiteral( "OVERLAY" ), QgsProcessingParameterField::Any, true, true ) );
addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Intersection" ) ) );
}
QVariantMap QgsIntersectionAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( !sourceA )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) );
std::unique_ptr< QgsFeatureSource > sourceB( parameterAsSource( parameters, QStringLiteral( "OVERLAY" ), context ) );
if ( !sourceB )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "OVERLAY" ) ) );
QgsWkbTypes::Type geomType = QgsWkbTypes::multiType( sourceA->wkbType() );
const QStringList fieldsA = parameterAsFields( parameters, QStringLiteral( "INPUT_FIELDS" ), context );
const QStringList fieldsB = parameterAsFields( parameters, QStringLiteral( "OVERLAY_FIELDS" ), context );
QList<int> fieldIndicesA = QgsProcessingUtils::fieldNamesToIndices( fieldsA, sourceA->fields() );
QList<int> fieldIndicesB = QgsProcessingUtils::fieldNamesToIndices( fieldsB, sourceB->fields() );
QgsFields outputFields = QgsProcessingUtils::combineFields(
QgsProcessingUtils::indicesToFields( fieldIndicesA, sourceA->fields() ),
QgsProcessingUtils::indicesToFields( fieldIndicesB, sourceB->fields() ) );
QString dest;
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, outputFields, geomType, sourceA->sourceCrs(), QgsFeatureSink::RegeneratePrimaryKey ) );
if ( !sink )
throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) );
QVariantMap outputs;
outputs.insert( QStringLiteral( "OUTPUT" ), dest );
int count = 0;
int total = sourceA->featureCount();
QgsOverlayUtils::intersection( *sourceA, *sourceB, *sink, context, feedback, count, total, fieldIndicesA, fieldIndicesB );
return outputs;
}
///@endcond
| 43.269565 | 201 | 0.65213 | [
"vector"
] |
d5c771e7dd3af6a4f1e586719f83b91f467f6ff9 | 743 | cpp | C++ | 6_STLContainerIterator/own/Iterator2.cpp | stefan-ewald/UdemyCpp | f880b566774882a1722e2c76c5ce3bdbd33b35d0 | [
"MIT"
] | null | null | null | 6_STLContainerIterator/own/Iterator2.cpp | stefan-ewald/UdemyCpp | f880b566774882a1722e2c76c5ce3bdbd33b35d0 | [
"MIT"
] | null | null | null | 6_STLContainerIterator/own/Iterator2.cpp | stefan-ewald/UdemyCpp | f880b566774882a1722e2c76c5ce3bdbd33b35d0 | [
"MIT"
] | null | null | null | #include <iostream>
#include <iterator>
#include <list>
#include <numeric>
#include <vector>
int main()
{
std::vector<int> vec(5, 0);
std::iota(vec.begin(), vec.end(), 0);
std::list<int> list(5, 0);
std::iota(list.begin(), list.end(), 0);
auto it = list.begin();
std::advance(it, 2); // replacement for it+=2 if not available
std::cout << " vec[2]=" << vec[2] << std::endl;
std::cout << "list[2]=" << *it << std::endl;
auto dist = std::distance(it, list.end());
std::cout << "distance=" << dist << std::endl;
auto prev = std::prev(it);
auto next = std::next(it);
std::cout << "prev=" << *prev << std::endl;
std::cout << "next=" << *next << std::endl;
return EXIT_SUCCESS;
}
| 22.515152 | 66 | 0.546433 | [
"vector"
] |
d5ce5ca3537edc5eccaf75ab62f182486dc1e2bc | 4,016 | cpp | C++ | FireCube/UI/UIText.cpp | ashleygwinnell/firecube | ea6bec6bab98d922dce76610a739beb5f7f88b61 | [
"MIT"
] | 1 | 2020-03-31T20:41:48.000Z | 2020-03-31T20:41:48.000Z | FireCube/UI/UIText.cpp | ashleygwinnell/firecube | ea6bec6bab98d922dce76610a739beb5f7f88b61 | [
"MIT"
] | null | null | null | FireCube/UI/UIText.cpp | ashleygwinnell/firecube | ea6bec6bab98d922dce76610a739beb5f7f88b61 | [
"MIT"
] | null | null | null | #include "UI/UIText.h"
#include "Rendering/Font.h"
using namespace FireCube;
UIText::UIText(Engine *engine) : UIElement(engine), color(1.0f)
{
}
UIText::~UIText()
{
}
void UIText::GetParts(std::vector<UIPart> &parts, std::vector<UIVertex> &data)
{
if (vertexData.empty())
{
return;
}
UIPart part;
part.texture = fontFace->page->tex;
part.offset = data.size();
part.count = vertexData.size();
parts.push_back(part);
data.insert(data.end(), vertexData.begin(), vertexData.end());
}
void UIText::SetFontFace(FontFace *fontFace)
{
this->fontFace = fontFace;
UpdateData();
}
void UIText::SetText(const std::string &text)
{
this->text = text;
UpdateData();
}
void UIText::SetColor(vec4 color)
{
this->color = color;
UpdateData();
}
vec4 UIText::GetColor() const
{
return color;
}
void UIText::UpdateData()
{
if (!fontFace)
{
return;
}
if (text.empty())
{
vertexData.clear();
return;
}
vertexData.resize(text.size() * 6);
int numTris = 0;
vec2 curPos(0.0f);
char previous = 0;
for (std::string::const_iterator i = text.begin(); i != text.end(); i++)
{
char c = *i;
if (c == 32)
{
// If current glyph is space simply advance the current position
curPos.x += fontFace->glyph[c].advance;
continue;
}
else if (c == '\n')
{
// If current glyph is new line set the current position accordingly
curPos.x = 0.0f;
curPos.y += fontFace->pointSize;
continue;
}
else if (fontFace->glyph[c].size != vec2(0, 0))
{
if (previous && c)
{
curPos.x += fontFace->GetKerning(previous, c);
}
// Populate the vertex buffer with the position and the texture coordinates of the current glyph
vertexData[numTris * 3 + 0].position = vec3(fontFace->glyph[c].bitmapOffset.x + curPos.x, fontFace->glyph[c].bitmapOffset.y + curPos.y, 0.0f);
vertexData[numTris * 3 + 1].position = vec3(fontFace->glyph[c].bitmapOffset.x + curPos.x, fontFace->glyph[c].bitmapOffset.y + curPos.y + fontFace->glyph[c].size.y, 0.0f);
vertexData[numTris * 3 + 2].position = vec3(fontFace->glyph[c].bitmapOffset.x + curPos.x + fontFace->glyph[c].size.x, fontFace->glyph[c].bitmapOffset.y + curPos.y, 0.0f);
vertexData[numTris * 3 + 0].uv = vec2(fontFace->glyph[c].uv.x, fontFace->glyph[c].uv.y);
vertexData[numTris * 3 + 1].uv = vec2(fontFace->glyph[c].uv.x, fontFace->glyph[c].uv.y + fontFace->glyph[c].size.y / 512.0f);
vertexData[numTris * 3 + 2].uv = vec2(fontFace->glyph[c].uv.x + fontFace->glyph[c].size.x / 512.0f, fontFace->glyph[c].uv.y);
vertexData[numTris * 3 + 0].color = color;
vertexData[numTris * 3 + 1].color = color;
vertexData[numTris * 3 + 2].color = color;
numTris++;
vertexData[numTris * 3 + 0].position = vec3(fontFace->glyph[c].bitmapOffset.x + curPos.x + fontFace->glyph[c].size.x, fontFace->glyph[c].bitmapOffset.y + curPos.y, 0.0f);
vertexData[numTris * 3 + 1].position = vec3(fontFace->glyph[c].bitmapOffset.x + curPos.x, fontFace->glyph[c].bitmapOffset.y + curPos.y + fontFace->glyph[c].size.y, 0.0f);
vertexData[numTris * 3 + 2].position = vec3(fontFace->glyph[c].bitmapOffset.x + curPos.x + fontFace->glyph[c].size.x, fontFace->glyph[c].bitmapOffset.y + curPos.y + fontFace->glyph[c].size.y, 0.0f);
vertexData[numTris * 3 + 0].uv = vec2(fontFace->glyph[c].uv.x + fontFace->glyph[c].size.x / 512.0f, fontFace->glyph[c].uv.y);
vertexData[numTris * 3 + 1].uv = vec2(fontFace->glyph[c].uv.x, fontFace->glyph[c].uv.y + fontFace->glyph[c].size.y / 512.0f);
vertexData[numTris * 3 + 2].uv = vec2(fontFace->glyph[c].uv.x + fontFace->glyph[c].size.x / 512.0f, fontFace->glyph[c].uv.y + fontFace->glyph[c].size.y / 512.0f);
vertexData[numTris * 3 + 0].color = color;
vertexData[numTris * 3 + 1].color = color;
vertexData[numTris * 3 + 2].color = color;
numTris++;
curPos.x += fontFace->glyph[c].advance;
previous = c;
}
}
vertexData.resize(numTris * 3);
}
FontFace *UIText::GetFontFace() const
{
return fontFace;
}
std::string UIText::GetText() const
{
return text;
}
| 29.529412 | 201 | 0.656375 | [
"vector"
] |
d5cf000180b9d9d64d7a407b59a28520d952010d | 24,802 | cpp | C++ | Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/ForcePlateMDF.cpp | mitkof6/BTKCore | d4c03aa9e354be16265d0efe0815c09b35abc642 | [
"Barr",
"Unlicense"
] | 61 | 2015-04-21T20:40:37.000Z | 2022-03-25T03:35:03.000Z | Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/ForcePlateMDF.cpp | mitkof6/BTKCore | d4c03aa9e354be16265d0efe0815c09b35abc642 | [
"Barr",
"Unlicense"
] | 40 | 2018-03-11T15:14:50.000Z | 2022-03-23T18:13:48.000Z | Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/ForcePlateMDF.cpp | mitkof6/BTKCore | d4c03aa9e354be16265d0efe0815c09b35abc642 | [
"Barr",
"Unlicense"
] | 56 | 2015-05-11T11:04:35.000Z | 2022-01-15T20:37:04.000Z | /*--
Open3DMotion
Copyright (c) 2004-2012.
All rights reserved.
See LICENSE.txt for more information.
--*/
#include "ForcePlateMDF.h"
#include "MDFVarTypes.h"
#include "Open3DMotion/Maths/LinearSolve3.h"
#include "Open3DMotion/Maths/RigidTransform3.h"
#include <math.h>
namespace Open3DMotion
{
ForcePlateMDF::ForcePlateMDF()
{
}
ForcePlateMDF::ForcePlateMDF(const ForcePlate& src) :
ForcePlate(src)
{
}
size_t ForcePlateMDF::NumPlates(
const std::map<size_t, std::vector< std::vector<UInt8> >, std::less<size_t> >& data,
const std::map<size_t, size_t, std::less<size_t> >& elementsize)
{
std::map<size_t, size_t, std::less<size_t> >::const_iterator sizeinfo = elementsize.find( VAR_ANALOGUE_FORCE );
size_t force_element_size = (sizeinfo != elementsize.end()) ? sizeinfo->second : 0;
// allow zero here - should this really be allowed??
if (force_element_size == 0)
return 0UL;
// if non-zero should always indicate 2 bytes per value
if (force_element_size != 2)
throw(MotionFileException(MotionFileException::formaterror,"Unexpected element size for force data"));
// see what force plate descriptors are available
size_t num_corners = data.find(VAR_FORCE_PLATE_POSITION)->second.size();
size_t num_sensor_offsets = data.find(VAR_FORCE_PLATE_CONSTANTS)->second.size();
size_t num_force_types = data.find(VAR_FORCE_PLATE_FLAGS)->second.size();
// establish number of plates
size_t num_plates(0);
if (num_force_types)
{
if (elementsize.find(VAR_FORCE_PLATE_FLAGS)->second != 2)
throw(MotionFileException(MotionFileException::formaterror,"Unexpected element size for force plate flags"));
num_plates = num_force_types;
}
else if (num_corners)
{
if (num_corners % 4 != 0)
throw(MotionFileException(MotionFileException::formaterror,"Error in force plate corners"));
num_plates = num_corners / 4;
}
else
{
// default force plate types for all plates
size_t num_force = data.find(VAR_ANALOGUE_FORCE)->second.size();
if (num_force % 8 != 0)
throw(MotionFileException(MotionFileException::formaterror,"No force plate info was given for non-standard plate"));
num_plates = num_force / 8;
}
// check appropriate number of corners etc.
if (num_corners && num_corners != (4*num_plates))
throw(MotionFileException(MotionFileException::formaterror,"4 corners per force plate not present"));
if (num_sensor_offsets && num_sensor_offsets != num_plates)
throw(MotionFileException(MotionFileException::formaterror,"3 sensor offsets per force plate not present"));
// return number of plates
return num_plates;
}
void ForcePlateMDF::ParseMDF(
std::map<size_t, std::vector< std::vector<UInt8> >, std::less<size_t> >& data,
std::map<size_t, size_t, std::less<size_t> >& /*elementsize*/,
size_t iplate) throw(MotionFileException)
{
// MDF plate ID - init to zero (invalid)
UInt8 id(0);
// read plate type - may be 0 if file with no flags was re-saved using CODAmotion Analysis
if (iplate < data[VAR_FORCE_PLATE_FLAGS].size() &&
data[VAR_FORCE_PLATE_FLAGS][iplate].size() >= 2)
{
UInt16 wType = *reinterpret_cast<UInt16*>(&(data[VAR_FORCE_PLATE_FLAGS][iplate][0]));
id = wType >> 8;
}
// if zero or not specified, default to Kistler_9821B
if (id == 0)
id = (UInt8)ForcePlateMDF::type_Kistler_9821B;
// get plate type and model from ID - will generate exception if not recognised or supported
Type = IDtoType(id);
Model = IDtoModel(id);
// set default basic params
DefaultOutline();
DefaultSensorConstants(id);
// custom sensor constants
// - defaults will be left if not available
if (iplate < data[VAR_FORCE_PLATE_CONSTANTS].size() &&
data[VAR_FORCE_PLATE_CONSTANTS][iplate].size() >= 6)
{
ParseMDFSensorConstants(reinterpret_cast<const Int16*>(&data[VAR_FORCE_PLATE_CONSTANTS][iplate][0]));
}
// custom outline
if ((4*iplate+3) < data[VAR_FORCE_PLATE_POSITION].size())
{
for (size_t i = 0; i < 4; i++)
{
size_t nelements = data[VAR_FORCE_PLATE_POSITION][4*iplate+i].size();
if (nelements != 6)
throw (MotionFileException(MotionFileException::formaterror, "missing data for forceplate corners"));
double corner_vector[3] = { 0, 0, 0 };
for (size_t j = 0; j < 3; j++)
corner_vector[j] = 0.1 * (reinterpret_cast<const Int16*>(&data[VAR_FORCE_PLATE_POSITION][4*iplate+i][0]))[j];
Outline[i].SetVector(corner_vector);
}
}
// Kistler correction factors
size_t coeff_num_rows = data[VAR_FORCE_PLATE_COP_COEFFS].size();
if (coeff_num_rows == 2)
{
// build CoP correction matrix if possible
double kistler_params[2][6];
bool have_CoP_correction = true;
for (size_t r = 0; r < 2; r++)
{
size_t coeff_num_cols = data[VAR_FORCE_PLATE_COP_COEFFS][r].size()/4;
if (coeff_num_cols != 6)
{
have_CoP_correction = false;
break;
}
for (size_t c = 0; c < 6; c++)
{
kistler_params[r][c] = (reinterpret_cast<float*>(&data[VAR_FORCE_PLATE_COP_COEFFS][r][0]))[c];
}
}
// put into calibration matrix
if (have_CoP_correction)
{
for (size_t r = 0; r < 2; r++)
{
for (size_t c = 0; c < 6; c++)
{
this->COPOptimisation.Add(kistler_params[r][c]);
}
}
}
}
// In earlier versions of Codamotion Analysis, sensor offset for AMTI plates was not specified
// This code will estimate sensor offsets from the data
if (HasAMTIChannelScheme() /* &&
fabs(sensor.x[0]) < 0.1 &&
fabs(sensor.x[1]) < 0.1 */ )
{
// number of frames of data
size_t nframes_AMTI = data[VAR_ANALOGUE_FORCE][8*iplate+2].size() / 2;
// matrices for best-fit solution for centre-of-pressure value
float* linsolveA = new float [(2*nframes_AMTI)*3];
float* linsolveb = new float [(2*nframes_AMTI)*1];
Int32 validframe = 0;
// alternative matrix for solution to equations from MA6.3
float* linsolveA_MA63 = new float [(2*nframes_AMTI)*3];
// fill matrices from data
for (size_t index_frame = 0; index_frame < nframes_AMTI; index_frame++)
{
size_t platechan0 = iplate*8;
// get scaled inputs
float Fy = -1.0f *
(reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0 ][0])))[index_frame]
* *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0 ][0]);
float Fx = -1.0f *
(reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+1][0])))[index_frame]
* *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+1][0]);
float Fz =
(reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+2][0])))[index_frame]
* *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+2][0]);
float My = 1000.0f *
(reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+3][0])))[index_frame]
* *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+3][0]);
float Mx = 1000.0f *
(reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+4][0])))[index_frame]
* *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+4][0]);
// Mz would be like this but not needed for these calcs
// float Mz = 1000.0f *
// (reinterpret_cast<Int16*>(&data[FileFormatMDF::VAR_ANALOGUE_FORCE][platechan0+5][0]))[index_frame]
// * *reinterpret_cast<float*>(&data[FileFormatMDF::VAR_FORCE_RESOLUTION][platechan0+5][0]);
// centre of pressure as originally computed
float Py =
(reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+6][0])))[index_frame]
* *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+6][0]);
float Px =
(reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+7][0])))[index_frame]
* *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+7][0]);
if (fabs(Fz) < 1.0)
continue;
//-- fill matrices
// first row of matrix
linsolveA[6*validframe ] = Fz;
linsolveA[6*validframe+1] = 0.0f;
linsolveA[6*validframe+2] = -Fx;
// second row of matrix
linsolveA[6*validframe+3] = 0.0f;
linsolveA[6*validframe+4] = Fz;
linsolveA[6*validframe+5] = -Fy;
// first row of const
linsolveb[2*validframe ] = Px*Fz + My;
// second row of const
linsolveb[2*validframe+1] = Py*Fz - Mx;
//-- fill alternative matrices (works for files saved with MA6.3)
// first row of matrix (note different sign of Fx component)
linsolveA_MA63[6*validframe ] = Fz;
linsolveA_MA63[6*validframe+1] = 0.0f;
linsolveA_MA63[6*validframe+2] = Fx;
// second row of matrix (same as before)
linsolveA_MA63[6*validframe+3] = 0.0f;
linsolveA_MA63[6*validframe+4] = Fz;
linsolveA_MA63[6*validframe+5] = -Fy;
// another valid frame
validframe++;
}
if (validframe > 2)
{
// solve to determine sensor consts from data
float x[3], x_MA63[3];
float rms(0.0f), rms_MA63(0.0f);
if (LinearSolve3(x, linsolveA, linsolveb, validframe*2, &rms))
{
// also solve for MA63 equations
// use them only if:
// - they solve ok
// - they produce a better rms result than the regular equations
// - they give a positive value for z0 as was used in those equations
if (LinearSolve3(x_MA63, linsolveA_MA63, linsolveb, validframe*2, &rms_MA63) &&
(rms_MA63 < rms) &&
(x_MA63[2] > 0.0))
{
CentreOffset.X = RoundSensorConst(x_MA63[0]);
CentreOffset.Y = RoundSensorConst(x_MA63[1]);
CentreOffset.Z = RoundSensorConst(x_MA63[2]);
}
else
{
CentreOffset.X = RoundSensorConst(x[0]);
CentreOffset.Y = RoundSensorConst(x[1]);
CentreOffset.Z = RoundSensorConst(fabs(x[2]));
}
}
}
// done with matrices
delete [] linsolveA;
delete [] linsolveb;
delete [] linsolveA_MA63;
}
// need to know number of EMG channels because force data always begins after it
Int32 num_emg = (Int32)data[VAR_ANALOGUE_EMG].size();
// find one-based indices into channels
bool AMTIscheme = HasAMTIChannelScheme();
for (Int32 ichannel = 0; ichannel < 8; ichannel++)
{
Int32 analogchannel = num_emg + 8*iplate + ichannel + 1;
if (AMTIscheme && ichannel >= 6)
this->PreCompCoPChannels.Add(analogchannel);
else
this->Channels.Add(analogchannel);
}
}
// round k to nearest 0.1
double ForcePlateMDF::RoundSensorConst(double k)
{
return 0.1*floor(10.0*k + 0.5);
}
UInt8 ForcePlateMDF::MDFPlateID() const throw(MotionFileException)
{
UInt8 id(0);
const std::string& model = Model.Value();
if (Type.Value() == ForcePlate::TypeKistler)
{
if (model == "9821B")
id = type_Kistler_9821B;
else if (model == "9826")
id = type_Kistler_9826;
else if (model == "9821C_1")
id = type_Kistler_9821C_1;
else if (model == "9821C_2")
id = type_Kistler_9821C_2;
else if (model == "9827")
id = type_Kistler_9827;
else if (model == "9261")
id = type_Kistler_9261;
else
id = type_Kistler_9821B;
}
else if (Type.Value() == ForcePlate::TypeAMTI)
{
if (model == "BP2416")
id = type_AMTI_BP2416;
else if (model == "LG6")
id = type_AMTI_LG6;
else if (model == "OR6")
id=type_AMTI_OR6_7;
else if (model == "AccuSway")
id = type_AMTI_AccuSway;
else if (model == "AccuGait")
id=type_AMTI_AccuGait;
else
id = type_AMTI_BP2416;
}
else
{
throw (MotionFileException(MotionFileException::notsupported, "unsupported force plate type"));
}
return id;
}
const char* ForcePlateMDF::IDtoType(UInt8 id) throw(MotionFileException)
{
switch((int)id)
{
case type_Kistler_9821B:
case type_Kistler_9826:
case type_Kistler_9821C_1:
case type_Kistler_9821C_2:
case type_Kistler_9827:
case type_Kistler_9261:
return ForcePlate::TypeKistler;
case type_AMTI_BP2416:
case type_AMTI_LG6:
case type_AMTI_OR6_7:
case type_AMTI_AccuSway:
case type_AMTI_AccuGait:
return ForcePlate::TypeAMTI;
default:
throw (MotionFileException(MotionFileException::formaterror, "unrecognised force plate ID"));
return "";
}
}
const char* ForcePlateMDF::IDtoModel(UInt8 id) throw(MotionFileException)
{
switch((int)id)
{
case type_Kistler_9821B:
return "9821B";
case type_Kistler_9826:
return "9826";
case type_Kistler_9821C_1:
return "9821C_1";
case type_Kistler_9821C_2:
return "9821C_2";
case type_Kistler_9827:
return "9827";
case type_Kistler_9261:
return "9261";
case type_AMTI_BP2416:
return "BP2416";
case type_AMTI_LG6:
return "LG6";
case type_AMTI_OR6_7:
return "OR6";
case type_AMTI_AccuSway:
return "AccuSway";
case type_AMTI_AccuGait:
return "AccuGait";
default:
throw (MotionFileException(MotionFileException::formaterror, "unrecognised force plate ID"));
return "";
}
}
bool ForcePlateMDF::HasAMTIChannelScheme() const
{
bool isAMTI = (Type.Value() == ForcePlate::TypeAMTI);
return isAMTI;
}
void ForcePlateMDF::DefaultSensorConstants(UInt8 id)
{
switch((int)id)
{
case type_Kistler_9821B:
// sensor_separation = Vector3(120.0, 200.0, 54.0);
SensorSeparation.X = 120.0;
SensorSeparation.Y = 200.0;
SensorSeparation.Z = 54.0;
break;
case type_Kistler_9826:
// sensor_separation = Vector3(120.0F, 200.0F, 49.0F);
SensorSeparation.X = 120.0;
SensorSeparation.Y = 200.0;
SensorSeparation.Z = 49.0;
break;
case type_Kistler_9821C_1:
// sensor_separation = Vector3(120.0F, 200.0F, 49.0F);
SensorSeparation.X = 120.0;
SensorSeparation.Y = 200.0;
SensorSeparation.Z = 49.0;
break;
case type_Kistler_9821C_2:
// sensor_separation = Vector3(175.0F, 275.0F, 22.0F);
SensorSeparation.X = 175.0;
SensorSeparation.Y = 275.0;
SensorSeparation.Z = 22.0;
break;
case type_Kistler_9827:
// sensor_separation = Vector3(210.0F, 350.0F, 52.0F);
SensorSeparation.X = 210.0;
SensorSeparation.Y = 350.0;
SensorSeparation.Z = 52.0;
break;
case type_Kistler_9261:
// sensor_separation = Vector3(132.0F, 220.0F, 37.0F);
SensorSeparation.X = 132.0;
SensorSeparation.Y = 220.0;
SensorSeparation.Z = 37.0;
break;
case type_AMTI_BP2416:
case type_AMTI_LG6:
case type_AMTI_OR6_7:
case type_AMTI_AccuSway:
// centre_offset = Vector3(0.0F, 0.0F, 61.0F);
CentreOffset.X = 0.0;
CentreOffset.Y = 0.0;
CentreOffset.Z = 61.0;
break;
case type_AMTI_AccuGait:
// centre_offset = Vector3(0.0F, 0.0F, 61.0F);
CentreOffset.X = 0.0;
CentreOffset.Y = 0.0;
CentreOffset.Z = 61.0;
break;
}
}
void ForcePlateMDF::DefaultOutline()
{
Outline[0].X = -300.0;
Outline[0].Y = -200.0;
Outline[0].Z = 0.0;
Outline[1].X = -300.0;
Outline[1].Y = 200.0;
Outline[1].Z = 0.0;
Outline[2].X = 300.0;
Outline[2].Y = 200.0;
Outline[2].Z = 0.0;
Outline[3].X = 300.0;
Outline[3].Y = -200.0;
Outline[3].Z = 0.0;
}
float ForcePlateMDF::MDFDefaultSaveRes(size_t ichannel) const
{
const float resAMTI[8] = { 0.01f, 0.01f, 0.06f, 0.03f, 0.03f, 0.01f, 0.1f, 0.1f };
const float resKistler[8] = { 0.02f, 0.02f, 0.02f, 0.02f, 0.06f, 0.06f, 0.06f, 0.06f };
if (ichannel > 7)
return 1.0;
if (HasAMTIChannelScheme())
return resAMTI[ichannel];
else
return resKistler[ichannel];
}
const char* ForcePlateMDF::MDFChannelUnits(size_t mdfchannel) const
{
if (HasAMTIChannelScheme())
{
switch (mdfchannel)
{
// Nmm for moments channels
case 3:
case 4:
case 5:
return "Nmm";
// mm for pre-computed CoP values
case 6:
case 7:
return "mm";
}
}
// default for all others (and all channels on Kistlers) is Newtons
return "N";
}
//--------------------------------------------------------------------------
// channel mapping for psuedo-rotation of force platform
// - index into the array using index for MDF writing
// - get as a result the index of input channel (runtime channel) to use
// - one map for each orientation
// - minus signs mean to negate the input data
// Kistler
static const int mdf_remap_kistler[4][8] =
{
{ 1, 2, 3, 4, 5, 6, 7, 8 },
{ -3, -4, 2, 1, 8, 5, 6, 7 },
{ -2, -1, -4, -3, 7, 8, 5, 6 },
{ 4, 3, -1, -2, 6, 7, 8, 5 },
};
// AMTI
static const int mdf_remap_amti[4][6] =
{
{ -2, -1, 3, 5, 4, 6 },
{ -1, 2, 3, 4, -5, 6 },
{ 2, 1, 3, -5, -4, 6 },
{ 1, -2, 3, -4, 5, 6 }
};
//--------------------------------------------------------------------------
size_t ForcePlateMDF::MDFChannelToRuntimeChannel(size_t mdfchannel) const
{
// get orientation
int orient = static_cast<int>(MDFOrientation());
// cannot remap unless orientation 0-3
if (orient < 0 || orient >= 4)
return mdfchannel;
// remap according to plate type
int mapvalue = 0;
if (HasAMTIChannelScheme())
{
if (mdfchannel < 6)
mapvalue = mdf_remap_amti[orient][mdfchannel];
}
else
{
if (mdfchannel < 8)
mapvalue = mdf_remap_kistler[orient][mdfchannel];
}
// extract zero-based integer part of map value
if (mapvalue)
{
int runtimechannel = abs(mapvalue) - 1;
return runtimechannel;
}
// no remapping available or needed - return original value
return mdfchannel;
}
size_t ForcePlateMDF::RuntimeChannelToMDFChannel(size_t runchannel) const
{
// get orientation
int orient = static_cast<int>(MDFOrientation());
// cannot remap unless orientation 0-3
if (orient < 0 || orient >= 4)
return runchannel;
// remap according to plate type
if (HasAMTIChannelScheme())
{
for (int i = 0; i < 6; i++)
{
if ((abs(mdf_remap_amti[orient][i])-1) == static_cast<int>(runchannel))
return i;
}
}
else
{
for (int i = 0; i < 8; i++)
{
if ((abs(mdf_remap_kistler[orient][i])-1) == static_cast<int>(runchannel))
return i;
}
}
// no remapping available or needed - return original value
return runchannel;
}
double ForcePlateMDF::MDFChannelScale(size_t mdfchannel) const
{
// get orientation
int orient = static_cast<int>(MDFOrientation());
// cannot remap unless orientation 0-3
if (orient < 0 || orient >= 4)
return 1.0;
if (HasAMTIChannelScheme())
{
// scale conversion of Nm -> Nmm for moments components of AMTI data
// and change sign of Fx, Fy according to required remapping
const static double AMTImagnitude[6] = { 1.0, 1.0, 1.0, 1000.0, 1000.0, 1000.0 };
if (mdfchannel < 6)
{
double scale = (mdf_remap_amti[orient][mdfchannel] > 0) ? AMTImagnitude[mdfchannel] : -AMTImagnitude[mdfchannel];
return scale;
}
}
else
{
// 1 or -1 for Kistler depending on how specified in the remapping
if (mdfchannel < 8)
{
double scale = (mdf_remap_kistler[orient][mdfchannel] > 0) ? 1.0 : -1.0;
return scale;
}
}
// usual scale is 1
return 1.0;
}
void ForcePlateMDF::ParseMDFSensorConstants(const Int16* w)
{
// swap x & y and force correct sign of AMTI Z offset
if (HasAMTIChannelScheme())
{
// scale appropriately (strain gauge)
CentreOffset.X = 0.1*w[0];
CentreOffset.Y = 0.1*w[1];
CentreOffset.Z = 0.1*w[2];
if (CentreOffset.Z > 0.0)
CentreOffset.Z.Value() *= -1.0;
// swap sensor_const[0] and sensor_const[1]
// problem in VS2010 using std::swap
// std::swap<double>(sensor_const[0], sensor_const[1]);
double temp = CentreOffset.X;
CentreOffset.X = CentreOffset.Y;
CentreOffset.Y = temp;
}
else
{
// scale appropriately (kistler)
SensorSeparation.X = 0.1*w[0];
SensorSeparation.Y = 0.1*w[1];
SensorSeparation.Z = 0.1*w[2];
}
}
void ForcePlateMDF::MDFSensorConstants(Int16* w) const
{
size_t index_x(0), index_y(1);
Int16 scale_x(1), scale_y(1);
double sensor_const[3];
if (HasAMTIChannelScheme())
{
// Must remap according to convention for AMTI
index_x = RuntimeChannelToMDFChannel(0);
index_y = RuntimeChannelToMDFChannel(1);
scale_x = (MDFChannelScale(0) >= 0.0) ? -1 : 1; // opposite of channel scale
scale_y = (MDFChannelScale(1) >= 0.0) ? -1 : 1; // opposite of channel scale
CentreOffset.GetVector(sensor_const);
}
else
{
// For Kistler these are dimensions so need to swap X and Y if at 90 or 270
Orientation orient = MDFOrientation();
if (orient == orient090 || orient == orient270)
{
index_x = 1;
index_y = 0;
}
SensorSeparation.GetVector(sensor_const);
}
// get consts appropriately and apply standard MDF scale of 10
w[0] = scale_x * (Int16)(10.0*sensor_const[index_x]);
w[1] = scale_y * (Int16)(10.0*sensor_const[index_y]);
w[2] = (Int16)(10.0*sensor_const[2]);
}
// deduce MDF orientation from Outline (may be invalid)
ForcePlateMDF::Orientation ForcePlateMDF::MDFOrientation() const
{
RigidTransform3 T;
Vector3 outline_vector[4];
for (size_t corner_index = 0; corner_index < 4; corner_index++)
Outline[corner_index].GetVector(outline_vector[corner_index]);
// mean central point
Vector3 centre(0,0,0);
centre += outline_vector[0];
centre += outline_vector[1];
centre += outline_vector[2];
centre += outline_vector[3];
centre *= 0.25;
// mean fp X-direction
Vector3 meanX(0,0,0);
meanX -= outline_vector[0];
meanX += outline_vector[1];
meanX += outline_vector[2];
meanX -= outline_vector[3];
// mean fp Y-direction
Vector3 meanY(0,0,0);
meanY -= outline_vector[0];
meanY -= outline_vector[1];
meanY += outline_vector[2];
meanY += outline_vector[3];
// transform fp co-ords ---> global co-ords
RigidTransform3::FromXYVec(T, centre, meanX, meanY);
// this means plate must lie horizontal to within 0.1 degrees
// - usually Codamotion files specify the plate as exactly horizontal but
// some manufacturers do not impose such a constraint
double zcomponent = T.R(2,2);
if (fabs(zcomponent - -1.0) > 0.0017)
{
return orient_invalid;
}
// get rotation angle - atan2 returns a range [-pi, pi)
// or is it (-pi, pi] I'm not sure but it doesn't affect the outcome
const double PI = 3.1415926535897932384626433832795;
double angle = 180.0 * atan2( T.R(0,1), T.R(0,0) ) / PI;
// convert to range [0, 360)
if (angle < 0.0)
angle += 360.0;
// find value
// - note how the MDF (Codamotion Analysis) definition of orientation is
// 90 deg out of phase with the actual matrix orientation & opposite sense
if (angle > 359.5 || angle < 0.5)
return orient090;
else if (fabs(angle-90.0) < 0.5)
return orient000;
else if (fabs(angle-180.0) < 0.5)
return orient270;
else if (fabs(angle-270.0) < 0.5)
return orient180;
else
return orient_invalid;
}
// make MDF-compatible outline to match ChannelScale and RuntimeChanneltoMDFChannel
// returns true if made ok, false if invalid orientation
bool ForcePlateMDF::MDFOutline(std::vector<Vector3>& mdfoutline) const
{
// get orientation
Orientation orient = MDFOrientation();
// must be valid
if (orient == orient_invalid)
return false;
// set result by rotating to canonical system
mdfoutline.resize(4);
for (size_t corner_index = 0; corner_index < 4; corner_index++)
{
Outline[(corner_index + (size_t)orient) % 4].GetVector(mdfoutline[corner_index]);
}
// set ok
return true;
}
}
| 30.099515 | 125 | 0.620192 | [
"vector",
"model",
"transform"
] |
d5d06eb74ec8c856b445df02542439045361ce6c | 4,723 | cpp | C++ | build.cpp | cjemerson/cs411_hw2 | a373ce741b224b6647c89e8aafe65131789ec793 | [
"MIT"
] | null | null | null | build.cpp | cjemerson/cs411_hw2 | a373ce741b224b6647c89e8aafe65131789ec793 | [
"MIT"
] | null | null | null | build.cpp | cjemerson/cs411_hw2 | a373ce741b224b6647c89e8aafe65131789ec793 | [
"MIT"
] | null | null | null | // build.cpp
// Charles Emerson
// 23 September 2019
// Updated: 23 September 2019
//
// For CS 411 Fall 2019
// Source for function build
// Solution for Assignment 2, Exercise A
#include "build.h"
/***** FUNCTION DECLARATIONS *****/
// Workhorse function (RECURSIVE)
// *** Default arguments specified here. ***
// (definition and documentation below)
int build_recurse(const std::vector<std::vector<int>> & bridges,
int i = 0, int nextWestCity = 0, int nextEastCity = 0);
// Helper function
// (definition and documentation below)
void sortAndCull(std::vector<std::vector<int>> & bridges);
/***** WRAPPER FUNCTION DEFINITION *****/
// build - Wrapper function (RECURSIVE)
// Finds the maximum cumulative toll possible for a given a set of
// bridges. Bridges can be combined if they do not start from the
// same West city, end at the same East city or cross another.
//
// The following defines crossing bridges:
// Two bridges {w1, e1, t1} and {w2, e2, t2} cross,
// if (w1 < w2 and e1 > e2) or (w1 > w2 and e1 < e2)
//
// The bridge format is {West city number, East city number, toll}
//
// Preconditions:
// * w must be greater than the maximum West City
// * e must be greater than the maximum East City
// * bridges is a vector of size-3 vectors
int build(int w, int e, std::vector<std::vector<int>> bridges)
{
(void) w, (void) e; // To suppress -Wunused-parameter
// Sorts bridges to make use of invariants and remove duplicates.
sortAndCull(bridges);
return build_recurse(bridges);
}
/***** RECURSIVE WORKHORSE FUNCTION DEFINITION *****/
// build_recurse - Workhorse function (RECURSIVE)
// Finds the maximum toll by recursively combining of bridges that do
// not cross. The variable i is the index of the bridge currently
// considered. The variables nextWestCity and nextEastCity represent
// the lowest bridge connections under consideration.
//
// Default args (See declaration):
// * i = 0
// * nextWestCity = 0
// * nextEastCity = 0
// Preconditions:
// * i, nextWestCity and nextEastCity are initially zero
// (in the first recursive call).
// * bridges is sorted according to sortAndCull()
// Invariants:
// * [nextWestCity, max West City] is available for a bridge or
// nextWestCity > max West city.
// * [nextEastCity, max East City] is available for a bridge or
// nextEastCity > max East city.
int build_recurse(const std::vector<std::vector<int>> & bridges, int i, int nextWestCity, int nextEastCity)
{
const int BRIDGES_SIZE = int(bridges.size());
// If we are at the end of the bridges
if (i >= BRIDGES_SIZE)
{
return 0;
}
auto max_toll = 0;
auto current_w = bridges[i][0];
auto current_e = bridges[i][1];
// If we can place a bridge
if (current_w >= nextWestCity && current_e >= nextEastCity)
{
// Try with the bridge
auto temp = bridges[i][2] + build_recurse(bridges, i + 1, current_w + 1, current_e + 1);
max_toll = (max_toll < temp)? temp : max_toll;
}
// Try without the bridge
auto temp = build_recurse(bridges, i + 1, nextWestCity, nextEastCity);
max_toll = (max_toll < temp)? temp : max_toll;
return max_toll;
}
/***** HELPER FUNCTION DEFINITIONS *****/
// sortAndCull - Helper function (Modifies the set of bridges)
// Sorts the set of bridges in ascending order of West to East cities,
// then in descending order of toll. Duplicate bridges with less than
// or equal toll are removed from the set of bridges.
void sortAndCull(std::vector<std::vector<int>> & bridges)
{
// Sort bridges in the following order:
// 1) Ascending order of West city numbers (Lowest to Highest)
// 2) Ascending order of East city numbers (Lowest to Highest)
// 3) Descending order of bridge tolls (Highest to Lowest)
std::sort(bridges.begin(), bridges.end(),
[](const auto & a, const auto & b)
{
return std::forward_as_tuple(a[0], a[1], -a[2]) < std::forward_as_tuple(b[0], b[1], -b[2]);
});
// Cull every subsequent duplicate bridge after the first.
// (Duplicate bridges, which have the same West and East cities,
// are consecutive in order of highest toll to lowest toll.)
int last_w = -1, last_e = -1;
auto it = std::remove_if(bridges.begin(), bridges.end(),
[&](const auto & bridge)
{
auto value = bridge[0] == last_w && bridge[1] == last_e;
last_w = bridge[0], last_e = bridge[1];
return value;
});
bridges.erase(it, bridges.end());
}
| 34.224638 | 108 | 0.638154 | [
"vector"
] |
d5dd142f84f90a9ec3b0d12ba11e4f6052cf38f5 | 7,083 | hpp | C++ | include/autoppl/expression/distribution/uniform.hpp | JamesYang007/autoppl | e78f8d229d2e399f86f338e473da5ddc7dbed053 | [
"MIT"
] | 37 | 2020-04-12T19:45:12.000Z | 2021-06-28T19:05:38.000Z | include/autoppl/expression/distribution/uniform.hpp | JamesYang007/autoppl | e78f8d229d2e399f86f338e473da5ddc7dbed053 | [
"MIT"
] | 11 | 2020-04-26T14:55:52.000Z | 2020-09-13T19:21:50.000Z | include/autoppl/expression/distribution/uniform.hpp | JamesYang007/autoppl | e78f8d229d2e399f86f338e473da5ddc7dbed053 | [
"MIT"
] | 7 | 2020-04-15T04:45:22.000Z | 2022-03-25T17:28:42.000Z | #pragma once
#include <cassert>
#include <random>
#include <fastad_bits/reverse/stat/uniform.hpp>
#include <autoppl/util/traits/traits.hpp>
#include <autoppl/expression/distribution/dist_utils.hpp>
#include <autoppl/math/density.hpp>
#include <autoppl/math/math.hpp>
#define PPL_UNIFORM_PARAM_SHAPE \
"Uniform parameters min and max must be either scalar or vector. "
namespace ppl {
namespace expr {
namespace dist {
namespace details {
/**
* Checks whether min, max have proper relative shapes.
* Must be proper shapes and cannot be matrices.
*/
template <class MinType
, class MaxType>
struct uniform_valid_param_dim
{
static constexpr bool value =
util::is_shape_v<MinType> &&
util::is_shape_v<MaxType> &&
!util::is_mat_v<MinType> &&
!util::is_mat_v<MaxType>;
};
/**
* Checks if var, min, max have proper relative shapes.
* Currently, we only allow up to vector dimension (no matrix).
*/
template <class VarType
, class MinType
, class MaxType>
struct uniform_valid_dim
{
static constexpr bool value =
util::is_shape_v<VarType> &&
(
(util::is_scl_v<VarType> &&
util::is_scl_v<MinType> &&
util::is_scl_v<MaxType>) ||
(util::is_vec_v<VarType> &&
uniform_valid_param_dim<MinType, MaxType>::value)
);
};
template <class MinType
, class MaxType>
inline constexpr bool uniform_valid_param_dim_v =
uniform_valid_param_dim<MinType, MaxType>::value;
template <class VarType
, class MinType
, class MaxType>
inline constexpr bool uniform_valid_dim_v =
uniform_valid_dim<VarType, MinType, MaxType>::value;
} // namespace details
/**
* Uniform is a generic expression type for the uniform distribution.
*
* If MinType or MaxType is a vector, then the variable assigned
* to this distribution must also be a vector.
*
* @tparam MinType variable expression for the min.
* Cannot be a matrix shape.
* @tparam MaxType variable expression for the max.
* Cannot be a matrix shape.
*/
template <class MinType
, class MaxType>
struct Uniform: util::DistExprBase<Uniform<MinType, MaxType>>
{
private:
using min_t = MinType;
using max_t = MaxType;
static_assert(util::is_var_expr_v<min_t>);
static_assert(util::is_var_expr_v<max_t>);
static_assert(details::uniform_valid_param_dim_v<min_t, max_t>,
PPL_DIST_SHAPE_MISMATCH
PPL_UNIFORM_PARAM_SHAPE
);
public:
using value_t = util::cont_param_t;
using base_t = util::DistExprBase<Uniform<min_t, max_t>>;
using typename base_t::dist_value_t;
Uniform(const min_t& min,
const max_t& max)
: min_{min}, max_{max}
{}
template <class XType>
dist_value_t pdf(const XType& x)
{
static_assert(util::is_dist_assignable_v<XType>);
static_assert(details::uniform_valid_dim_v<XType, min_t, max_t>,
PPL_DIST_SHAPE_MISMATCH);
return math::uniform_pdf(x.get(), min_.eval(), max_.eval());
}
template <class XType>
dist_value_t log_pdf(const XType& x)
{
static_assert(util::is_dist_assignable_v<XType>);
static_assert(details::uniform_valid_dim_v<XType, min_t, max_t>,
PPL_DIST_SHAPE_MISMATCH);
return math::uniform_log_pdf(x.get(), min_.eval(), max_.eval());
}
template <class XType
, class PtrPackType>
auto ad_log_pdf(const XType& x,
const PtrPackType& pack) const
{
return ad::uniform_adj_log_pdf(x.ad(pack),
min_.ad(pack),
max_.ad(pack));
}
template <class PtrPackType>
void bind(const PtrPackType& pack)
{
static_cast<void>(pack);
if constexpr (min_t::has_param) {
min_.bind(pack);
}
if constexpr (max_t::has_param) {
max_.bind(pack);
}
}
void activate_refcnt() const
{
min_.activate_refcnt();
max_.activate_refcnt();
}
// Note: assumes that min_ and max_ have already been evaluated!
template <class XType, class GenType>
bool prune(XType& x, GenType& gen) const {
using x_t = std::decay_t<XType>;
static_assert(util::is_param_v<x_t>);
auto m = min_.get();
auto M = max_.get();
std::uniform_real_distribution<dist_value_t> dist(0.,1.);
if constexpr (util::is_scl_v<x_t>) {
bool needs_prune = (x.get() <= m) || (x.get() >= M);
if (needs_prune) {
x.get() = (M-m) * dist(gen) + m;
}
return needs_prune;
} else if constexpr (util::is_vec_v<x_t>) {
auto get = [](const auto& v, size_t i=0, size_t j=0) {
using v_t = std::decay_t<decltype(v)>;
static_cast<void>(i);
static_cast<void>(j);
if constexpr (!ad::util::is_eigen_v<v_t>) {
return v;
} else {
return v(i,j);
}
};
auto to_array = [](const auto& v) {
using v_t = std::decay_t<decltype(v)>;
if constexpr (!ad::util::is_eigen_v<v_t>) {
return v;
} else {
return v.array();
}
};
auto xa = x.get().array();
bool needs_prune = (xa <= to_array(m)).max(xa >= to_array(M)).any();
if (needs_prune) {
using vec_t = std::decay_t<decltype(x.get())>;
x.get() = vec_t::NullaryExpr(x.get().size(),
[&](size_t i) {
return (get(M, i) - get(m, i)) * dist(gen) + get(m, i);
});
}
return needs_prune;
} else {
static_assert(util::is_scl_v<x_t> ||
util::is_vec_v<x_t>,
"x must be a scalar or vector shape.");
}
}
private:
min_t min_;
max_t max_;
};
} // namespace dist
} // namespace expr
/**
* Builds a Uniform expression only when the parameters
* are both valid continuous distribution parameter types.
* See var_expr.hpp for more information.
*/
template <class MinType, class MaxType
, class = std::enable_if_t<
util::is_valid_dist_param_v<MinType> &&
util::is_valid_dist_param_v<MaxType>
> >
inline constexpr auto uniform(const MinType& min_expr,
const MaxType& max_expr)
{
using min_t = util::convert_to_param_t<MinType>;
using max_t = util::convert_to_param_t<MaxType>;
min_t wrap_min_expr = min_expr;
max_t wrap_max_expr = max_expr;
return expr::dist::Uniform(wrap_min_expr, wrap_max_expr);
}
} // namespace ppl
#undef PPL_UNIFORM_PARAM_SHAPE
| 29.886076 | 83 | 0.575039 | [
"shape",
"vector"
] |
d5e29ce3afd3c6082478361e267721b83371e486 | 2,520 | cpp | C++ | c++/segment2D.cpp | forgotter/Snippets | bb4e39cafe7ef2c1ef3ac24b450a72df350a248b | [
"MIT"
] | 38 | 2018-09-17T18:16:24.000Z | 2022-02-10T10:26:23.000Z | c++/segment2D.cpp | forgotter/Snippets | bb4e39cafe7ef2c1ef3ac24b450a72df350a248b | [
"MIT"
] | 1 | 2020-10-01T10:48:45.000Z | 2020-10-04T11:27:44.000Z | c++/segment2D.cpp | forgotter/Snippets | bb4e39cafe7ef2c1ef3ac24b450a72df350a248b | [
"MIT"
] | 12 | 2018-11-13T13:36:41.000Z | 2021-05-02T10:07:44.000Z | /// Name: Segment2D
/// Description: Segment Tree implementation using bottom-up technique for 2D matrix
/// Detail: Segment tree, Data Structure, Range Query, 2D
/// Guarantee: } // Segment2D
vector< vector< int > >arr, tree;
// NOTE: Arr size is n*m, tree size is (4n)*(4m)
void build_y(int vx, int lx, int rx, int vy, int ly, int ry) {
if (ly == ry) {
if (lx == rx)
tree[vx][vy] = arr[lx][ly];
else
tree[vx][vy] = tree[vx*2][vy] + tree[vx*2+1][vy];
} else {
int my = (ly + ry) / 2;
build_y(vx, lx, rx, vy*2, ly, my);
build_y(vx, lx, rx, vy*2+1, my+1, ry);
tree[vx][vy] = tree[vx][vy*2] + tree[vx][vy*2+1];
}
}
void build_x(int vx, int lx, int rx) {
if (lx != rx) {
int mx = (lx + rx) / 2;
build_x(vx*2, lx, mx);
build_x(vx*2+1, mx+1, rx);
}
build_y(vx, lx, rx, 1, 0, arr[0].size()-1);
}
int sum_y(int vx, int vy, int tly, int try_, int ly, int ry) {
if (ly > ry)
return 0;
if (ly == tly && try_ == ry)
return tree[vx][vy];
int tmy = (tly + try_) / 2;
return sum_y(vx, vy*2, tly, tmy, ly, min(ry, tmy))
+ sum_y(vx, vy*2+1, tmy+1, try_, max(ly, tmy+1), ry);
}
int sum_x(int vx, int tlx, int trx, int lx, int rx, int ly, int ry) {
if (lx > rx)
return 0;
if (lx == tlx && trx == rx)
return sum_y(vx, 1, 0, arr[0].size()-1, ly, ry);
int tmx = (tlx + trx) / 2;
return sum_x(vx*2, tlx, tmx, lx, min(rx, tmx), ly, ry)
+ sum_x(vx*2+1, tmx+1, trx, max(lx, tmx+1), rx, ly, ry);
}
void update_y(int vx, int lx, int rx, int vy, int ly, int ry, int x, int y, int new_val) {
if (ly == ry) {
if (lx == rx)
tree[vx][vy] = new_val;
else
tree[vx][vy] = tree[vx*2][vy] + tree[vx*2+1][vy];
} else {
int my = (ly + ry) / 2;
if (y <= my)
update_y(vx, lx, rx, vy*2, ly, my, x, y, new_val);
else
update_y(vx, lx, rx, vy*2+1, my+1, ry, x, y, new_val);
tree[vx][vy] = tree[vx][vy*2] + tree[vx][vy*2+1];
}
}
void update_x(int vx, int lx, int rx, int x, int y, int new_val) {
if (lx != rx) {
int mx = (lx + rx) / 2;
if (x <= mx)
update_x(vx*2, lx, mx, x, y, new_val);
else
update_x(vx*2+1, mx+1, rx, x, y, new_val);
}
update_y(vx, lx, rx, 1, 0, arr[0].size()-1, x, y, new_val);
} // Segment2D | 32.727273 | 91 | 0.475 | [
"vector"
] |
d5e4f4d5e106a1cb0f1d0007261f88d98689f14e | 14,438 | cpp | C++ | 3rdparty/optee/optee_os/external/RIoT/Sample/Barnacle/Shared/Tool/BarT/SignAgent.cpp | mrragava/ragava_openenclave_6 | 78ffbd4ce16ec698576c432ca1fa8340663ca229 | [
"MIT"
] | null | null | null | 3rdparty/optee/optee_os/external/RIoT/Sample/Barnacle/Shared/Tool/BarT/SignAgent.cpp | mrragava/ragava_openenclave_6 | 78ffbd4ce16ec698576c432ca1fa8340663ca229 | [
"MIT"
] | 2 | 2018-01-13T01:58:40.000Z | 2018-01-13T02:22:28.000Z | 3rdparty/optee/optee_os/external/RIoT/Sample/Barnacle/Shared/Tool/BarT/SignAgent.cpp | mrragava/ragava_openenclave_6 | 78ffbd4ce16ec698576c432ca1fa8340663ca229 | [
"MIT"
] | 1 | 2017-11-22T22:19:54.000Z | 2017-11-22T22:19:54.000Z | #include "stdafx.h"
//SignAgent
void SignAgent(
std::wstring fileName,
PCCERT_CONTEXT appAuthCert,
INT32 buildNo
)
{
DWORD retVal = STDFUFILES_NOERROR;
DWORD dwKeySpec;
BOOL pfCallerFreeProvOrCryptKey;
HCRYPTPROV_OR_NCRYPT_KEY_HANDLE codeAuth = NULL;
HANDLE hHexFile = INVALID_HANDLE_VALUE;
HANDLE hDfuFile = INVALID_HANDLE_VALUE;
DFUIMAGEELEMENT dfuImageElement = { 0 };
BCRYPT_ALG_HANDLE hSha256 = NULL;
std::exception_ptr pendingException = NULL;
UINT32 agentSize = 0;
try
{
if ((retVal = BCryptOpenAlgorithmProvider(&hSha256,
BCRYPT_SHA256_ALGORITHM,
NULL,
0)) != 0)
{
printf("%s: BCryptOpenAlgorithmProvider failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
if (!CryptAcquireCertificatePrivateKey(appAuthCert,
CRYPT_ACQUIRE_SILENT_FLAG | CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG,
NULL,
&codeAuth,
&dwKeySpec,
&pfCallerFreeProvOrCryptKey))
{
printf("%s: CryptAcquireCertificatePrivateKey failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw GetLastError();
}
std::string hexFileName;
hexFileName.resize(fileName.size());
if (!WideCharToMultiByte(CP_UTF8,
WC_ERR_INVALID_CHARS,
fileName.c_str(),
fileName.size(),
(LPSTR)hexFileName.c_str(),
hexFileName.size(),
NULL,
NULL))
{
printf("%s: WideCharToMultiByte failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw GetLastError();
}
// Get the agent image
if ((retVal = ImageFromFile((PSTR)hexFileName.c_str(), &hHexFile, 0)) != STDFUFILES_NOERROR)
{
printf("%s: ImageFromFile failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
agentSize = GetImageSize(hHexFile);
std::vector<BYTE> image((((agentSize + 0x7ff) / 0x800) * 0x800), 0x00);
printf("IN-Size: %d (allocated 0x%08x)\n", agentSize, image.size());
dfuImageElement.Data = image.data();
if ((retVal = GetImageElement(hHexFile, 0, &dfuImageElement)) != STDFUFILES_NOERROR)
{
printf("%s: GetImageElement failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
printf("IN-Rank[0]: 0x%08x-0x%08x (%d)\n", dfuImageElement.dwAddress, dfuImageElement.dwAddress + dfuImageElement.dwDataLength, dfuImageElement.dwDataLength);
for (DWORD rank = 1; ; rank++)
{
DFUIMAGEELEMENT iterator = { 0 };
if ((retVal = GetImageElement(hHexFile, rank, &iterator)) != STDFUFILES_NOERROR)
{
break;
}
printf("IN-Rank[%d]: 0x%08x-0x%08x (%d)\n", rank, iterator.dwAddress, iterator.dwAddress + iterator.dwDataLength, iterator.dwDataLength);
std::vector<BYTE> fragment(iterator.dwDataLength, 0x00);
iterator.Data = fragment.data();
if ((retVal = GetImageElement(hHexFile, rank, &iterator)) != STDFUFILES_NOERROR)
{
printf("%s: GetImageElement failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
memcpy(&image[iterator.dwAddress - dfuImageElement.dwAddress], fragment.data(), fragment.size());
}
dfuImageElement.dwDataLength = image.size();
// Add the information about this image to the header
PBARNACLE_AGENT_HDR AgentHdr;
AgentHdr = (PBARNACLE_AGENT_HDR)image.data();
if ((AgentHdr->s.sign.hdr.magic != BARNACLEMAGIC) ||
(AgentHdr->s.sign.hdr.size != sizeof(BARNACLE_AGENT_HDR)) ||
(AgentHdr->s.sign.hdr.version != BARNACLEVERSION))
{
printf("%s: Bad agent image (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw ERROR_INVALID_DATA;
}
AgentHdr->s.sign.agent.size = agentSize - AgentHdr->s.sign.hdr.size;
AgentHdr->s.sign.agent.issued = GetTimeStamp();
if (buildNo > 0)
{
AgentHdr->s.sign.agent.version = (AgentHdr->s.sign.agent.version & 0xffff0000) | (UINT16)buildNo;
}
hexFileName.resize(hexFileName.size() - 4);
strncpy_s(AgentHdr->s.sign.agent.name, hexFileName.c_str(), sizeof(AgentHdr->s.sign.agent.name));
if ((retVal = BCryptHash(hSha256,
NULL,
0,
(PBYTE)&image[AgentHdr->s.sign.hdr.size],
AgentHdr->s.sign.agent.size,
AgentHdr->s.sign.agent.digest,
sizeof(AgentHdr->s.sign.agent.digest))) != 0)
{
printf("%s: BCryptHash failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
// Report binary info
printf("Agent: %s\n", AgentHdr->s.sign.agent.name);
printf("Size: %d bytes\n", AgentHdr->s.sign.agent.size);
printf("Version: %d.%d\n", AgentHdr->s.sign.agent.version >> 16, AgentHdr->s.sign.agent.version & 0x0000ffff);
printf("Issued: 0x%08x\n", AgentHdr->s.sign.agent.issued);
printf("Digest: ");
for (uint32_t n = 0; n < sizeof(AgentHdr->s.sign.agent.digest); n++) printf("%02x", AgentHdr->s.sign.agent.digest[n]);
printf("\n");
// Sign the header
if (codeAuth != NULL)
{
std::vector<BYTE> hdrDigest(BARNACLEDIGESTLEN, 0);
if ((retVal = BCryptHash(hSha256,
NULL,
0,
(PBYTE)&AgentHdr->s.sign,
sizeof(AgentHdr->s.sign),
hdrDigest.data(),
hdrDigest.size())) != 0)
{
printf("%s: BCryptHash failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
std::vector<BYTE> sig(32 * 2, 0);
DWORD result;
if ((retVal = NCryptSignHash(codeAuth,
NULL,
hdrDigest.data(),
hdrDigest.size(),
sig.data(),
sig.size(),
&result,
0)) != 0)
{
printf("%s: NCryptSignHash failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
memcpy(AgentHdr->s.signature.r, &sig[0], sizeof(AgentHdr->s.signature.r));
memcpy(AgentHdr->s.signature.s, &sig[sizeof(AgentHdr->s.signature.r)], sizeof(AgentHdr->s.signature.s));
// Check the header signature
ecc_signature riotSig = { 0 };
BigIntToBigVal(&riotSig.r, AgentHdr->s.signature.r, sizeof(AgentHdr->s.signature.r));
BigIntToBigVal(&riotSig.s, AgentHdr->s.signature.s, sizeof(AgentHdr->s.signature.s));
if ((retVal = NCryptExportKey(codeAuth,
NULL,
BCRYPT_ECCPUBLIC_BLOB,
NULL,
NULL,
0,
&result,
0)) != 0)
{
printf("%s: NCryptExportKey failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
std::vector<BYTE> codeAuthKeyData(result, 0);
if ((retVal = NCryptExportKey(codeAuth,
NULL,
BCRYPT_ECCPUBLIC_BLOB,
NULL,
codeAuthKeyData.data(),
codeAuthKeyData.size(),
&result,
0)) != 0)
{
printf("%s: NCryptExportKey failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
BCRYPT_ECCKEY_BLOB* keyHdr = (BCRYPT_ECCKEY_BLOB*)codeAuthKeyData.data();
RIOT_ECC_PUBLIC codeAuthPub = { 0 };
BigIntToBigVal(&codeAuthPub.x, &codeAuthKeyData[sizeof(BCRYPT_ECCKEY_BLOB)], keyHdr->cbKey);
BigIntToBigVal(&codeAuthPub.y, &codeAuthKeyData[sizeof(BCRYPT_ECCKEY_BLOB) + keyHdr->cbKey], keyHdr->cbKey);
if ((retVal = RIOT_DSAVerify((PBYTE)&AgentHdr->s.sign, sizeof(AgentHdr->s.sign), &riotSig, &codeAuthPub)) != RIOT_SUCCESS)
{
printf("%s: RiotCrypt_Verify failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
if ((retVal = BuildTCPSAliasIdentity( &codeAuthPub, hdrDigest.data(), hdrDigest.size(), NULL, 0, (uint32_t*)&result)) != RIOT_BAD_FORMAT)
{
throw retVal;
}
std::vector<BYTE> tcpsId(result, 0x00);
if ((retVal = BuildTCPSAliasIdentity( &codeAuthPub, hdrDigest.data(), hdrDigest.size(), tcpsId.data(), tcpsId.size(), (uint32_t*)&result)) != RIOT_SUCCESS)
{
throw retVal;
}
// Log the CBOR
WriteToFile(L"ApplicationDataSheet.CBOR", tcpsId, OPEN_ALWAYS);
}
else
{
// Unsigned Image
memset(&AgentHdr->s.signature, 0x00, sizeof(AgentHdr->s.signature));
}
hHexFile = NULL;
if ((retVal = CreateImage(&hHexFile, 0)) != STDFUFILES_NOERROR)
{
printf("%s: CreateImage failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
if ((retVal = SetImageName(hHexFile, (PSTR)hexFileName.c_str())) != STDFUFILES_NOERROR)
{
printf("%s: SetImageName failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
if ((retVal = SetImageElement(hHexFile, 0, TRUE, dfuImageElement)) != STDFUFILES_NOERROR)
{
printf("%s: SetImageElement failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
printf("OUT-Rank[0](%s): 0x%08x-0x%08x (%d)\n", hexFileName.c_str(), dfuImageElement.dwAddress, dfuImageElement.dwAddress + dfuImageElement.dwDataLength, dfuImageElement.dwDataLength);
std::string verStr(16, '\0');
verStr.resize(sprintf_s((char*)verStr.c_str(), verStr.size(), "-%d.%d", AgentHdr->s.sign.agent.version >> 16, AgentHdr->s.sign.agent.version & 0x0000ffff));
hexFileName += verStr;
hexFileName.append(".DFU");
if ((retVal = CreateNewDFUFile((PSTR)hexFileName.c_str(), &hDfuFile, diceDeviceVid, diceDevicePid, diceDeviceVer)) != STDFUFILES_NOERROR)
{
printf("%s: CreateNewDFUFile failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
if ((retVal = AppendImageToDFUFile(hDfuFile, hHexFile)) != STDFUFILES_NOERROR)
{
printf("%s: AppendImageToDFUFile failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
printf("DFU file %s successfully created.\n", hexFileName.c_str());
}
catch (const std::exception& e)
{
UNREFERENCED_PARAMETER(e);
pendingException = std::current_exception();
}
// Cleanup
if ((hDfuFile != INVALID_HANDLE_VALUE) && ((retVal = CloseDFUFile(hDfuFile)) != STDFUFILES_NOERROR))
{
printf("%s: CloseDFUFile failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
hDfuFile = INVALID_HANDLE_VALUE;
if ((hHexFile != INVALID_HANDLE_VALUE) && ((retVal = DestroyImage(&hHexFile)) != STDFUFILES_NOERROR))
{
printf("%s: DestroyImage failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw retVal;
}
hHexFile = INVALID_HANDLE_VALUE;
if ((codeAuth) && (pfCallerFreeProvOrCryptKey))
{
if (dwKeySpec == CERT_NCRYPT_KEY_SPEC)
{
NCryptFreeObject(codeAuth);
}
else
{
CryptReleaseContext(codeAuth, 0);
}
codeAuth = NULL;
}
if (hSha256)
{
BCryptCloseAlgorithmProvider(hSha256, 0);
hSha256 = NULL;
}
if (pendingException != NULL)
{
std::rethrow_exception(pendingException);
}
}
bool RunSignAgent(std::unordered_map<std::wstring, std::wstring> param)
{
bool result = true;
std::unordered_map<std::wstring, std::wstring>::iterator it;
std::wstring hexName(param.find(L"00")->second);
HCERTSTORE hStore = NULL;
PCCERT_CONTEXT hCert = NULL;
UINT32 timeStamp = -1;
INT32 buildNo = -1;
try
{
if (((it = param.find(L"-ct")) != param.end()) || ((it = param.find(L"-cf")) != param.end()))
{
std::vector<BYTE> certThumbPrint;
if ((it = param.find(L"-ct")) != param.end())
{
// Get NCrypt Handle to certificate private key pointed to by CertThumbPrint
certThumbPrint = ReadHex(it->second);
}
if ((it = param.find(L"-cf")) != param.end())
{
// Get NCrypt Handle to certificate private key pointed to by Certificate file
PCCERT_CONTEXT hCert = CertFromFile(it->second);
certThumbPrint = CertThumbPrint(hCert);
CertFreeCertificateContext(hCert);
}
CRYPT_HASH_BLOB findTP = { certThumbPrint.size(), certThumbPrint.data() };
if ((hStore = CertOpenSystemStore(NULL, TEXT("MY"))) == NULL)
{
printf("%s: CertOpenSystemStore failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw GetLastError();
}
if ((hCert = CertFindCertificateInStore(hStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_HASH, &findTP, NULL)) == NULL)
{
printf("%s: CertFindCertificateInStore failed (%s@%u).\n", __FUNCTION__, __FILE__, __LINE__);
throw GetLastError();
}
}
if ((it = param.find(L"-bn")) != param.end())
{
try
{
buildNo = std::stoul(ReadStrFromFile(it->second));
}
catch (const std::exception& e)
{
UNREFERENCED_PARAMETER(e);
buildNo = 0;
}
WriteToFile(it->second, ++buildNo);
}
SignAgent(hexName, hCert, buildNo);
}
catch (const std::exception& e)
{
UNREFERENCED_PARAMETER(e);
result = false;
}
return result;
}
| 39.664835 | 192 | 0.557487 | [
"vector"
] |
d5e52f483cd705bab12006c7e80bbf89a539b9d7 | 1,251 | hpp | C++ | EaMC++/07_CRTP_variadic_templates/operators/operators.hpp | Jorengarenar/homework | 5e69aa0fb1b21ffaf88d62af263ea719e82e9c70 | [
"Unlicense"
] | null | null | null | EaMC++/07_CRTP_variadic_templates/operators/operators.hpp | Jorengarenar/homework | 5e69aa0fb1b21ffaf88d62af263ea719e82e9c70 | [
"Unlicense"
] | null | null | null | EaMC++/07_CRTP_variadic_templates/operators/operators.hpp | Jorengarenar/homework | 5e69aa0fb1b21ffaf88d62af263ea719e82e9c70 | [
"Unlicense"
] | null | null | null | #pragma once
template<int N> class Vector;
template<typename L, typename R>
class Vector_lazy {
public:
using F = int (*)(L,R,int);
Vector_lazy(L&& left_, R&& right_, F op_) :
left(std::forward<L>(left_)), right(std::forward<R>(right_)), op(op_)
{}
int operator [](int n)
{
return op(left, right, n);
}
template<int N>
operator Vector<N>()
{
Vector<N> temp;
for (int i = 0; i < N; ++i) {
temp[i] = (*this)[i];
}
return temp;
}
private:
L left;
R right;
F op;
};
template<typename L, typename R>
Vector_lazy<L,R> operator +(L&& l, R&& r)
{
return Vector_lazy<L,R>(std::forward<L>(l), std::forward<R>(r),
[](L l, R r, int n) { return l[n] + r[n]; });
}
template<typename L, typename R>
Vector_lazy<L,R> operator -(L&& l, R&& r)
{
return Vector_lazy<L,R>(std::forward<L>(l), std::forward<R>(r),
[](L l, R r, int n) { return l[n] - r[n]; });
}
template<typename L, typename R>
Vector_lazy<L,R> operator *(L&& l, R&& r)
{
return Vector_lazy<L,R>(std::forward<L>(l), std::forward<R>(r),
[](L l, R r, int n) { return l * r[n]; });
// ^ I've assumed scalar is always first
}
// vim: fen fdl=1
| 21.568966 | 77 | 0.533173 | [
"vector"
] |
d5f6c986a03a2029f5264038c0c2d307fe1f8a2c | 2,061 | cpp | C++ | leetcode2/aliendictionary.cpp | WIZARD-CXY/pl | 22b7f5d81804f4e333d3cff6433364ba1a0ac7ef | [
"Apache-2.0"
] | 1 | 2016-01-20T08:26:34.000Z | 2016-01-20T08:26:34.000Z | leetcode2/aliendictionary.cpp | WIZARD-CXY/pl | 22b7f5d81804f4e333d3cff6433364ba1a0ac7ef | [
"Apache-2.0"
] | 1 | 2015-10-21T05:38:17.000Z | 2015-11-02T07:42:55.000Z | leetcode2/aliendictionary.cpp | WIZARD-CXY/pl | 22b7f5d81804f4e333d3cff6433364ba1a0ac7ef | [
"Apache-2.0"
] | null | null | null | class Solution {
public:
//adjacent list graph
unordered_map<char, unordered_set<char> > g;
vector<int> vis;
int t;
string alienOrder(vector<string>& words) {
if(words.size()==1){
return words[0];
}
g=buildGraph(words);
string res=topo();
cout<<res.size()<<endl;
return res;
}
string topo(){
int n=g.size();
string res=string(n,'a');
t=n;
vis.assign(256,0);
for(auto kv : g){
if(!vis[kv.first]){
if(!dfs(kv.first,res)){
return "";
}
}
}
return res;
}
bool dfs(char u, string &res){
vis[u]=-1;
for(auto v: g[u]){
if(vis[v]==-1){
return false;
}else if (!vis[v] && !dfs(v,res)){
return false;
}
}
vis[u]=1;
res[--t]=u;
return true;
}
unordered_map<char,unordered_set<char> > buildGraph(vector<string> &words){
int n=words.size();
unordered_map<char,unordered_set<char> > g;
for(int i=1; i<n; i++){
int l1=words[i-1].size();
int l2=words[i].size();
int lmax=max(l1,l2);
bool flag=false;
for(int j=0; j<lmax; j++){
if(j<l1 && g.find(words[i-1][j])==g.end()){
g[words[i-1][j]]=unordered_set<char>();
}
if(j<l2 && g.find(words[i][j])==g.end()){
g[words[i][j]]=unordered_set<char>();
}
if(j<l1 && j<l2 && words[i-1][j]!=words[i][j] && !flag){
//if a different is found we can stop
g[words[i-1][j]].insert(words[i][j]);
flag=true;
}
}
}
return g;
}
}; | 24.535714 | 79 | 0.378457 | [
"vector"
] |
d5f8ce601ea2d65c80acc96cb684f07c31e949ee | 3,585 | cc | C++ | Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.cc | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 1 | 2019-03-09T19:47:49.000Z | 2019-03-09T19:47:49.000Z | Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.cc | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | null | null | null | Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.cc | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 1 | 2019-04-03T19:23:27.000Z | 2019-04-03T19:23:27.000Z | ///////////////////////////////////////////////////////////////////////////////
// File: DDHCalTestBeamAlgo.cc
// Description: Position inside the mother according to (eta,phi)
///////////////////////////////////////////////////////////////////////////////
#include <cmath>
#include <algorithm>
namespace std{} using namespace std;
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
#include "Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
DDHCalTestBeamAlgo::DDHCalTestBeamAlgo() {
LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating an instance";
}
DDHCalTestBeamAlgo::~DDHCalTestBeamAlgo() {}
void DDHCalTestBeamAlgo::initialize(const DDNumericArguments & nArgs,
const DDVectorArguments & ,
const DDMapArguments & ,
const DDStringArguments & sArgs,
const DDStringVectorArguments & ) {
eta = nArgs["Eta"];
theta = 2.0*atan(exp(-eta));
phi = nArgs["Phi"];
distance = nArgs["Dist"];
distanceZ = nArgs["DistZ"];
dz = nArgs["Dz"];
copyNumber = int (nArgs["Number"]);
dist = (distance+distanceZ/sin(theta));
LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parameters for position"
<< "ing--" << " Eta " << eta << "\tPhi "
<< phi/CLHEP::deg << "\tTheta " << theta/CLHEP::deg
<< "\tDistance " << distance << "/" << distanceZ << "/"
<< dist <<"\tDz " << dz <<"\tcopyNumber " << copyNumber;
idNameSpace = DDCurrentNamespace::ns();
childName = sArgs["ChildName"];
DDName parentName = parent().name();
LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parent " << parentName
<< "\tChild " << childName << " NameSpace "
<< idNameSpace;
}
void DDHCalTestBeamAlgo::execute(DDCompactView& cpv) {
double thetax = 90.*CLHEP::deg + theta;
double sthx = sin(thetax);
if (abs(sthx)>1.e-12) sthx = 1./sthx;
else sthx = 1.;
double phix = atan2(sthx*cos(theta)*sin(phi),sthx*cos(theta)*cos(phi));
double thetay = 90.*CLHEP::deg;
double phiy = 90.*CLHEP::deg + phi;
double thetaz = theta;
double phiz = phi;
DDRotation rotation;
string rotstr = childName;
LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating a new rotation "
<< rotstr << "\t" << thetax/CLHEP::deg << ","
<< phix/CLHEP::deg << "," << thetay/CLHEP::deg << ","
<< phiy/CLHEP::deg << "," << thetaz/CLHEP::deg <<","
<< phiz/CLHEP::deg;
rotation = DDrot(DDName(rotstr, idNameSpace), thetax, phix, thetay, phiy,
thetaz, phiz);
double r = dist*sin(theta);
double xpos = r*cos(phi);
double ypos = r*sin(phi);
double zpos = dist*cos(theta);
DDTranslation tran(xpos, ypos, zpos);
DDName parentName = parent().name();
cpv.position(DDName(childName,idNameSpace), parentName,copyNumber, tran,rotation);
LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: "
<< DDName(childName, idNameSpace) << " number "
<< copyNumber << " positioned in " << parentName
<< " at " << tran << " with " << rotation;
xpos = (dist-dz)*sin(theta)*cos(phi);
ypos = (dist-dz)*sin(theta)*sin(phi);
zpos = (dist-dz)*cos(theta);
edm::LogInfo("HCalGeom") << "DDHCalTestBeamAlgo: Suggested Beam position "
<< "(" << xpos << ", " << ypos << ", " << zpos
<< ") and (dist, eta, phi) = (" << (dist-dz) << ", "
<< eta << ", " << phi << ")";
}
| 38.138298 | 83 | 0.586611 | [
"geometry"
] |
d5f9693289a0f39d5d21756e6bd4d7a6b4703079 | 654 | cpp | C++ | problemsets/Codeforces/C++/B776.cpp | juarezpaulino/coderemite | a4649d3f3a89d234457032d14a6646b3af339ac1 | [
"Apache-2.0"
] | null | null | null | problemsets/Codeforces/C++/B776.cpp | juarezpaulino/coderemite | a4649d3f3a89d234457032d14a6646b3af339ac1 | [
"Apache-2.0"
] | null | null | null | problemsets/Codeforces/C++/B776.cpp | juarezpaulino/coderemite | a4649d3f3a89d234457032d14a6646b3af339ac1 | [
"Apache-2.0"
] | null | null | null | /**
*
* Author: Juarez Paulino(coderemite)
* Email: juarez.paulino@gmail.com
*
*/
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define fi first
#define se second
typedef pair<int,int> pii;
#define MAX 100010
bool comp[MAX];
vector<int> prime;
void sieve (int n) {
comp[1] = 1;
for (int i = 2; i <= n; ++i) {
if (!comp[i]) prime.eb(i);
for (int p: prime) {
if (i*p > n) break;
comp[i*p] = 1;
if (i%p == 0) break;
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
sieve(n+1);
cout << (n<3?1:2) << endl;
for (int i = 2; i <= n+1; i++)
cout << (!comp[i] ? 1 : 2) << " ";
} | 16.35 | 38 | 0.553517 | [
"vector"
] |
d5faea0c3bbd121996803ef6d598b42b6ddcb175 | 1,191 | cc | C++ | src/AndroidInterface.cc | Ascent-AeroSystems-Inc/qgroundcontrol-herelink | 388aa2aaa3536a3f0870e7e9004617833adc5e75 | [
"Apache-2.0"
] | 12 | 2020-04-19T17:36:34.000Z | 2022-02-02T01:42:06.000Z | src/AndroidInterface.cc | Ascent-AeroSystems-Inc/qgroundcontrol-herelink | 388aa2aaa3536a3f0870e7e9004617833adc5e75 | [
"Apache-2.0"
] | 27 | 2020-04-20T16:33:54.000Z | 2022-03-10T13:57:23.000Z | src/AndroidInterface.cc | Ascent-AeroSystems-Inc/qgroundcontrol-herelink | 388aa2aaa3536a3f0870e7e9004617833adc5e75 | [
"Apache-2.0"
] | 39 | 2020-04-18T00:45:45.000Z | 2022-03-21T10:41:46.000Z | /****************************************************************************
*
* Copyright (C) 2018 Pinecone Inc. All rights reserved.
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include <QtAndroidExtras/QtAndroidExtras>
#include <QtAndroidExtras/QAndroidJniObject>
#include "QGCApplication.h"
#include "AndroidInterface.h"
#include <QAndroidJniObject>
QString AndroidInterface::getSdcardPath()
{
QAndroidJniObject value = QAndroidJniObject::callStaticObjectMethod("org/mavlink/qgroundcontrol/QGCActivity", "getSdcardPath",
"()Ljava/lang/String;");
return value.toString();
}
void AndroidInterface::triggerMediaScannerScanFile(QString& file_path)
{
QAndroidJniObject path = QAndroidJniObject::fromString(file_path);
QAndroidJniObject::callStaticObjectMethod("org/mavlink/qgroundcontrol/QGCActivity", "triggerMediaScannerScanFile",
"(Ljava/lang/String;)V",
path.object<jstring>());
}
| 39.7 | 130 | 0.600336 | [
"object"
] |
d5fe9067e0b3d0e0e65c8e0650eab64365dd5114 | 5,812 | cpp | C++ | lab4_sem2/main.cpp | Neknu/labs_algorythm | aeed6c60ca5db4daaac9f01554c2d7f4a2700ab7 | [
"Apache-2.0"
] | null | null | null | lab4_sem2/main.cpp | Neknu/labs_algorythm | aeed6c60ca5db4daaac9f01554c2d7f4a2700ab7 | [
"Apache-2.0"
] | null | null | null | lab4_sem2/main.cpp | Neknu/labs_algorythm | aeed6c60ca5db4daaac9f01554c2d7f4a2700ab7 | [
"Apache-2.0"
] | 4 | 2019-10-29T10:39:38.000Z | 2020-05-28T21:00:56.000Z | #include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include "sqlite3.h"
using std::string;
using std::cout;
using std::cin;
using std::vector;
using std::endl;
const char separator = ' ';
const int nameWidth = 35;
const int numWidth = 5;
const int MAX_N = 100;
struct Product {
int id;
string name;
string group;
int cost;
};
vector<Product*> collect_data() {
sqlite3 *db;
sqlite3_stmt * stmt;
vector<Product*> products;
if (sqlite3_open("../../data.db", &db) == SQLITE_OK)
{
sqlite3_prepare( db, "SELECT * from product;", -1, &stmt, nullptr );//preparing the statement
sqlite3_step( stmt );
while( sqlite3_column_text( stmt, 0 ) )
{
auto product = new Product();
std::stringstream strValueID;
strValueID << sqlite3_column_text(stmt, 0);
int intValueID;
strValueID >> intValueID;
product->id = intValueID;
product->name = std::string(reinterpret_cast<const char*>(
sqlite3_column_text(stmt, 1)
));
product->group = std::string(reinterpret_cast<const char*>(
sqlite3_column_text(stmt, 3)
));
std::stringstream strValueCost;
strValueCost << sqlite3_column_text(stmt, 2);
int intValueCost;
strValueCost >> intValueCost;
product->cost = intValueCost;
products.push_back(product);
sqlite3_step( stmt );
}
}
else
{
cout << "Failed to open db\n";
}
sqlite3_finalize(stmt);
sqlite3_close(db);
return products;
}
template<typename T> void printElement(T t, const int& width) {
cout << std::left << std::setw(width) << std::setfill(separator) << t;
}
void print_product(Product* product) {
printElement(product->id, numWidth);
printElement(product->name, nameWidth);
printElement(product->group, nameWidth);
printElement(product->cost, numWidth);
cout << endl;
}
void print_products(const vector<Product*> &products) {
cout << "WELCOME TO OUR MINIMARKET:" << endl;
cout << "THIS IS OUR LIST OF PRODUCTS:" << endl;
printElement("ID:", numWidth);
printElement("NAME:", nameWidth);
printElement("GROUP:", nameWidth);
printElement("COST:", numWidth);
cout << endl;
int length = products.size();
for(int i = 0; i < length; i++) {
print_product(products[i]);
}
cout << endl;
}
struct Node {
Product* data;
Node* left;
Node* right;
};
Node* newNode(Product* product, Node *left, Node* right) {
auto new_node = new Node();
new_node->data = product;
new_node->left = left;
new_node->right = right;
return new_node;
}
Node* buildTree(const vector<Product*>& products, int root[][MAX_N], int low, int high) {
if(low > high) {
return nullptr;
} else {
int current_root = root[low][high];
return newNode(products[current_root], buildTree(products, root, low, current_root - 1), buildTree(products, root, current_root + 1, high));
}
}
Node* optimalSearchTree(int freq[], int fails[], int n, const vector<Product*>& products)
{
int cost[n+2][n+1];
int possibility[n+2][n+1];
int root[MAX_N][MAX_N];
for (int i = 1; i <= n+1; i++) {
cost[i][i-1] = fails[i-1];
possibility[i][i-1] = fails[i-1];
}
for (int L = 1; L <= n + 1; L++) {
for (int i = 1; i <= n-L+1; i++) {
int j = i+L-1;
cost[i][j] = INT_MAX;
possibility[i][j] = possibility[i][j-1] + freq[j] + fails[j];
for (int r = i; r <= j; r++) {
int temp = cost[i][r - 1] + cost[r+1][j] + possibility[i][j];
if(temp < cost[i][j]) {
cost[i][j] = temp;
root[i][j] = r;
}
}
}
}
cout << "Cost of Optimal BST in COSTS:" << cost[1][n] << endl;
cout << endl << "COSTS:" << endl;
for(int i = 1; i < n + 2; i++) {
for(int j = 0; j < n + 1; j++) {
if(i <= j+1) {
printElement(cost[i][j],5);
} else {
printElement(0,5);
};
}
cout << endl;
}
cout << "POSSIBILITIES:" << endl;
for(int i = 1; i < n + 2; i++) {
for(int j = 0; j < n + 1; j++) {
if(i <= j+1) {
printElement(possibility[i][j],5);
} else {
printElement(0,5);
};
}
cout << endl;
}
cout << "ROOTS:" << endl;
for(int i = 1; i < n + 1; i++) {
for(int j = 1; j < n + 1; j++) {
if(i <= j) {
printElement(root[i][j],5);
} else {
printElement(0,5);
};
}
cout << endl;
}
return buildTree(products, root, 1, n);
}
void preOrder(Node* root)
{
if (root != nullptr)
{
print_product(root->data);
preOrder(root->left);
preOrder(root->right);
}
}
int main() {
vector<Product*> products = collect_data();
print_products(products);
int freq[] = {0, 15, 10, 5, 10, 20}; // in percents
int fails[] = {5, 10, 5, 5, 5, 10}; // in percents
int n = 5;
products.resize(n);
auto compare = [](const Product* a, const Product* b) {
return a->name < b->name;};
std::sort(products.begin(), products.end(),compare);
Node* root = optimalSearchTree(freq, fails, n, products);
cout << endl << "This is pre order TREE:" << endl;
preOrder(root);
return 0;
} | 25.716814 | 148 | 0.511872 | [
"vector"
] |
91078f557623984cc26388680936f00db6f4d169 | 2,074 | cxx | C++ | pandatool/src/xfile/xFileArrayDef.cxx | cmarshall108/panda3d-python3 | 8bea2c0c120b03ec1c9fd179701fdeb7510bb97b | [
"PHP-3.0",
"PHP-3.01"
] | null | null | null | pandatool/src/xfile/xFileArrayDef.cxx | cmarshall108/panda3d-python3 | 8bea2c0c120b03ec1c9fd179701fdeb7510bb97b | [
"PHP-3.0",
"PHP-3.01"
] | null | null | null | pandatool/src/xfile/xFileArrayDef.cxx | cmarshall108/panda3d-python3 | 8bea2c0c120b03ec1c9fd179701fdeb7510bb97b | [
"PHP-3.0",
"PHP-3.01"
] | null | null | null | /**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file xFileArrayDef.cxx
* @author drose
* @date 2004-10-03
*/
#include "xFileArrayDef.h"
#include "xFileDataDef.h"
#include "xFileDataObject.h"
/**
* Returns the size of the array dimension. If this is a fixed array, the
* size is trivial; if it is dynamic, the size is determined by looking up the
* dynamic_size element in the prev_data table (which lists all of the data
* values already defined at this scoping level).
*/
int XFileArrayDef::
get_size(const XFileNode::PrevData &prev_data) const {
if (is_fixed_size()) {
return _fixed_size;
} else {
XFileNode::PrevData::const_iterator pi;
pi = prev_data.find(_dynamic_size);
nassertr_always(pi != prev_data.end(), 0);
nassertr((*pi).second != nullptr, 0);
return (*pi).second->i();
}
}
/**
*
*/
void XFileArrayDef::
output(std::ostream &out) const {
if (is_fixed_size()) {
out << "[" << _fixed_size << "]";
} else {
out << "[" << _dynamic_size->get_name() << "]";
}
}
/**
* Returns true if the node, particularly a template node, is structurally
* equivalent to the other node (which must be of the same type). This checks
* data element types, but does not compare data element names.
*/
bool XFileArrayDef::
matches(const XFileArrayDef &other, const XFileDataDef *parent,
const XFileDataDef *other_parent) const {
if (other.is_fixed_size() != is_fixed_size()) {
return false;
}
if (is_fixed_size()) {
if (other.get_fixed_size() != get_fixed_size()) {
return false;
}
} else {
int child_index = parent->find_child_index(get_dynamic_size());
int other_child_index =
other_parent->find_child_index(other.get_dynamic_size());
if (other_child_index != child_index) {
return false;
}
}
return true;
}
| 27.289474 | 78 | 0.675988 | [
"3d"
] |
510672dd664d324dce75a4d3951545fa5ac16512 | 5,693 | cc | C++ | src/ast/module.cc | zatkh/verona | 8e0c5b1cd7f80ce3d2419c43e97cacad7472323c | [
"MIT"
] | null | null | null | src/ast/module.cc | zatkh/verona | 8e0c5b1cd7f80ce3d2419c43e97cacad7472323c | [
"MIT"
] | null | null | null | src/ast/module.cc | zatkh/verona | 8e0c5b1cd7f80ce3d2419c43e97cacad7472323c | [
"MIT"
] | 1 | 2020-07-30T13:26:05.000Z | 2020-07-30T13:26:05.000Z | // Copyright Microsoft and Project Verona Contributors.
// SPDX-License-Identifier: MIT
#include "module.h"
#include "path.h"
using namespace peg::udl;
namespace
{
using namespace module;
ModulePtr make_module(const std::string& name)
{
return std::make_shared<Module>(name);
}
// This ensures that a module has only one moduledef node, and transforms the
// moduledef to a classdef, such that from this point on, modules are classes.
bool moduledef(ast::Ast& ast, const std::string& path, err::Errors& err)
{
std::vector<ast::Ast> defs;
for (auto& node : ast->nodes)
{
if (node->tag == "moduledef"_)
defs.push_back(node);
}
if (defs.size() > 1)
{
err << defs.front() << "This module contains multiple definitions.\n";
for (auto& def : defs)
err << def << "Module definition here.\n";
err << err::end;
return false;
}
auto moduledef = (defs.size() > 0) ? defs.front() : ast;
auto classdef = ast::node(moduledef, "classdef");
auto id = ast::token(classdef, "id", "$module");
ast::push_back(classdef, id);
if (moduledef->tag == "moduledef"_)
{
ast::remove(moduledef);
for (auto& node : moduledef->nodes)
ast::push_back(classdef, node);
moduledef->nodes.clear();
}
else
{
auto typeparams = ast::node(moduledef, "typeparams");
ast::push_back(classdef, typeparams);
auto oftype = ast::node(moduledef, "oftype");
ast::push_back(classdef, oftype);
auto constraints = ast::node(moduledef, "constraints");
ast::push_back(classdef, constraints);
}
auto typebody = ast::node(moduledef, "typebody");
ast::push_back(classdef, typebody);
for (auto& node : ast->nodes)
ast::push_back(typebody, node);
ast->nodes.clear();
ast = classdef;
return true;
}
// This extract all module references from an Ast, and builds a vector of
// dependency paths rooted in the Ast path.
void extract(ast::Ast& ast, std::vector<std::string>& deps)
{
switch (ast->tag)
{
case "module_ref"_:
{
auto name = path::join(ast->path, ast->nodes.front()->token);
if (path::extension(name).empty())
name = path::to_directory(name);
deps.push_back(name);
return;
}
}
ast::for_each(ast, extract, deps);
}
ModulePtr load(
peg::parser& parser,
const std::string& path,
const std::string& ext,
err::Errors& err)
{
std::map<std::string, ModulePtr> modules;
std::vector<ModulePtr> stack;
bool ok = true;
auto canonical_path = path::canonical(path);
auto m = make_module(path::from_platform(path));
modules.emplace(canonical_path, m);
stack.push_back(m);
while (!stack.empty())
{
m = stack.back();
stack.pop_back();
m->ast = parser::parse(parser, m->name, ext, err);
if (!m->ast || !moduledef(m->ast, m->name, err))
{
ok = false;
continue;
}
std::vector<std::string> deps;
extract(m->ast, deps);
while (!deps.empty())
{
auto path = deps.back();
deps.pop_back();
canonical_path = path::canonical(path);
auto find = modules.find(canonical_path);
if (find != modules.end())
{
m->edges.push_back(find->second);
continue;
}
auto dep = make_module(path);
modules.emplace(canonical_path, dep);
stack.push_back(dep);
m->edges.push_back(dep);
}
}
return modules.begin()->second;
}
void detect_cycles(ModulePtr& m, err::Errors& err)
{
std::vector<std::vector<ModulePtr>> cycles;
dfs::cycles(
m,
[](auto& parent, auto& child, auto& cycles) {
cycles.push_back({parent});
auto& cycle = cycles.back();
auto m = parent;
while (m != child)
{
for (auto& m2 : m->edges)
{
if (m2->color == dfs::grey)
{
cycle.push_back(m2);
m = m2;
break;
}
}
}
return false;
},
cycles);
for (auto& cycle : cycles)
{
err << "These modules cause a cyclic dependency:\n";
for (auto& m : cycle)
err << " " << m->name << "\n";
err << err::end;
}
}
bool run_passes(ModulePtr& m, const Passes& passes, err::Errors& err)
{
return dfs::post(
m,
[](auto& m, auto& passes, auto& err) {
// Stop running passes when we get errors on this module, then add those
// errors to the main error list.
if (!m->ast)
return false;
err::Errors lerr;
bool ok = true;
for (auto& pass : passes)
{
pass(m->ast, lerr);
if (!lerr.empty())
{
err << lerr;
ok = false;
break;
}
}
return ok;
},
passes,
err);
}
}
namespace module
{
ModulePtr build(
peg::parser& parser,
const Passes& passes,
const std::string& path,
const std::string& ext,
err::Errors& err)
{
auto m = load(parser, path, ext, err);
if (err.empty())
detect_cycles(m, err);
if (err.empty())
run_passes(m, passes, err);
return m;
}
ModulePtr build(
const std::string& grammar,
const Passes& passes,
const std::string& path,
const std::string& ext,
err::Errors& err)
{
auto parser = parser::create(grammar, err);
if (!err.empty())
return {};
return build(parser, passes, path, ext, err);
}
}
| 22.151751 | 80 | 0.548217 | [
"vector"
] |
51096422a39e72852c2e76935c2841988ccca9be | 42,303 | cc | C++ | src/render.cc | Segarraraj/VulkanDemo | 9738e8d0b3c4f90f991c9fc677cbb5406a6a190f | [
"CC0-1.0"
] | null | null | null | src/render.cc | Segarraraj/VulkanDemo | 9738e8d0b3c4f90f991c9fc677cbb5406a6a190f | [
"CC0-1.0"
] | null | null | null | src/render.cc | Segarraraj/VulkanDemo | 9738e8d0b3c4f90f991c9fc677cbb5406a6a190f | [
"CC0-1.0"
] | null | null | null | #include "render.h"
#include "logger.h"
#include "utils.h"
#include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "chrono"
static struct UniformBufferObject {
glm::mat4 model;
glm::mat4 view;
glm::mat4 projection;
};
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData);
Render::Render() { }
Render::~Render() {
cleanup();
#ifdef DEBUG
auto vkDestroyDebugUtilsMessengerEXT = (PFN_vkDestroyDebugUtilsMessengerEXT)
vkGetInstanceProcAddr(_instance, "vkDestroyDebugUtilsMessengerEXT");
if (vkDestroyDebugUtilsMessengerEXT)
{
vkDestroyDebugUtilsMessengerEXT(_instance, _debug_messenger, nullptr);
}
#endif // DEBUG
vkDestroySemaphore(_device, _image_ready_semaphore, nullptr);
vkDestroySemaphore(_device, _render_finished_semaphore, nullptr);
vkDestroyFence(_device, _frame_fence, nullptr);
vkDestroyDescriptorSetLayout(_device, _uniform_descriptor_layout, nullptr);
vkDestroyBuffer(_device, _positions_vertex_buffer, nullptr);
vkFreeMemory(_device, _positions_buffer_memory, nullptr);
vkDestroyBuffer(_device, _colors_vertex_buffer, nullptr);
vkFreeMemory(_device, _colors_buffer_memory, nullptr);
vkDestroyBuffer(_device, _indices_buffer, nullptr);
vkFreeMemory(_device, _indices_buffer_memory, nullptr);
vkDestroyBuffer(_device, _uniform_buffer, nullptr);
vkFreeMemory(_device, _uniform_buffer_memory, nullptr);
vkDestroyCommandPool(_device, _command_pool, nullptr);
vkDestroyDescriptorPool(_device, _descriptor_pool, nullptr);
vkDestroyDevice(_device, nullptr);
vkDestroySurfaceKHR(_instance, _surface, nullptr);
vkDestroyInstance(_instance, nullptr);
}
int Render::init(HWND window, HINSTANCE instance)
{
_window = window;
LOG_DEBUG("Render", "Initializing Vulkan :)");
// CREATING APP INFO
VkApplicationInfo app_info = {};
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
app_info.pApplicationName = "Vulkan Demo";
app_info.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
app_info.pEngineName = "NotBadBoy";
app_info.engineVersion = VK_MAKE_VERSION(1, 0, 0);
app_info.apiVersion = VK_API_VERSION_1_2;
// ENUMERATING AVAILABLE LAYERS AND EXTENSIONS
uint32_t count;
vkEnumerateInstanceExtensionProperties(nullptr, &count, nullptr);
std::vector<VkExtensionProperties> availableExtensions(count);
vkEnumerateInstanceExtensionProperties(nullptr, &count, &availableExtensions[0]);
std::cout << "\n";
LOG_DEBUG("Render", "Available extensions:");
LOG_DEBUG("Render", "---------------------");
for (const VkExtensionProperties& propertie : availableExtensions)
{
LOG_DEBUG("Render", "%s, V%d", propertie.extensionName, propertie.specVersion);
}
vkEnumerateInstanceLayerProperties(&count, nullptr);
std::vector<VkLayerProperties> availableLayers(count);
vkEnumerateInstanceLayerProperties(&count, &(availableLayers[0]));
std::cout << "\n";
LOG_DEBUG("Render", "Available layers:");
LOG_DEBUG("Render", "-----------------");
for (const VkLayerProperties& propertie : availableLayers)
{
LOG_DEBUG("Render", "%s, V%d", propertie.layerName, propertie.implementationVersion);
}
// ADDING LAYERS AND EXTENSIONS
std::vector<char*> extensions = std::vector<char*>();
std::vector<char*> layers = std::vector<char*>();
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
extensions.push_back("VK_KHR_win32_surface");
#ifdef DEBUG
layers.push_back("VK_LAYER_KHRONOS_validation");
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
#endif // DEBUG
VkInstanceCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
create_info.pApplicationInfo = &app_info;
create_info.enabledExtensionCount = extensions.size();
create_info.ppEnabledExtensionNames = &(extensions[0]);
create_info.enabledLayerCount = layers.size();
create_info.ppEnabledLayerNames = &(layers[0]);
// CREATING VULKAN INSTANCE
VkResult result = vkCreateInstance(&create_info, nullptr, &_instance);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to create Vulkan instance");
return 0;
}
createDebuger();
if (!createSurface(window, instance))
{
return 0;
}
std::vector<char*> device_extensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
if (!pickPhysicalDevice(device_extensions)) {
return 0;
}
if (!createLogicalDevice(device_extensions)) {
return 0;
}
RECT rect;
GetClientRect(window, &rect);
if (!createSwapChain(rect.right - rect.left, rect.bottom - rect.top))
{
return 0;
}
if (!createRenderPass())
{
return 0;
}
if (!createGraphicsPipeline())
{
return 0;
}
if (!createVertexBuffers())
{
return 0;
}
if (!createCommandBuffer())
{
return 0;
}
return 1;
}
void Render::drawFrame()
{
vkWaitForFences(_device, 1, &_frame_fence, VK_TRUE, UINT64_MAX);
vkResetFences(_device, 1, &_frame_fence);
uint32_t image_index = 0;
VkResult result = vkAcquireNextImageKHR(
_device, _swapchain,
UINT64_MAX, _image_ready_semaphore,
VK_NULL_HANDLE, &image_index
);
if (result == VK_ERROR_OUT_OF_DATE_KHR)
{
recreateSwapChain();
return;
}
else if (result == VK_SUBOPTIMAL_KHR)
{
LOG_WARNING("Render", "Running with suboptimal swapchain");
}
else if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to get image from swapchain");
return;
}
VkPipelineStageFlags wait_stages[] = { VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT };
VkSubmitInfo submit_info = {};
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submit_info.waitSemaphoreCount = 1;
submit_info.pWaitSemaphores = &_image_ready_semaphore;
submit_info.pWaitDstStageMask = wait_stages;
submit_info.commandBufferCount = 1;
submit_info.pCommandBuffers = &_command_buffers[image_index];
submit_info.signalSemaphoreCount = 1;
submit_info.pSignalSemaphores = &_render_finished_semaphore;
update();
result = vkQueueSubmit(_graphics_queue, 1, &submit_info, _frame_fence);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed submiting command buffer");
return;
}
VkPresentInfoKHR present_info = {};
present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
present_info.waitSemaphoreCount = 1;
present_info.pWaitSemaphores = &_render_finished_semaphore;
present_info.swapchainCount = 1;
present_info.pSwapchains = &_swapchain;
present_info.pImageIndices = &image_index;
present_info.pResults = nullptr;
result = vkQueuePresentKHR(_present_queue, &present_info);
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || _resize) {
_resize = false;
recreateSwapChain();
}
else if (result != VK_SUCCESS) {
LOG_ERROR("Render", "Failed to present swapchain image");
return;
}
}
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData) {
switch (messageSeverity)
{
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: {
LOG_DEBUG("VALIDATION LAYER", pCallbackData->pMessage);
break;
}
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: {
LOG_WARNING("VALIDATION LAYER", pCallbackData->pMessage);
break;
}
case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: {
LOG_ERROR("VALIDATION LAYER", pCallbackData->pMessage);
break;
}
}
return VK_FALSE;
}
void Render::createDebuger()
{
#if DEBUG
std::cout << "\n";
LOG_DEBUG("Render", "Creating debuger");
VkDebugUtilsMessengerCreateInfoEXT debug_create_info = {};
debug_create_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
debug_create_info.messageSeverity =
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
debug_create_info.messageType =
VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
debug_create_info.pfnUserCallback = debugCallback;
debug_create_info.pUserData = nullptr;
// Get extension funtion pointer
auto vkCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)
vkGetInstanceProcAddr(_instance, "vkCreateDebugUtilsMessengerEXT");
// check if it's valid
if (!vkCreateDebugUtilsMessengerEXT) {
LOG_WARNING("Render", "Failed to set up debug messenger");
return;
}
// Create the debug messenger
VkResult result = vkCreateDebugUtilsMessengerEXT(_instance, &debug_create_info, nullptr, &_debug_messenger);
if (result != VK_SUCCESS)
{
LOG_WARNING("Render", "Failed to create debug messenger");
return;
}
LOG_DEBUG("Render", "Debuger created succesfully");
#endif // DEBUG
}
int Render::createSurface(HWND window, HINSTANCE instance)
{
std::cout << "\n";
LOG_DEBUG("Render", "Creating surface");
VkWin32SurfaceCreateInfoKHR create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
create_info.hwnd = window;
create_info.hinstance = instance;
VkResult result = vkCreateWin32SurfaceKHR(_instance, &create_info, nullptr, &_surface);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to create window surface");
return 0;
}
LOG_DEBUG("Render", "Surface created succesfully");
return 1;
}
int Render::createLogicalDevice(const std::vector<char*>& device_extensions)
{
std::cout << "\n";
LOG_DEBUG("Render", "Creating logical device");
std::vector<VkDeviceQueueCreateInfo> queue_create_infos;
int32_t queues[] = { _queue_indices.graphics_family, _queue_indices.present_family };
for (size_t i = 0; i < sizeof(queues) / sizeof(queues[0]); i++)
{
float queue_priority = 1.0f;
VkDeviceQueueCreateInfo queue_create_info = {};
queue_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queue_create_info.queueCount = 1;
queue_create_info.pQueuePriorities = &queue_priority;
queue_create_info.queueFamilyIndex = queues[i];
queue_create_infos.push_back(queue_create_info);
}
// Any mandatory features required
VkPhysicalDeviceFeatures device_features = {};
VkDeviceCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
create_info.queueCreateInfoCount = (uint32_t) queue_create_infos.size();
create_info.pQueueCreateInfos = queue_create_infos.data();
create_info.pEnabledFeatures = &device_features;
create_info.enabledLayerCount = 0;
create_info.ppEnabledLayerNames = nullptr;
create_info.enabledExtensionCount = device_extensions.size();
create_info.ppEnabledExtensionNames = device_extensions.data();
VkResult result = vkCreateDevice(_physical_device, &create_info, nullptr, &_device);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to create logical device!");
return 0;
}
vkGetDeviceQueue(_device, _queue_indices.graphics_family, 0, &_graphics_queue);
vkGetDeviceQueue(_device, _queue_indices.present_family, 0, &_present_queue);
LOG_DEBUG("Render", "Logical device created succesfully");
return 1;
}
int Render::createSwapChain(int width, int height)
{
std::cout << "\n";
LOG_DEBUG("Render", "Creating swapchain");
VkSurfaceCapabilitiesKHR capabilities;
std::vector<VkSurfaceFormatKHR> available_formats;
std::vector<VkPresentModeKHR> available_present_modes;
VkSurfaceFormatKHR surface_format = {};
VkPresentModeKHR surface_present_mode = VK_PRESENT_MODE_FIFO_KHR;
VkExtent2D surface_extent = { (uint32_t) width, (uint32_t) height };
uint32_t count;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(_physical_device, _surface, &capabilities);
vkGetPhysicalDeviceSurfaceFormatsKHR(_physical_device, _surface, &count, nullptr);
if (count != 0)
{
available_formats.resize(count);
vkGetPhysicalDeviceSurfaceFormatsKHR(_physical_device, _surface, &count, available_formats.data());
}
vkGetPhysicalDeviceSurfacePresentModesKHR(_physical_device, _surface, &count, nullptr);
if (count != 0)
{
available_present_modes.resize(count);
vkGetPhysicalDeviceSurfacePresentModesKHR(_physical_device, _surface, &count, available_present_modes.data());
}
surface_format = available_formats[0];
for (size_t i = 0; i < available_formats.size(); i++)
{
if (available_formats[i].format == VK_FORMAT_B8G8R8A8_SRGB &&
available_formats[i].colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
{
surface_format = available_formats[i];
}
}
for (size_t i = 0; i < available_present_modes.size(); i++)
{
if (available_present_modes[i] == VK_PRESENT_MODE_MAILBOX_KHR)
{
surface_present_mode = available_present_modes[i];
}
}
if (capabilities.currentExtent.width != UINT32_MAX)
{
surface_extent = capabilities.currentExtent;
}
else {
surface_extent.width = glm::clamp(surface_extent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width);
surface_extent.height = glm::clamp(surface_extent.height, capabilities.minImageExtent.height, capabilities.maxImageExtent.height);
}
uint32_t image_count = capabilities.minImageCount + 1;
if (capabilities.maxImageCount != 0 && image_count > capabilities.maxImageCount)
{
image_count = capabilities.maxImageCount;
}
VkSwapchainCreateInfoKHR create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
create_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
create_info.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
create_info.preTransform = capabilities.currentTransform;
create_info.surface = _surface;
create_info.minImageCount = image_count;
create_info.imageFormat = surface_format.format;
create_info.imageColorSpace = surface_format.colorSpace;
create_info.imageExtent = surface_extent;
create_info.presentMode = surface_present_mode;
create_info.imageArrayLayers = 1;
create_info.clipped = VK_TRUE;
create_info.oldSwapchain = VK_NULL_HANDLE;
uint32_t queue_family_indices[] = { _queue_indices.graphics_family, _queue_indices.present_family };
if (_queue_indices.graphics_family != _queue_indices.present_family)
{
// VK_SHARING_MODE_EXCLUSIVE should be better for performance
create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
create_info.queueFamilyIndexCount = sizeof(queue_family_indices) / sizeof(queue_family_indices[0]);
create_info.pQueueFamilyIndices = queue_family_indices;
}
else
{
create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
create_info.queueFamilyIndexCount = 0;
create_info.pQueueFamilyIndices = nullptr;
}
VkResult result = vkCreateSwapchainKHR(_device, &create_info, nullptr, &_swapchain);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to create SwapChain");
return 0;
}
vkGetSwapchainImagesKHR(_device, _swapchain, &image_count, nullptr);
_swapchain_images.resize(image_count);
vkGetSwapchainImagesKHR(_device, _swapchain, &image_count, _swapchain_images.data());
_swapchain_extent = surface_extent;
_swapchain_format = surface_format.format;
_swapchain_image_views.resize(image_count);
for (uint32_t i = 0; i < image_count; i++)
{
VkImageViewCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
create_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
create_info.image = _swapchain_images[i];
create_info.format = surface_format.format;
create_info.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
create_info.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
create_info.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
create_info.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
create_info.subresourceRange.baseMipLevel = 0;
create_info.subresourceRange.levelCount = 1;
create_info.subresourceRange.baseArrayLayer = 0;
create_info.subresourceRange.layerCount = 1;
VkResult result = vkCreateImageView(_device, &create_info, nullptr, &(_swapchain_image_views[i]));
if (result != VK_SUCCESS)
{
LOG_DEBUG("Render", "Failed creating image view %d", i);
return 0;
}
}
LOG_DEBUG("Render", "Swapchain created succesfully");
return 1;
}
int Render::createRenderPass()
{
std::cout << "\n";
LOG_DEBUG("Render", "Creating render pass");
VkAttachmentDescription color_attachment = {};
color_attachment.format = _swapchain_format;
color_attachment.samples = VK_SAMPLE_COUNT_1_BIT;
color_attachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
color_attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
color_attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
color_attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
color_attachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
color_attachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
VkAttachmentReference color_attachment_ref = {};
color_attachment_ref.attachment = 0;
color_attachment_ref.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkSubpassDescription subpass = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &color_attachment_ref;
VkRenderPassCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
create_info.attachmentCount = 1;
create_info.pAttachments = &color_attachment;
create_info.subpassCount = 1;
create_info.pSubpasses = &subpass;
VkResult result = vkCreateRenderPass(_device, &create_info, nullptr, &_render_pass);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating render pass");
return 0;
}
_swapchain_framebuffers.resize(_swapchain_image_views.size());
for (size_t i = 0; i < _swapchain_image_views.size(); i++) {
VkFramebufferCreateInfo framebuffer_info{};
framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebuffer_info.renderPass = _render_pass;
framebuffer_info.attachmentCount = 1;
framebuffer_info.pAttachments = &(_swapchain_image_views[i]);
framebuffer_info.width = _swapchain_extent.width;
framebuffer_info.height = _swapchain_extent.height;
framebuffer_info.layers = 1;
result = vkCreateFramebuffer(_device, &framebuffer_info, nullptr, &_swapchain_framebuffers[i]);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating framebuffer");
return 0;
}
}
LOG_DEBUG("Render", "Render pass created succesfully");
return 1;
}
int Render::createGraphicsPipeline()
{
std::cout << "\n";
LOG_DEBUG("Render", "Creating ghrapic pipeline");
std::vector<char> vertex_shader_code = Utils::readFile("../../shaders/vert.spv");
std::vector<char> fragment_shader_code = Utils::readFile("../../shaders/frag.spv");
if (vertex_shader_code.size() == 0 || fragment_shader_code.size() == 0)
{
LOG_ERROR("Render", "Failed opening shader files");
return 0;
}
VkShaderModule vertex_shader_module = createShaderModule(vertex_shader_code);
VkShaderModule fragment_shader_module = createShaderModule(fragment_shader_code);
VkPipelineShaderStageCreateInfo vertex_stage_create_info = {};
vertex_stage_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
vertex_stage_create_info.stage = VK_SHADER_STAGE_VERTEX_BIT;
vertex_stage_create_info.module = vertex_shader_module;
vertex_stage_create_info.pName = "main";
VkPipelineShaderStageCreateInfo fragment_stage_create_info = {};
fragment_stage_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
fragment_stage_create_info.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fragment_stage_create_info.module = fragment_shader_module;
fragment_stage_create_info.pName = "main";
VkPipelineShaderStageCreateInfo shader_stages[] = { vertex_stage_create_info, fragment_stage_create_info };
VkVertexInputBindingDescription positions_binding_description = {};
positions_binding_description.binding = 0;
positions_binding_description.stride = sizeof(glm::vec3);
positions_binding_description.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
VkVertexInputBindingDescription colors_binding_description = {};
colors_binding_description.binding = 1;
colors_binding_description.stride = sizeof(glm::vec3);
colors_binding_description.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
VkVertexInputAttributeDescription positions_attribute_description = {};
positions_attribute_description.binding = 0;
positions_attribute_description.location = 0;
positions_attribute_description.offset = 0;
positions_attribute_description.format = VK_FORMAT_R32G32B32_SFLOAT;
VkVertexInputAttributeDescription colors_attribute_description = {};
colors_attribute_description.binding = 1;
colors_attribute_description.location = 1;
colors_attribute_description.offset = 0;
colors_attribute_description.format = VK_FORMAT_R32G32B32_SFLOAT;
VkVertexInputBindingDescription bindings[] = { positions_binding_description, colors_binding_description };
VkVertexInputAttributeDescription attributes[] = { positions_attribute_description, colors_attribute_description };
VkPipelineVertexInputStateCreateInfo vertex_input_info{};
vertex_input_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertex_input_info.vertexBindingDescriptionCount = sizeof(bindings) / sizeof(VkVertexInputBindingDescription);
vertex_input_info.pVertexBindingDescriptions = bindings;
vertex_input_info.vertexAttributeDescriptionCount = sizeof(attributes) / sizeof(VkVertexInputAttributeDescription);;
vertex_input_info.pVertexAttributeDescriptions = attributes;
VkPipelineInputAssemblyStateCreateInfo input_assembly = {};
input_assembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
input_assembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
input_assembly.primitiveRestartEnable = VK_FALSE;
VkViewport viewport = {};
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = _swapchain_extent.width;
viewport.height = _swapchain_extent.height;
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
VkRect2D scissor = {};
scissor.offset = { 0, 0 };
scissor.extent = _swapchain_extent;
VkPipelineViewportStateCreateInfo viewport_info = {};
viewport_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewport_info.viewportCount = 1;
viewport_info.pViewports = &viewport;
viewport_info.scissorCount = 1;
viewport_info.pScissors = &scissor;
VkPipelineRasterizationStateCreateInfo rasterizer = {};
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterizer.depthClampEnable = VK_FALSE;
rasterizer.rasterizerDiscardEnable = VK_FALSE;
rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
rasterizer.lineWidth = 1.0f;
rasterizer.cullMode = VK_CULL_MODE_BACK_BIT;
rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
rasterizer.depthBiasEnable = VK_FALSE;
rasterizer.depthBiasConstantFactor = 0.0f;
rasterizer.depthBiasClamp = 0.0f;
rasterizer.depthBiasSlopeFactor = 0.0f;
VkPipelineMultisampleStateCreateInfo multisampler = {};
multisampler.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
multisampler.sampleShadingEnable = VK_FALSE;
multisampler.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
multisampler.minSampleShading = 1.0f;
multisampler.pSampleMask = nullptr;
multisampler.alphaToCoverageEnable = VK_FALSE;
multisampler.alphaToOneEnable = VK_FALSE;
VkPipelineColorBlendAttachmentState color_blend_attachment = {};
color_blend_attachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
color_blend_attachment.blendEnable = VK_FALSE;
VkPipelineColorBlendStateCreateInfo color_blending = {};
color_blending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
color_blending.logicOpEnable = VK_FALSE;
color_blending.attachmentCount = 1;
color_blending.pAttachments = &color_blend_attachment;
VkDescriptorSetLayoutBinding uniform_layour_binding = {};
uniform_layour_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
uniform_layour_binding.binding = 0;
uniform_layour_binding.descriptorCount = 1;
uniform_layour_binding.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
VkDescriptorSetLayoutCreateInfo uniform_layout_create_info = {};
uniform_layout_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
uniform_layout_create_info.bindingCount = 1;
uniform_layout_create_info.pBindings = &uniform_layour_binding;
VkResult result = vkCreateDescriptorSetLayout(_device, &uniform_layout_create_info, nullptr, &_uniform_descriptor_layout);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating uniform descriptor layuout");
return 0;
}
VkPipelineLayoutCreateInfo pipeline_layout_create_info = {};
pipeline_layout_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipeline_layout_create_info.setLayoutCount = 1;
pipeline_layout_create_info.pSetLayouts = &_uniform_descriptor_layout;
result = vkCreatePipelineLayout(_device, &pipeline_layout_create_info, nullptr, &_pipeline_layout);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating pipeline layout");
return 0;
}
VkGraphicsPipelineCreateInfo pipeline_info = {};
pipeline_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipeline_info.stageCount = 2;
pipeline_info.pStages = shader_stages;
pipeline_info.pVertexInputState = &vertex_input_info;
pipeline_info.pInputAssemblyState = &input_assembly;
pipeline_info.pViewportState = &viewport_info;
pipeline_info.pRasterizationState = &rasterizer;
pipeline_info.pMultisampleState = &multisampler;
pipeline_info.pColorBlendState = &color_blending;
pipeline_info.layout = _pipeline_layout;
pipeline_info.renderPass = _render_pass;
pipeline_info.subpass = 0;
result = vkCreateGraphicsPipelines(_device, VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &_graphics_pipeline);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating graphics pipeline");
return 0;
}
vkDestroyShaderModule(_device, vertex_shader_module, nullptr);
vkDestroyShaderModule(_device, fragment_shader_module, nullptr);
LOG_DEBUG("Render", "Ghrapic pipeline created succesfully");
return 1;
}
int Render::createVertexBuffers()
{
std::cout << "\n";
LOG_DEBUG("Render", "Creating vertex buffer");
void* buffer_memory;
glm::vec3 positions[] = {
{-0.5f, -0.5f, -0.5f},
{ 0.5f, -0.5f, -0.5f},
{ 0.5f, 0.5f, -0.5f},
{-0.5f, 0.5f, -0.5f},
{-0.5f, -0.5f, 0.5f},
{ 0.5f, -0.5f, 0.5f},
{ 0.5f, 0.5f, 0.5f},
{-0.5f, 0.5f, 0.5f},
};
glm::vec3 colors[] = {
{0.0f, 0.0f, 1.0f},
{1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f},
{1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f},
{1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f},
{1.0f, 0.0f, 0.0f},
};
uint16_t indices[] = {
0, 1, 3, 3, 1, 2,
1, 5, 2, 2, 5, 6,
5, 4, 6, 6, 4, 7,
4, 0, 7, 7, 0, 3,
3, 2, 7, 7, 2, 6,
4, 5, 0, 0, 5, 1
};
//////////////////
// POSITIONS
VkBufferCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
create_info.size = sizeof(positions);
create_info.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
VkResult result = vkCreateBuffer(_device, &create_info, nullptr, &_positions_vertex_buffer);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating vertex buffer");
return 0;
}
VkMemoryRequirements memory_requirements;
vkGetBufferMemoryRequirements(_device, _positions_vertex_buffer, &memory_requirements);
VkMemoryAllocateInfo allocate_info{};
allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocate_info.allocationSize = memory_requirements.size;
allocate_info.memoryTypeIndex = findMemoryType(memory_requirements.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
result = vkAllocateMemory(_device, &allocate_info, nullptr, &_positions_buffer_memory);
if (result != VK_SUCCESS) {
LOG_ERROR("Render", "Failed to allocate vertex buffer memory!");
return 0;
}
vkBindBufferMemory(_device, _positions_vertex_buffer, _positions_buffer_memory, 0);
vkMapMemory(_device, _positions_buffer_memory, 0, create_info.size, 0, &buffer_memory);
memcpy(buffer_memory, positions, (size_t) create_info.size);
vkUnmapMemory(_device, _positions_buffer_memory);
//////////////////
// COLORS
create_info.size = sizeof(colors);
result = vkCreateBuffer(_device, &create_info, nullptr, &_colors_vertex_buffer);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating vertex buffer");
return 0;
}
vkGetBufferMemoryRequirements(_device, _colors_vertex_buffer, &memory_requirements);
allocate_info.allocationSize = memory_requirements.size;
result = vkAllocateMemory(_device, &allocate_info, nullptr, &_colors_buffer_memory);
if (result != VK_SUCCESS) {
LOG_ERROR("Render", "Failed to allocate vertex buffer memory!");
return 0;
}
vkBindBufferMemory(_device, _colors_vertex_buffer, _colors_buffer_memory, 0);
vkMapMemory(_device, _colors_buffer_memory, 0, create_info.size, 0, &buffer_memory);
memcpy(buffer_memory, colors, (size_t) create_info.size);
vkUnmapMemory(_device, _colors_buffer_memory);
// --------------------------------
// INDICES
create_info.size = sizeof(indices);
create_info.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
result = vkCreateBuffer(_device, &create_info, nullptr, &_indices_buffer);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating indices buffer");
return 0;
}
vkGetBufferMemoryRequirements(_device, _indices_buffer, &memory_requirements);
allocate_info.allocationSize = memory_requirements.size;
result = vkAllocateMemory(_device, &allocate_info, nullptr, &_indices_buffer_memory);
if (result != VK_SUCCESS) {
LOG_ERROR("Render", "Failed to allocate indices buffer memory!");
return 0;
}
vkBindBufferMemory(_device, _indices_buffer, _indices_buffer_memory, 0);
vkMapMemory(_device, _indices_buffer_memory, 0, create_info.size, 0, &buffer_memory);
memcpy(buffer_memory, indices, (size_t) create_info.size);
vkUnmapMemory(_device, _indices_buffer_memory);
////////////////////
// UNIFORM BUFFER
create_info.size = sizeof(UniformBufferObject);
create_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
result = vkCreateBuffer(_device, &create_info, nullptr, &_uniform_buffer);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating unifrom buffer");
return 0;
}
vkGetBufferMemoryRequirements(_device, _uniform_buffer, &memory_requirements);
allocate_info.allocationSize = memory_requirements.size;
result = vkAllocateMemory(_device, &allocate_info, nullptr, &_uniform_buffer_memory);
if (result != VK_SUCCESS) {
LOG_ERROR("Render", "Failed to allocate uniform buffer memory!");
return 0;
}
vkBindBufferMemory(_device, _uniform_buffer, _uniform_buffer_memory, 0);
////////////////////
// DESCRIPTORS
VkDescriptorPoolSize pool_size = {};
pool_size.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
pool_size.descriptorCount = 1;
VkDescriptorPoolCreateInfo pool_create_info = {};
pool_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
pool_create_info.poolSizeCount = 1;
pool_create_info.pPoolSizes = &pool_size;
pool_create_info.maxSets = 1;
result = vkCreateDescriptorPool(_device, &pool_create_info, nullptr, &_descriptor_pool);
if (result != VK_SUCCESS) {
LOG_ERROR("Render", "Failed to create descriptor pool!");
return 0;
}
VkDescriptorSetAllocateInfo descriptor_allocate_info = {};
descriptor_allocate_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
descriptor_allocate_info.descriptorPool = _descriptor_pool;
descriptor_allocate_info.descriptorSetCount = 1;
descriptor_allocate_info.pSetLayouts = &_uniform_descriptor_layout;
result = vkAllocateDescriptorSets(_device, &descriptor_allocate_info, &_descriptor_set);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to create descriptor set!");
return 0;
}
VkDescriptorBufferInfo descriptor_buffer_info = {};
descriptor_buffer_info.buffer = _uniform_buffer;
descriptor_buffer_info.offset = 0;
descriptor_buffer_info.range = sizeof(UniformBufferObject);
VkWriteDescriptorSet descriptor_write = {};
descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
descriptor_write.dstSet = _descriptor_set;
descriptor_write.dstBinding = 0;
descriptor_write.dstArrayElement = 0;
descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
descriptor_write.descriptorCount = 1;
descriptor_write.pBufferInfo = &descriptor_buffer_info;
vkUpdateDescriptorSets(_device, 1, &descriptor_write, 0, nullptr);
LOG_DEBUG("Render", "Vertex buffers created succesfully");
return 1;
}
int Render::createCommandBuffer()
{
std::cout << "\n";
LOG_DEBUG("Render", "Creating command buffer");
VkCommandPoolCreateInfo pool_info = {};
pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
pool_info.queueFamilyIndex = _queue_indices.graphics_family;
pool_info.flags = 0;
VkResult result = vkCreateCommandPool(_device, &pool_info, nullptr, &_command_pool);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating command pool");
return 0;
}
_command_buffers.resize(_swapchain_framebuffers.size());
VkCommandBufferAllocateInfo allocate_info = {};
allocate_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocate_info.commandPool = _command_pool;
allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocate_info.commandBufferCount = (uint32_t) _command_buffers.size();
result = vkAllocateCommandBuffers(_device, &allocate_info, _command_buffers.data());
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to allocate command buffers");
return 0;
}
for (size_t i = 0; i < _command_buffers.size(); i++)
{
VkCommandBufferBeginInfo begin_info = {};
begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
result = vkBeginCommandBuffer(_command_buffers[i], &begin_info);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to begin recording command buffer %d", i);
return 0;
}
VkClearValue clear_color = {{{ 0.06f, 0.06f, 0.06f, 1.0f }}};
VkRenderPassBeginInfo render_pass_info = {};
render_pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
render_pass_info.renderPass = _render_pass;
render_pass_info.framebuffer = _swapchain_framebuffers[i];
render_pass_info.renderArea.offset = { 0, 0 };
render_pass_info.renderArea.extent = _swapchain_extent;
render_pass_info.clearValueCount = 1;
render_pass_info.pClearValues = &clear_color;
vkCmdBeginRenderPass(_command_buffers[i], &render_pass_info, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(_command_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, _graphics_pipeline);
VkBuffer vertex_buffers[] = { _positions_vertex_buffer, _colors_vertex_buffer };
VkDeviceSize offsets[] = { 0, 0 };
vkCmdBindVertexBuffers(_command_buffers[i], 0, 2, vertex_buffers, offsets);
vkCmdBindDescriptorSets(_command_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, _pipeline_layout, 0, 1, &_descriptor_set, 0, nullptr);
vkCmdBindIndexBuffer(_command_buffers[i], _indices_buffer, 0, VK_INDEX_TYPE_UINT16);
// HARDCODED INDEX COUNT
vkCmdDrawIndexed(_command_buffers[i], 36, 1, 0, 0, 0);
vkCmdEndRenderPass(_command_buffers[i]);
result = vkEndCommandBuffer(_command_buffers[i]);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed to record command buffer");
return 0;
}
}
VkSemaphoreCreateInfo semaphore_info = {};
semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
VkFenceCreateInfo fence_info = {};
fence_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fence_info.flags = VK_FENCE_CREATE_SIGNALED_BIT;
if (vkCreateSemaphore(_device, &semaphore_info, nullptr, &_image_ready_semaphore) != VK_SUCCESS ||
vkCreateSemaphore(_device, &semaphore_info, nullptr, &_render_finished_semaphore) != VK_SUCCESS ||
vkCreateFence(_device, &fence_info, nullptr, &_frame_fence) != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating semaphore");
return 0;
}
LOG_DEBUG("Render", "Command buffer created succesfully");
return 1;
}
int Render::recreateSwapChain()
{
std::cout << "\n";
LOG_DEBUG("Render", "Recreating swapchain");
vkDeviceWaitIdle(_device);
cleanup();
RECT rect;
GetClientRect(_window, &rect);
if (!createSwapChain(rect.right - rect.left, rect.bottom - rect.top))
{
return 0;
}
if (!createRenderPass())
{
return 0;
}
if (!createGraphicsPipeline())
{
return 0;
}
if (!createCommandBuffer())
{
return 0;
}
LOG_DEBUG("Render", "Swapchain recreated susccefully");
return 1;
}
void Render::update()
{
static std::chrono::steady_clock::time_point start_time = std::chrono::high_resolution_clock::now();
std::chrono::steady_clock::time_point current_time = std::chrono::high_resolution_clock::now();
float time = std::chrono::duration<float, std::chrono::seconds::period>(current_time - start_time).count();
UniformBufferObject uniform = {};
uniform.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
uniform.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
uniform.projection = glm::perspective(glm::radians(45.0f), _swapchain_extent.width / (float) _swapchain_extent.height, 0.1f, 10.0f);
uniform.projection[1][1] *= -1;
void* data;
vkMapMemory(_device, _uniform_buffer_memory, 0, sizeof(uniform), 0, &data);
memcpy(data, &uniform, sizeof(uniform));
vkUnmapMemory(_device, _uniform_buffer_memory);
}
int Render::pickPhysicalDevice(const std::vector<char*>& device_extensions)
{
std::cout << "\n";
LOG_DEBUG("Render", "Creating physical device");
uint32_t count;
std::vector<VkPhysicalDevice> devices;
// Query number of available devices
vkEnumeratePhysicalDevices(_instance, &count, nullptr);
if (count < 1)
{
LOG_ERROR("Render", "Failed to find GPUs with Vulkan support");
return 0;
}
// Query the "real"devices
devices.resize(count);
vkEnumeratePhysicalDevices(_instance, &count, &(devices[0]));
for (size_t i = 0; i < devices.size() && _physical_device == VK_NULL_HANDLE && !_queue_indices.isValid(); i++)
{
VkPhysicalDeviceProperties properties;
vkGetPhysicalDeviceProperties(devices[i], &properties);
// We just want dedicated GPUs
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
{
uint32_t count;
QueueFamilyIndices indices = {};
std::vector<VkQueueFamilyProperties> queues;
// Query count of queue families
vkGetPhysicalDeviceQueueFamilyProperties(devices[i], &count, nullptr);
// Query the queue family properties
queues.resize(count);
vkGetPhysicalDeviceQueueFamilyProperties(devices[i], &count, &(queues[0]));
for (int32_t j = 0; j < count; j++)
{
// Check if the queue supports graphic commands
if (queues[j].queueFlags & VK_QUEUE_GRAPHICS_BIT)
{
indices.graphics_family = j;
}
VkBool32 present_support = false;
vkGetPhysicalDeviceSurfaceSupportKHR(devices[i], j, _surface, &present_support);
if (present_support)
{
indices.present_family = j;
}
}
if (indices.isValid())
{
_queue_indices = indices;
_physical_device = devices[i];
LOG_DEBUG("Render", "Running on: %s", properties.deviceName);
}
}
}
if (_physical_device == VK_NULL_HANDLE)
{
LOG_ERROR("Render", "Failed to find any suitable GPU");
return 0;
}
return 1;
}
uint32_t Render::findMemoryType(uint32_t filter, VkMemoryPropertyFlags properties)
{
VkPhysicalDeviceMemoryProperties memory_properties;
vkGetPhysicalDeviceMemoryProperties(_physical_device, &memory_properties);
for (uint32_t i = 0; i < memory_properties.memoryTypeCount; i++) {
if ((filter & (1 << i)) && (memory_properties.memoryTypes[i].propertyFlags & properties) == properties) {
return i;
}
}
LOG_ERROR("Render", "Unable to fins right memory type");
return UINT32_MAX;
}
VkShaderModule Render::createShaderModule(const std::vector<char>& code) const
{
VkShaderModuleCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
create_info.codeSize = code.size();
create_info.pCode = reinterpret_cast<const uint32_t*>(code.data());
VkShaderModule shader_module = {};
VkResult result = vkCreateShaderModule(_device, &create_info, nullptr, &shader_module);
if (result != VK_SUCCESS)
{
LOG_ERROR("Render", "Failed creating shader module");
return VkShaderModule();
}
return shader_module;
}
void Render::cleanup()
{
for (size_t i = 0; i < _swapchain_image_views.size(); i++)
{
vkDestroyImageView(_device, _swapchain_image_views[i], nullptr);
vkDestroyFramebuffer(_device, _swapchain_framebuffers[i], nullptr);
}
vkFreeCommandBuffers(_device, _command_pool, static_cast<uint32_t>(_command_buffers.size()), _command_buffers.data());
vkDestroyPipeline(_device, _graphics_pipeline, nullptr);
vkDestroyPipelineLayout(_device, _pipeline_layout, nullptr);
vkDestroyRenderPass(_device, _render_pass, nullptr);
vkDestroySwapchainKHR(_device, _swapchain, nullptr);
}
| 34.646192 | 161 | 0.755407 | [
"render",
"vector",
"model"
] |
5113211d29a7235bd0f53ad704c8763fd7246f03 | 2,045 | cpp | C++ | src/SortList.cpp | lzz5235/leetcode | 8713b7924a84a0c7d6887e1c8052738b5a778d1f | [
"MIT"
] | null | null | null | src/SortList.cpp | lzz5235/leetcode | 8713b7924a84a0c7d6887e1c8052738b5a778d1f | [
"MIT"
] | null | null | null | src/SortList.cpp | lzz5235/leetcode | 8713b7924a84a0c7d6887e1c8052738b5a778d1f | [
"MIT"
] | null | null | null | //Sort a linked list in O(n log n) time using constant space complexity.
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdint.h>
#include <assert.h>
#include <queue>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
ListNode *sortList(ListNode *head) {
if(head==NULL||head->next==NULL)
return head;
ListNode *fast = head;
ListNode *slow = head;
while(fast->next!=NULL&&fast->next->next!=NULL){
fast = fast->next->next;
slow = slow->next;
}
//cut
fast = slow;
slow = slow->next;
fast->next=NULL;
//recurse
ListNode *l1 = sortList(head);
ListNode *l2 = sortList(slow);
return mergeTwoLists(l1,l2);
}
private:
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
if(l1==NULL)
return l2;
if(l2==NULL)
return l1;
ListNode dummy(-1);
ListNode *temp = &dummy;
for(;l1!=NULL&&l2!=NULL;temp=temp->next){
if(l1->val > l2->val){
temp->next = l2;
l2 = l2->next;
}
else{
temp->next = l1;
l1 = l1->next;
}
}
if(l1==NULL)
temp->next = l2;
else
temp->next = l1;
return dummy.next;
}
};
int main()
{
ListNode *a1 = new ListNode(1);
ListNode *a2 = new ListNode(8);
ListNode *c1 = new ListNode(5);
ListNode *c2 = new ListNode(9);
ListNode *c3 = new ListNode(11);
ListNode *b1 = new ListNode(2);
ListNode *b2 = new ListNode(6);
ListNode *b3 = new ListNode(9);
ListNode *d1 = new ListNode(0);
ListNode *d2 = new ListNode(1);
ListNode *d3 = new ListNode(3);
a1->next = a2;
a2->next = c1;
c1->next = c2;
c2->next = c3;
c3->next = b1;
b1->next = b2;
b2->next = b3;
b3->next = d1;
d1->next = d2;
d2->next = d3;
d3->next = NULL;
Solution solute;
ListNode * head = solute.sortList(a1);
while(head!=NULL){
printf("%d\t",head->val);
head = head->next;
}
return 0;
} | 19.854369 | 73 | 0.578973 | [
"vector"
] |
511bade1cc8dc07eadde628feda2c477440c3f7d | 6,183 | cpp | C++ | src/dawn_native/SpirvUtils.cpp | mingmingtasd/Dawn | 3668d352bc5fe13af27dc178d203f67032537a7f | [
"Apache-2.0"
] | null | null | null | src/dawn_native/SpirvUtils.cpp | mingmingtasd/Dawn | 3668d352bc5fe13af27dc178d203f67032537a7f | [
"Apache-2.0"
] | null | null | null | src/dawn_native/SpirvUtils.cpp | mingmingtasd/Dawn | 3668d352bc5fe13af27dc178d203f67032537a7f | [
"Apache-2.0"
] | null | null | null | // Copyright 2020 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "dawn_native/SpirvUtils.h"
namespace dawn_native {
spv::ExecutionModel ShaderStageToExecutionModel(SingleShaderStage stage) {
switch (stage) {
case SingleShaderStage::Vertex:
return spv::ExecutionModelVertex;
case SingleShaderStage::Fragment:
return spv::ExecutionModelFragment;
case SingleShaderStage::Compute:
return spv::ExecutionModelGLCompute;
}
}
SingleShaderStage ExecutionModelToShaderStage(spv::ExecutionModel model) {
switch (model) {
case spv::ExecutionModelVertex:
return SingleShaderStage::Vertex;
case spv::ExecutionModelFragment:
return SingleShaderStage::Fragment;
case spv::ExecutionModelGLCompute:
return SingleShaderStage::Compute;
default:
UNREACHABLE();
}
}
wgpu::TextureViewDimension SpirvDimToTextureViewDimension(spv::Dim dim, bool arrayed) {
switch (dim) {
case spv::Dim::Dim1D:
return wgpu::TextureViewDimension::e1D;
case spv::Dim::Dim2D:
if (arrayed) {
return wgpu::TextureViewDimension::e2DArray;
} else {
return wgpu::TextureViewDimension::e2D;
}
case spv::Dim::Dim3D:
return wgpu::TextureViewDimension::e3D;
case spv::Dim::DimCube:
if (arrayed) {
return wgpu::TextureViewDimension::CubeArray;
} else {
return wgpu::TextureViewDimension::Cube;
}
default:
UNREACHABLE();
}
}
wgpu::TextureFormat SpirvImageFormatToTextureFormat(spv::ImageFormat format) {
switch (format) {
case spv::ImageFormatR8:
return wgpu::TextureFormat::R8Unorm;
case spv::ImageFormatR8Snorm:
return wgpu::TextureFormat::R8Snorm;
case spv::ImageFormatR8ui:
return wgpu::TextureFormat::R8Uint;
case spv::ImageFormatR8i:
return wgpu::TextureFormat::R8Sint;
case spv::ImageFormatR16ui:
return wgpu::TextureFormat::R16Uint;
case spv::ImageFormatR16i:
return wgpu::TextureFormat::R16Sint;
case spv::ImageFormatR16f:
return wgpu::TextureFormat::R16Float;
case spv::ImageFormatRg8:
return wgpu::TextureFormat::RG8Unorm;
case spv::ImageFormatRg8Snorm:
return wgpu::TextureFormat::RG8Snorm;
case spv::ImageFormatRg8ui:
return wgpu::TextureFormat::RG8Uint;
case spv::ImageFormatRg8i:
return wgpu::TextureFormat::RG8Sint;
case spv::ImageFormatR32f:
return wgpu::TextureFormat::R32Float;
case spv::ImageFormatR32ui:
return wgpu::TextureFormat::R32Uint;
case spv::ImageFormatR32i:
return wgpu::TextureFormat::R32Sint;
case spv::ImageFormatRg16ui:
return wgpu::TextureFormat::RG16Uint;
case spv::ImageFormatRg16i:
return wgpu::TextureFormat::RG16Sint;
case spv::ImageFormatRg16f:
return wgpu::TextureFormat::RG16Float;
case spv::ImageFormatRgba8:
return wgpu::TextureFormat::RGBA8Unorm;
case spv::ImageFormatRgba8Snorm:
return wgpu::TextureFormat::RGBA8Snorm;
case spv::ImageFormatRgba8ui:
return wgpu::TextureFormat::RGBA8Uint;
case spv::ImageFormatRgba8i:
return wgpu::TextureFormat::RGBA8Sint;
case spv::ImageFormatRgb10A2:
return wgpu::TextureFormat::RGB10A2Unorm;
case spv::ImageFormatR11fG11fB10f:
return wgpu::TextureFormat::RG11B10Ufloat;
case spv::ImageFormatRg32f:
return wgpu::TextureFormat::RG32Float;
case spv::ImageFormatRg32ui:
return wgpu::TextureFormat::RG32Uint;
case spv::ImageFormatRg32i:
return wgpu::TextureFormat::RG32Sint;
case spv::ImageFormatRgba16ui:
return wgpu::TextureFormat::RGBA16Uint;
case spv::ImageFormatRgba16i:
return wgpu::TextureFormat::RGBA16Sint;
case spv::ImageFormatRgba16f:
return wgpu::TextureFormat::RGBA16Float;
case spv::ImageFormatRgba32f:
return wgpu::TextureFormat::RGBA32Float;
case spv::ImageFormatRgba32ui:
return wgpu::TextureFormat::RGBA32Uint;
case spv::ImageFormatRgba32i:
return wgpu::TextureFormat::RGBA32Sint;
default:
return wgpu::TextureFormat::Undefined;
}
}
wgpu::TextureComponentType SpirvBaseTypeToTextureComponentType(
spirv_cross::SPIRType::BaseType spirvBaseType) {
switch (spirvBaseType) {
case spirv_cross::SPIRType::Float:
return wgpu::TextureComponentType::Float;
case spirv_cross::SPIRType::Int:
return wgpu::TextureComponentType::Sint;
case spirv_cross::SPIRType::UInt:
return wgpu::TextureComponentType::Uint;
default:
UNREACHABLE();
}
}
} // namespace dawn_native
| 40.677632 | 91 | 0.589681 | [
"model"
] |
511ef7bfb01d5ca199453fdafe24479c7e306a36 | 8,160 | cpp | C++ | src/nbla/function/generic/instance_normalization.cpp | daniel-falk/nnabla | 3fe132ea52dc10521cc029a5d6ba8f565cf65ccf | [
"Apache-2.0"
] | 2,792 | 2017-06-26T13:05:44.000Z | 2022-03-28T07:55:26.000Z | src/nbla/function/generic/instance_normalization.cpp | daniel-falk/nnabla | 3fe132ea52dc10521cc029a5d6ba8f565cf65ccf | [
"Apache-2.0"
] | 138 | 2017-06-27T07:04:44.000Z | 2022-02-28T01:37:15.000Z | src/nbla/function/generic/instance_normalization.cpp | daniel-falk/nnabla | 3fe132ea52dc10521cc029a5d6ba8f565cf65ccf | [
"Apache-2.0"
] | 380 | 2017-06-26T13:23:52.000Z | 2022-03-25T16:51:30.000Z | // Copyright 2021 Sony Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <nbla/array.hpp>
#include <nbla/common.hpp>
#include <nbla/function/instance_normalization.hpp>
#include <nbla/variable.hpp>
#include <nbla/function/broadcast.hpp>
#include <nbla/function/tensor_normalization.hpp>
#include <nbla/imperative.hpp>
namespace nbla {
NBLA_REGISTER_FUNCTION_SOURCE(InstanceNormalization, int, const vector<int> &,
float, bool, bool);
template <typename T>
void InstanceNormalization<T>::setup_impl(const Variables &inputs,
const Variables &outputs) {
const int n_inputs = inputs.size();
const auto x_shape = inputs[0]->shape();
const int ndim = x_shape.size();
beta_idx_ = no_bias_ ? -1 : 1;
gamma_idx_ = no_scale_ ? -1 : no_bias_ ? 1 : 2;
// check inputs size
int n_inputs_expect = 1;
if (!no_scale_)
n_inputs_expect++;
if (!no_bias_)
n_inputs_expect++;
NBLA_CHECK(n_inputs == n_inputs_expect, error_code::value,
"Number of inputs must be 1, 2 or 3.");
// check chennel_axis
NBLA_CHECK(0 <= channel_axis_ && channel_axis_ < ndim, error_code::value,
"channel_axis must be in the range of [0, ndim). channel_axis : "
"%d, ndim: {}.",
channel_axis_, ndim);
// check batch_axis
for (size_t i = 0; i < batch_axis_.size(); i++) {
const auto ba = batch_axis_[i];
NBLA_CHECK(0 <= ba && ba < ndim, error_code::value,
"each element of batch_axis must be in the range of [0, ndim). "
"batch_axis[%d] : %d, ndim: {}.",
i, ba, ndim);
}
// check whether broadcast is needed or not.
// Unlike layer_norm and group_norm, only instance_norm can use bn scale bias
// & scale adaptation by broadcasting channel axis to channel * batch axis.
// (like [1, C, 1, 1] -> [N, C, 1, 1])
vector<int> adapt_shape(ndim, 1);
for (auto ba : batch_axis_) {
adapt_shape[ba] = x_shape[ba];
}
adapt_shape[channel_axis_] = x_shape[channel_axis_];
// check param shapes
const auto beta = no_bias_ ? nullptr : inputs[beta_idx_];
const auto gamma = no_scale_ ? nullptr : inputs[gamma_idx_];
// beta
need_beta_broadcast_ = false;
if (beta) {
const auto beta_shape = beta->shape();
for (size_t i = 0; i < beta_shape.size(); i++) {
if (beta_shape[i] != adapt_shape[i]) {
need_beta_broadcast_ = true;
NBLA_CHECK(beta_shape[channel_axis_] == adapt_shape[channel_axis_],
error_code::value,
"channel size of beta: %d != channel size of x (%d).",
beta_shape[channel_axis_], adapt_shape[channel_axis_]);
break;
}
}
}
// gamma
need_gamma_broadcast_ = false;
if (gamma) {
const auto gamma_shape = gamma->shape();
for (size_t i = 0; i < gamma_shape.size(); i++) {
if (gamma_shape[i] != adapt_shape[i]) {
need_gamma_broadcast_ = true;
NBLA_CHECK(gamma_shape[channel_axis_] == adapt_shape[channel_axis_],
error_code::value,
"channel size of gamma: %d != channel size of x (%d).",
gamma_shape[channel_axis_], adapt_shape[channel_axis_]);
break;
}
}
}
// reshape outputs
outputs[0]->reshape(x_shape, true);
Shape_t out_param_shape;
for (int i = 0; i < ndim; i++) {
out_param_shape.push_back(adapt_shape[i]);
}
if (outputs.size() == 3) {
outputs[1]->reshape(out_param_shape, true); // batch mean
outputs[2]->reshape(out_param_shape, true); // batch var
}
// functions
if (need_beta_broadcast_) {
f_broadcast_beta_ = create_Broadcast(ctx_, adapt_shape);
}
if (need_gamma_broadcast_) {
f_broadcast_gamma_ = create_Broadcast(ctx_, adapt_shape);
}
auto tn_axes = batch_axis_;
tn_axes.push_back(channel_axis_);
f_tensor_norm_ =
create_TensorNormalization(ctx_, tn_axes, eps_, no_scale_, no_bias_);
// setup tensor_norm
auto x = inputs[0];
// tensor_norm variables
Variable beta_bc, gamma_bc;
Variable *tn_beta = beta;
Variable *tn_gamma = gamma;
// broadcast
if (beta && need_beta_broadcast_) {
f_broadcast_beta_->setup(Variables{beta}, Variables{&beta_bc});
tn_beta = &beta_bc;
}
if (gamma && need_gamma_broadcast_) {
f_broadcast_gamma_->setup(Variables{gamma}, Variables{&gamma_bc});
tn_gamma = &gamma_bc;
}
// tensor_norm
auto tn_inputs = Variables{x};
if (beta)
tn_inputs.push_back(tn_beta);
if (gamma)
tn_inputs.push_back(tn_gamma);
f_tensor_norm_->setup(tn_inputs, outputs);
}
template <typename T>
void InstanceNormalization<T>::forward_impl(const Variables &inputs,
const Variables &outputs) {
auto x = inputs[0];
const auto beta = no_bias_ ? nullptr : inputs[beta_idx_];
const auto gamma = no_scale_ ? nullptr : inputs[gamma_idx_];
// tensor_norm variables
Variable beta_bc, gamma_bc;
Variable *tn_beta = beta;
Variable *tn_gamma = gamma;
// broadcast
if (beta && need_beta_broadcast_) {
nbla::execute(f_broadcast_beta_, Variables{beta}, Variables{&beta_bc});
tn_beta = &beta_bc;
}
if (gamma && need_gamma_broadcast_) {
nbla::execute(f_broadcast_gamma_, Variables{gamma}, Variables{&gamma_bc});
tn_gamma = &gamma_bc;
}
// tensor_norm
auto tn_inputs = Variables{x};
if (beta)
tn_inputs.push_back(tn_beta);
if (gamma)
tn_inputs.push_back(tn_gamma);
f_tensor_norm_->forward(tn_inputs, outputs);
}
template <typename T>
void InstanceNormalization<T>::backward_impl(const Variables &inputs,
const Variables &outputs,
const vector<bool> &propagate_down,
const vector<bool> &accum) {
if (!(propagate_down[0] || (inputs.size() > 1 && propagate_down[1]) ||
(inputs.size() > 2 && propagate_down[2]))) {
return;
}
auto x = inputs[0];
const auto beta = no_bias_ ? nullptr : inputs[beta_idx_];
const auto gamma = no_scale_ ? nullptr : inputs[gamma_idx_];
// tensor_norm variables
Variable beta_bc, gamma_bc;
Variable *tn_beta = beta;
Variable *tn_gamma = gamma;
// forward (broadcast -> tensor_norm)
// broadcast
if (beta && need_beta_broadcast_) {
nbla::execute(f_broadcast_beta_, Variables{beta}, Variables{&beta_bc});
tn_beta = &beta_bc;
}
if (gamma && need_gamma_broadcast_) {
nbla::execute(f_broadcast_gamma_, Variables{gamma}, Variables{&gamma_bc});
tn_gamma = &gamma_bc;
}
auto tn_inputs = Variables{x};
if (beta)
tn_inputs.push_back(tn_beta);
if (gamma)
tn_inputs.push_back(tn_gamma);
// We can skip tensor_norm forward calculation since its outputs are already
// in data region of `outputs`
// nbla::execute(f_tensor_norm_, tn_inputs, outputs);
// backward (tensor_norm -> broadcast)
vector<bool> tn_accum = {accum[0]};
if (beta)
tn_accum.push_back(accum[beta_idx_] && !need_beta_broadcast_);
if (gamma)
tn_accum.push_back(accum[gamma_idx_] && !need_gamma_broadcast_);
f_tensor_norm_->backward(tn_inputs, outputs, propagate_down, tn_accum);
if (beta && need_beta_broadcast_ && propagate_down[beta_idx_]) {
nbla::backward(f_broadcast_beta_, Variables{beta}, Variables{&beta_bc},
{true}, {accum[beta_idx_]});
}
if (gamma && need_gamma_broadcast_ && propagate_down[gamma_idx_]) {
nbla::backward(f_broadcast_gamma_, Variables{gamma}, Variables{&gamma_bc},
{true}, {accum[gamma_idx_]});
}
}
}
| 33.036437 | 80 | 0.650245 | [
"shape",
"vector"
] |
51240058771e4251a6bfb189a6ccf93af8caa66a | 8,518 | cpp | C++ | matrix_real.cpp | WarwickDumas/FocusFusion2D | 445903f3e9e447985cdfa40444787c108d834e48 | [
"MIT"
] | 1 | 2021-06-21T22:21:57.000Z | 2021-06-21T22:21:57.000Z | matrix_real.cpp | WarwickDumas/FocusFusion2D | 445903f3e9e447985cdfa40444787c108d834e48 | [
"MIT"
] | 2 | 2017-07-16T01:41:11.000Z | 2021-07-05T08:40:01.000Z | matrix_real.cpp | WarwickDumas/FocusFusion2D | 445903f3e9e447985cdfa40444787c108d834e48 | [
"MIT"
] | 1 | 2017-07-16T01:26:51.000Z | 2017-07-16T01:26:51.000Z |
#include <iostream>
#include <conio.h>
#include "matrix_real.h"
using std::cout;
// CompactMatrix class based on the Bandec class given on p.59 of
// Press, Teukolsky, Vetterling and Flannery
// Numerical Recipes for Scientific Computing, third edition (2007)
// [ they cite for this, Keller, H.B. (1968) ].
// call constructor with bandsize, m1, m2 as arguments
// then call invoke - size is now fixed forever
// then can define matrix A
// then can call bandec, bandsolve(RHS vector,soln vector) (can repeat with different RHS vector)
// & can repeat this.
#define unity 1.0
#define zero 0.0
Matrix_real::Matrix_real ()
{
LUSIZE = 0;
}
int Matrix_real::Invoke(long newLUSIZE)
{
long i;
// run this first and then assign values to the elements of the matrix
if (LUSIZE == newLUSIZE){
for (i = 0; i < newLUSIZE; i++)
memset(LU[i],0,sizeof(real)*newLUSIZE);
return 0;
}
if (LUSIZE > 0)
{
for (i = 0; i < LUSIZE; i++)
delete[] LU[i];
delete[] LU;
delete[] indx;
delete[] vv;
LUSIZE = 0;
//printf("Note: Matrix::Invoke called twice.");
};
LU = new real * [newLUSIZE];
for (i = 0; i < newLUSIZE; i++)
{
LU[i] = new real[newLUSIZE];
memset(LU[i],0,sizeof(real)*newLUSIZE);
}
indx = new long [newLUSIZE];
vv = new real [newLUSIZE];
if (vv == NULL) return 2;
LUSIZE = newLUSIZE;
return 0;
};
void Matrix_real::CopyFrom(Matrix_real & src)
{
for (long i = 0; i < LUSIZE; i++)
for (long j = 0; j < LUSIZE; j++)
LU[i][j] = src.LU[i][j];
};
Matrix_real::~Matrix_real ()
{
long i;
if (LUSIZE > 0)
{
for (i = 0; i < LUSIZE; i++)
delete[] LU[i];
delete[] LU;
delete[] indx;
delete[] vv;
};
LUSIZE = 0;
};
long Matrix_real::LUdecomp(/*real LU[LUSIZE][LUSIZE], long indx[]*/)
// LU must already be dimensioned as a matrix[LUSIZE][LUSIZE]
// index must already be dimensioned as an array[LUSIZE]
{
// Method taken from Press et al, Numerical Recipes, 3rd edition 2007
// pages 52-3
// After this is run, the LU matrix is decomposed. It has to be assigned values beforehand.
static real const TINY = (real)1.0e-80;
long i,imax,j,k;
real big,temp1;
//real vv[LUSIZE]; // stores implicit scaling of each row
real d;
d = unity; // no row interchanges yet
for (i = 0; i < LUSIZE; i++) // loop over rows to get implicit scaling information
{
big = zero;
for (j = 0; j < LUSIZE; j++)
if ((temp1=fabs(LU[i][j])) > big) big = temp1;
if (big == zero)
return 1; // no nonzero largest element
vv[i] = unity/big;
};
for (k = 0; k < LUSIZE; k++) // the outermost kij loop
{
if (k < LUSIZE - 1) // if it == LUSIZE-1 then we don't need to run this, and it's dangerous too.
{
imax = -1;
big = zero; // initialise for the search for largest pivot element
for (i = k; i < LUSIZE; i++)
{
temp1 = vv[i] * fabs(LU[i][k]);
if (temp1 > big) // is the figure of merit for the pivot better than the best so far?
{
big = temp1;
imax = i;
};
};
if (k != imax) // do we need to interchange rows?
{
// Swap row imax with row k.
// With a big matrix, what we want to do for efficiency is just exchange pointers,
// from an array of pointers to rows.
for (j = 0; j < LUSIZE; j++)
{
temp1 = LU[imax][j];
LU[imax][j] = LU[k][j];
LU[k][j] = temp1;
};
d = -d; // change the parity of d [ never used for anything ]
// surely here we should be actually interchanging properly?
// Old version:
//vv[imax] = vv[k]; // interchange the scale factor
// Warwick code:
temp1 = vv[imax];
vv[imax] = vv[k];
vv[k] = temp1; // does that help anything? Guess probably not.
// Otherwise the info from vv[imax] is lost completely - can that be right? This is all a bit crazy.
// never used again??
};
} else {
imax = k;
}
if (imax < 0) {
printf("problem -- imax not found.\n");
getch();
} else {
indx[k] = imax;
};
if (LU[k][k] == zero) {
LU[k][k] = TINY;
printf("singular matrix!\n");
};
// pivot element == zero, ie singular matrix
// huh.
// Well, this is simply changing the matrix then
// And making it appear that we are solving with some
// arbitrary influence of the unused value.
for (i = k+1; i < LUSIZE; i++)
{
temp1 = LU[i][k] /= LU[k][k]; // "divide by the pivot element"
for (j = k+1; j < LUSIZE; j++) // innermost loop: reduce remaining submatrix
LU[i][j] -= temp1*LU[k][j];
};
// Here could launch each row or column as a block.
};
// printf("LUdecomp done\n");
return 0; // successful?
}
long Matrix_real::LUSolve (real b[], real x[])
// Make x solve A x = b, where A was the matrix originally defined by assignments before decomposition
{
long i, ii, ip, j;
real sum;
ii = 0;
for (i = 0; i < LUSIZE; i++)
x[i] = b[i];
for (i = 0; i < LUSIZE; i++)
// when ii is +ve, it will become the index of the first nonvanishing element of b
{ // we now do the forward substitution (2.3.6), unscrambling as we go
ip = indx[i];
sum = x[ip];
x[ip] = x[i];
if (ii != 0)
for (j = ii-1; j < i; j++) sum -= LU[i][j]*x[j];
else if (sum != zero) // a nonzero element was encountered, so from now on we will do the sums in the loop above
ii = i+1;
x[i] = sum;
};
// My guess: the L matrix is the one with 1's on the diagonal, since LU[i][i] does not appear up to this point.
// For further debugging why not output this intermediate x
// It works up through the rows -- we need x[j > i].
// We could do 16 consecutive followed by next 16 together using those 16, followed by 16 consecutive.
// Next 16, we use 32 final rows, then do those 16 together. Can do 'consecutive' part in a kernel.
// Maybe it goes:
// for thread 0 alone: do calc ; syncthreads
// all other threads: use result ; syncthreads
// for thread 1 alone: do calc ; syncthreads
// all other threads: use result ; syncthreads ...
for (i = LUSIZE-1; i >= 0; i--) // now do the back-substitution, (2.3.7)
{
sum = x[i];
for (j = i+1; j < LUSIZE; j++) sum -= LU[i][j]*x[j];
// Add extra thing: this wastes many cycles but the point is
// that we may have an undetermined element of x.
if (LU[i][i] == 0.0) {
x[i] = 0.0;
// Maybe this will fix it.
} else {
x[i] = sum / LU[i][i]; // store a component of the solution vector X.
};
// For some reason no, we have in the decomp matrix a thing we should
// not have -- LU[i][i] == 0 for the previous element.
};
return 0;
}
long Matrix_real::LUSolveII (real b[], real x[],int iWhich, real value)
// Make x solve A x = b, where A was the matrix originally defined by assignments before decomposition
{
long i, ii, ip, j;
real sum;
ii = 0;
for (i = 0; i < LUSIZE; i++)
x[i] = b[i];
for (i = 0; i < LUSIZE; i++)
// when ii is +ve, it will become the index of the first nonvanishing element of b
{ // we now do the forward substitution (2.3.6), unscrambling as we go
ip = indx[i];
sum = x[ip];
x[ip] = x[i];
if (ii != 0)
for (j = ii-1; j < i; j++) sum -= LU[i][j]*x[j];
else if (sum != zero) // a nonzero element was encountered, so from now on we will do the sums in the loop above
ii = i+1;
x[i] = sum;
};
// My guess: the L matrix is the one with 1's on the diagonal, since LU[i][i] does not appear up to this point.
// For further debugging why not output this intermediate x
for (i = LUSIZE-1; i >= 0; i--) // now do the back-substitution, (2.3.7)
{
if (i == iWhich) {
x[i] = value;
} else {
sum = x[i];
for (j = i+1; j < LUSIZE; j++) sum -= LU[i][j]*x[j];
x[i] = sum/LU[i][i]; // store a component of the solution vector X.
// Add extra thing: this wastes many cycles but the point is
// that we may have an undetermined element of x.
// if (LU[i][i] == 0.0) x[i] = 0.0;
// Maybe this will fix it.
// For some reason no, we have in the decomp matrix a thing we should
// not have -- LU[i][i] == 0 for the previous element.
};
};
return 0;
}
| 28.777027 | 116 | 0.569382 | [
"vector"
] |
5125e2364113fffa33bc195d5c90c7c7e1eab919 | 3,069 | cc | C++ | util/arena_impl.cc | cld378632668/rocksdb-test | 8cd0ca501abe0cf4a30e8173c8452b1c9b416282 | [
"BSD-3-Clause"
] | 1 | 2017-12-26T01:52:03.000Z | 2017-12-26T01:52:03.000Z | util/arena_impl.cc | cld378632668/rocksdb-test | 8cd0ca501abe0cf4a30e8173c8452b1c9b416282 | [
"BSD-3-Clause"
] | null | null | null | util/arena_impl.cc | cld378632668/rocksdb-test | 8cd0ca501abe0cf4a30e8173c8452b1c9b416282 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2013, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "util/arena_impl.h"
#include <algorithm>
namespace rocksdb {
const size_t ArenaImpl::kMinBlockSize = 4096;
const size_t ArenaImpl::kMaxBlockSize = 2 << 30;
static const int kAlignUnit = sizeof(void*);
size_t OptimizeBlockSize(size_t block_size) {
// Make sure block_size is in optimal range
block_size = std::max(ArenaImpl::kMinBlockSize, block_size);
block_size = std::min(ArenaImpl::kMaxBlockSize, block_size);
// make sure block_size is the multiple of kAlignUnit
if (block_size % kAlignUnit != 0) {
block_size = (1 + block_size / kAlignUnit) * kAlignUnit;
}
return block_size;
}
ArenaImpl::ArenaImpl(size_t block_size)
: kBlockSize(OptimizeBlockSize(block_size)) {
assert(kBlockSize >= kMinBlockSize && kBlockSize <= kMaxBlockSize &&
kBlockSize % kAlignUnit == 0);
}
ArenaImpl::~ArenaImpl() {
for (const auto& block : blocks_) {
delete[] block;
}
}
char* ArenaImpl::AllocateFallback(size_t bytes, bool aligned) {
if (bytes > kBlockSize / 4) {
// Object is more than a quarter of our block size. Allocate it separately
// to avoid wasting too much space in leftover bytes.
return AllocateNewBlock(bytes);
}
// We waste the remaining space in the current block.
auto block_head = AllocateNewBlock(kBlockSize);
alloc_bytes_remaining_ = kBlockSize - bytes;
if (aligned) {
aligned_alloc_ptr_ = block_head + bytes;
unaligned_alloc_ptr_ = block_head + kBlockSize;
return block_head;
} else {
aligned_alloc_ptr_ = block_head;
unaligned_alloc_ptr_ = block_head + kBlockSize - bytes;
return unaligned_alloc_ptr_;
}
}
char* ArenaImpl::AllocateAligned(size_t bytes) {
assert((kAlignUnit & (kAlignUnit - 1)) ==
0); // Pointer size should be a power of 2
size_t current_mod =
reinterpret_cast<uintptr_t>(aligned_alloc_ptr_) & (kAlignUnit - 1);
size_t slop = (current_mod == 0 ? 0 : kAlignUnit - current_mod);
size_t needed = bytes + slop;
char* result;
if (needed <= alloc_bytes_remaining_) {
result = aligned_alloc_ptr_ + slop;
aligned_alloc_ptr_ += needed;
alloc_bytes_remaining_ -= needed;
} else {
// AllocateFallback always returned aligned memory
result = AllocateFallback(bytes, true /* aligned */);
}
assert((reinterpret_cast<uintptr_t>(result) & (kAlignUnit - 1)) == 0);
return result;
}
char* ArenaImpl::AllocateNewBlock(size_t block_bytes) {
char* block = new char[block_bytes];
blocks_memory_ += block_bytes;
blocks_.push_back(block);
return block;
}
} // namespace rocksdb
| 32.648936 | 79 | 0.713587 | [
"object"
] |
5126c050b935210a1c920c47b9a44feb6682a4bd | 6,695 | cpp | C++ | Light OJ/1165.cpp | dipta007/Competitive-Programming | 998d47f08984703c5b415b98365ddbc84ad289c4 | [
"MIT"
] | 6 | 2018-10-15T18:45:05.000Z | 2022-03-29T04:30:10.000Z | Light OJ/1165.cpp | dipta007/Competitive-Programming | 998d47f08984703c5b415b98365ddbc84ad289c4 | [
"MIT"
] | null | null | null | Light OJ/1165.cpp | dipta007/Competitive-Programming | 998d47f08984703c5b415b98365ddbc84ad289c4 | [
"MIT"
] | 4 | 2018-01-07T06:20:07.000Z | 2019-08-21T15:45:59.000Z | #pragma comment(linker, "/stack:640000000")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI=acos(-1.0);
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define MP(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define rep(i,n) for(int i = 1 ; i<=(n) ; i++)
#define repI(i,n) for(int i = 0 ; i<(n) ; i++)
#define FOR(i,L,R) for (int i = (int)(L); i <= (int)(R); i++)
#define ROF(i,L,R) for (int i = (int)(L); i >= (int)(R); i--)
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define ALL(p) p.begin(),p.end()
#define ALLR(p) p.rbegin(),p.rend()
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define getC(n) scanf("%c",&n)
#define getF(n) scanf("%lf",&n)
#define getS(n) scanf("%s",n)
#define bitCheck(N,in) ((bool)(N&(1<<(in))))
#define bitOff(N,in) (N&(~(1<<(in))))
#define bitOn(N,in) (N|(1<<(in)))
#define iseq(a,b) (fabs(a-b)<EPS)
#define vi vector < int >
#define vii vector < vector < int > >
#define pii pair< int, int >
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
template< class T > inline T _abs(T n) { return ((n) < 0 ? -(n) : (n)); }
template< class T > inline T _max(T a, T b) { return (!((a)<(b))?(a):(b)); }
template< class T > inline T _min(T a, T b) { return (((a)<(b))?(a):(b)); }
template< class T > inline T _swap(T &a, T &b) { a=a^b;b=a^b;a=a^b;}
template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
#ifdef dipta007
#define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;}
#else
#define debug(args...) // Just strip off all debug tokens
#endif
struct debugger{
template<typename T> debugger& operator , (const T& v){
cerr<<v<<" ";
return *this;
}
}dbg;
struct data
{
int num,male;
};
struct node
{
data a[10];
int step;
};
int check(node x)
{
FOR(i,0,7)
{
if(x.a[i].num!=i+1) return 0;
}
return 1;
}
int vis[400004];
int fac[]={1,1,2,6,24,120,720,5040,40320};
int getHash(node x)
{
int a[10],val=0,cnt;
for(int i=0;i<8;i++)a[i]=abs(x.a[i].num);
for(int i=0;i<8;i++){
cnt=0;
for(int j=0;j<i;j++){
if(a[j]>a[i])cnt++;
}
val+=cnt*fac[i];
}
return val;
// int val = 0;
// FOR(i,0,7)
// {
// val += x.a[i].num * hashArr[i];
// }
// return val;
}
bool isPrime(int x)
{
if(x==2 ) return true;
if(x==3 ) return true;
if(x==5 ) return true;
if(x==7 ) return true;
if(x==11) return true;
if(x==13) return true;
if(x==17) return true;
if(x==19) return true;
return false;
}
int find(node now, int val)
{
FOR(i,0,7)
{
if(now.a[i].num==val) return i;
}
}
node getNode(node now, int p1, int p2, int left)
{
int pos1 = find(now, p1);
int pos2 = find(now, p2);
node next;
next.step = now.step + 1;
if(left) ///left e insert korbo p2 k
{
//if(pos1<pos2)
{
int in=0;
FOR(i,0,pos1-1)
{
if(i==pos2) continue;
next.a[in].num = now.a[i].num;
next.a[in++].male = now.a[i].male;
}
next.a[in].male = now.a[pos2].male;
next.a[in++].num = p2;
FOR(i,pos1,7)
{
if(i==pos2) continue;
next.a[in].male = now.a[i].male;
next.a[in++].num = now.a[i].num;
}
}
}
else ///right e insert korbo p2 k
{
int in=0;
FOR(i,0,pos1)
{
if(i==pos2) continue;
next.a[in].male = now.a[i].male;
next.a[in++].num = now.a[i].num;
}
next.a[in].male = now.a[pos2].male;
next.a[in++].num = p2;
FOR(i,pos1+1,7)
{
if(i==pos2) continue;
next.a[in].male = now.a[i].male;
next.a[in++].num = now.a[i].num;
}
}
return next;
}
int BFS(node s)
{
queue <node> q;
q.push(s);
CLR(vis);
vis[ getHash(s) ] = 1;
while(!q.empty())
{
node u = q.front(); q.pop();
if(check(u))
{
//FOR(i,0,7) debug(u.a[i].num)
return u.step;
}
FOR(i,0,7)
{
FOR(j,0,7)
{
if(i==j) continue;
if(u.a[i].male!=u.a[j].male && isPrime(u.a[i].num + u.a[j].num))
{
FOR(k,0,1)
{
node v = getNode(u, u.a[i].num, u.a[j].num, k);
int hh = getHash(v);
if(vis[ hh ]==0)
{
vis[hh]=1;
q.push(v);
}
}
}
}
}
}
return -1;
}
int main() {
#ifdef dipta007
READ("in.txt");
//WRITE("in.txt");
#endif // dipta007
int t;
getI(t);
FOR(ci,1,t)
{
node s;
s.step=0;
FOR(i,0,7)
{
int x;
getI(x);
if(x<0)
{
s.a[i].male=0;
s.a[i].num=-x;
}
else
{
s.a[i].male=1;
s.a[i].num=x;
}
}
printf("Case %d: %d\n",ci,BFS(s));
}
return 0;
}
| 24.257246 | 109 | 0.450037 | [
"vector"
] |
5127fa0a6f97d7875285625ee2f1e5d698704ed6 | 7,649 | hpp | C++ | plat2d/plat2d.hpp | skiesel/search | b9bb14810a85d6a486d603b3d81444c9d0b246b0 | [
"MIT"
] | 28 | 2015-02-10T04:06:16.000Z | 2022-03-11T11:51:38.000Z | plat2d/plat2d.hpp | skiesel/search | b9bb14810a85d6a486d603b3d81444c9d0b246b0 | [
"MIT"
] | 3 | 2016-11-03T12:03:28.000Z | 2020-07-13T17:35:40.000Z | plat2d/plat2d.hpp | skiesel/search | b9bb14810a85d6a486d603b3d81444c9d0b246b0 | [
"MIT"
] | 9 | 2015-10-22T20:22:45.000Z | 2020-06-30T20:11:31.000Z | // Copyright © 2013 the Search Authors under the MIT license. See AUTHORS for the list of authors.
#include "player.hpp"
#include "lvl.hpp"
#include "../visnav/visgraph.hpp"
#include <vector>
#include <string>
#include <cstdio>
void fatal(const char*, ...);
extern "C" unsigned long hashbytes(unsigned char[], unsigned int);
// controlstr converts a vector of controls to an ASCII string.
std::string controlstr(const std::vector<unsigned int>&);
// controlvec converts a string of controls back into a vector.
std::vector<unsigned int> controlvec(const std::string&);
// Maxx is the maximum travel distance in the x-direction
// in a single frame.
static const double Maxx = Runspeed;
// Maxy is the maximum travel distance in the y-direction
// in a single frame.
static const double Maxy = Jmpspeed > Body::Maxdy ? Jmpspeed : Body::Maxdy;
// W is the minimum width of a tile in 'frames'. I.e., at max
// speed how many frames does it require to traverse the
// width of a tile.
static const double W = Tile::Width / Maxx;
// H is the minimum height of a tile in 'frames'.
static const double H = Tile::Height / Maxy;
struct Plat2d {
typedef int Cost;
typedef int Oper;
enum { Nop = -1 };
Plat2d(FILE*);
~Plat2d();
struct State {
State() : h(-1) { }
State(unsigned int x, unsigned int y, unsigned int z,
unsigned int w, unsigned int h) : player(x, y, w, h), h(-1) { }
static const int K = 3;
void vector(const Plat2d *d, double vec[]) const {
auto p = player.body.bbox.center();
p.y = d->maxy - p.y;
p.scale(1.0/d->maxx, 1.0/d->maxy);
vec[0] = p.x;
vec[1] = p.y;
vec[2] = (player.body.dy+Body::Maxdy)/(2*Body::Maxdy);
}
Player player;
Cost h;
};
struct PackedState {
bool eq(const Plat2d*, const PackedState &o) const {
return jframes == o.jframes &&
geom2d::doubleeq(x, o.x) &&
geom2d::doubleeq(y, o.y) &&
geom2d::doubleeq(dy, o.dy);
}
unsigned long hash(const Plat2d*) {
static const unsigned int sz = sizeof(x) +
sizeof(y) + sizeof(dy) + sizeof(jframes);
unsigned char bytes[sz];
unsigned int i = 0;
char *p = (char*) &x;
for (unsigned int j = 0; j < sizeof(x); j++)
bytes[i++] = p[j];
p = (char*) &y;
for (unsigned int j = 0; j < sizeof(y); j++)
bytes[i++] = p[j];
p = (char*) &dy;
for (unsigned int j = 0; j < sizeof(dy); j++)
bytes[i++] = p[j];
bytes[i++] = jframes;
assert (i <= sz);
return hashbytes(bytes, i);
}
double x, y, dy;
// The body's fall flag is packed as the high-order bit
// of jframes.
unsigned char jframes;
};
State initialstate();
Cost h(State &s) {
if (s.h < 0)
s.h = hvis(s);
return s.h;
}
Cost d(State &s) {
return h(s);
}
bool isgoal(State &s) {
Lvl::Blkinfo bi = lvl.majorblk(s.player.body.bbox);
return bi.x == gx && bi.y == gy;
}
struct Operators {
Operators(const Plat2d &d, const State &s) : n(Nops) {
// If jumping will have no effect then allow left, right and jump.
// This is a bit of a hack, but the 'jump' action that is allowed
// here will end up being a 'do nothing' and just fall action.
// Effectively, we prune off the jump/left and jump/right actions
// since they are the same as just doing left and right in this case.
if (!s.player.canjump())
n = 3;
}
unsigned int size() const {
return n;
}
Oper operator[](unsigned int i) const {
return Ops[i];
}
private:
unsigned int n;
static const unsigned int Ops[];
static const unsigned int Nops;
};
// Ident returns the (identity action, cost) pair, or (Nop, -1) if there is no identity action in this state.
std::pair<Oper, Cost> ident(const State &s) const {
Player copy = s.player;
copy.act(lvl, 0);
if (copy == s.player)
return std::make_pair(0, 1);
return std::make_pair(Nop, -1);
}
struct Edge {
Cost cost;
Oper revop;
Cost revcost;
State state;
Edge(Plat2d &d, State &s, Oper op) : revop(Nop), revcost(-1), state(s) {
state.h = -1;
state.player.act(d.lvl, (unsigned int) op);
cost = 1; // geom2d::Pt::distance(s.player.body.bbox.min, state.player.body.bbox.min));
if (s.player.body.bbox.min.y == state.player.body.bbox.min.y) {
if (op == Player::Left) {
revop = Player::Right;
revcost = cost;
}
else if (op == Player::Right) {
revop = Player::Left;
revcost = cost;
}
}
assert (op != 0 || state.player == s.player);
double dy = fabs(s.player.body.bbox.center().y - state.player.body.bbox.center().y);
double dx = fabs(s.player.body.bbox.center().x - state.player.body.bbox.center().x);
assert (dx <= Maxx);
assert (dy <= Maxy);
}
};
void pack(PackedState &dst, State &src) {
dst.x = src.player.body.bbox.min.x;
dst.y = src.player.body.bbox.min.y;
dst.dy = src.player.body.dy;
dst.jframes = src.player.jframes;
if (src.player.body.fall)
dst.jframes |= 1 << 7;
}
State &unpack(State &buf, PackedState &pkd) {
buf.player.jframes = pkd.jframes & 0x7F;
buf.player.body.fall = pkd.jframes & (1 << 7);
buf.player.body.dy = pkd.dy;
buf.player.body.bbox.min.x = pkd.x;
buf.player.body.bbox.min.y = pkd.y;
buf.player.body.bbox.max.x = pkd.x + Player::Width;
buf.player.body.bbox.max.y = pkd.y + Player::Height;
return buf;
}
static void dumpstate(FILE *out, State &s) {
fprintf(out, "%g, %g\n", s.player.loc().x, s.player.loc().y);
}
Cost pathcost(const std::vector<State>&, const std::vector<Oper>&,
bool printSolution=false);
// Drawmap returns an image of the map.
Image *drawmap() const;
unsigned int gx, gy; // goal tile location
unsigned int x0, y0; // initial location
Lvl lvl;
private:
struct Node {
int v; // vertex ID
int prev; // previous along path
long i; // prio queue index
double d; // distance to goal
static void setind(Node *n, unsigned long ind) { n->i = ind; }
static bool pred(const Node *a, const Node *b) { return a->d < b->d; }
};
void initvg();
double hvis(State &s) const {
const Lvl::Blkinfo &bi = lvl.majorblk(s.player.body.bbox);
if (bi.x == gx && bi.y == gy)
return 0;
geom2d::Pt loc(s.player.body.bbox.center());
loc.x /= Maxx; // Pixel to squished vismap coords.
loc.y /= Maxy;
int c = centers[bi.x * lvl.height() + bi.y];
geom2d::Pt g = goalpt(bi, loc);
if (togoal[c].prev == gcenter || vg->map.isvisible(loc, g)) {
double dx = fabs(g.x - loc.x);
double dy = fabs(g.y - loc.y);
double h = floor(std::max(dx, dy));
return h <= 0 ? 1 : h;
}
// Account for goal vertex being at its tile center.
static const double diag = std::max(W/2, H/2);
// Account for distance from player to center of tile.
double middx = fabs(loc.x - vg->verts[c].pt.x);
double middy = fabs(loc.y - vg->verts[c].pt.y);
double tomid = std::max(middx, middy);
double h = togoal[c].d - tomid - diag;
if (h <= 0)
h = 1;
h = floor(h);
if (h <= 0)
h = 1;
return h;
}
// goalpt returns a point in the goal cell that is closest
// to the given location.
geom2d::Pt goalpt(const Lvl::Blkinfo &bi, const geom2d::Pt &loc) const {
geom2d::Pt pt;
if (bi.y == gy)
pt.y = loc.y;
else if (bi.y < gy)
pt.y = gtop;
else
pt.y = gbottom;
if (bi.x == gx)
pt.x = loc.x;
else if (bi.x < gx)
pt.x = gleft;
else
pt.x = gright;
return pt;
}
// savemap draws the visibility map used for the heuristic
// to the given file.;
void savemap(const char*) const;
VisGraph *vg;
std::vector<long> centers;
std::vector<Node> togoal;
int gcenter; // vertex ID of the goal center
double gleft, gright, gtop, gbottom;
double maxx, maxy; // width and height in pixels.
};
| 25.841216 | 111 | 0.624526 | [
"vector"
] |
512d3f9b4a7c7787f184880fa9292e9294a26b6e | 3,516 | hpp | C++ | inference-engine/tests/ngraph_functions/include/ngraph_functions/low_precision_transformations/common/dequantization_operations.hpp | dbudniko/openvino | 6666e5fed3434637e538cf9d3219077c320c3c16 | [
"Apache-2.0"
] | 1 | 2021-01-17T03:24:52.000Z | 2021-01-17T03:24:52.000Z | inference-engine/tests/ngraph_functions/include/ngraph_functions/low_precision_transformations/common/dequantization_operations.hpp | dbudniko/openvino | 6666e5fed3434637e538cf9d3219077c320c3c16 | [
"Apache-2.0"
] | 30 | 2020-11-13T11:44:07.000Z | 2022-02-21T13:03:16.000Z | inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/common/dequantization_operations.hpp | dorloff/openvino | 1c3848a96fdd325b044babe6d5cd26db341cf85b | [
"Apache-2.0"
] | 1 | 2020-12-18T15:47:45.000Z | 2020-12-18T15:47:45.000Z | // Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <ngraph/ngraph.hpp>
#include "fake_quantize_on_data.hpp"
namespace ngraph {
namespace builder {
namespace subgraph {
class DequantizationOperations {
public:
class Convert {
public:
Convert();
Convert(const ngraph::element::Type outPrecision);
bool empty() const noexcept;
ngraph::element::Type outPrecision;
private:
bool isEmpty;
};
class Subtract {
public:
Subtract();
Subtract(const float value, const bool addDeqAttr = true);
Subtract(const std::vector<float>& values, const bool addDeqAttr = true);
Subtract(const std::vector<float>& values, const ngraph::element::Type outPrecision, const bool addDeqAttr = true);
Subtract(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& constantShape,
const bool addDequantizationAttribute = true,
const size_t constantIndex = 1ul,
const ngraph::element::Type constantPrecision = ngraph::element::undefined);
bool empty() const noexcept;
Subtract& setConstantPrecision(const ngraph::element::Type& precision);
std::vector<float> values;
ngraph::element::Type outPrecision;
ngraph::Shape constantShape;
bool constantShapeIsDefined;
bool addDequantizationAttribute;
size_t constantIndex = 1ul;
ngraph::element::Type constantPrecision = ngraph::element::undefined;
private:
bool isEmpty;
};
class Multiply {
public:
Multiply();
Multiply(const float value);
Multiply(const std::vector<float>& values);
Multiply(const std::vector<float>& values, const ngraph::element::Type outPrecision);
Multiply(
const std::vector<float>& values,
const ngraph::element::Type outPrecision,
const ngraph::Shape& constantShape,
const bool addDequantizationAttribute = true,
const size_t constantIndex = 1ul,
const ngraph::element::Type constantPrecision = ngraph::element::undefined);
bool empty() const noexcept;
Multiply& setConstantPrecision(const ngraph::element::Type& precision);
std::vector<float> values;
ngraph::element::Type outPrecision;
ngraph::Shape constantShape;
bool constantShapeIsDefined;
bool addDequantizationAttribute;
size_t constantIndex = 1ul;
ngraph::element::Type constantPrecision = ngraph::element::undefined;
private:
bool isEmpty;
};
DequantizationOperations();
DequantizationOperations(const Convert& convert, const Subtract& subtract, const Multiply& multiply);
bool empty() const;
Convert convert;
Subtract subtract;
Multiply multiply;
};
inline std::ostream& operator<<(std::ostream& out, const DequantizationOperations& data) {
return out << "_" <<
(data.convert.outPrecision != element::undefined ? data.convert.outPrecision.get_type_name() : "") << "_" <<
data.subtract.values << "_" <<
data.subtract.constantShape << "_" <<
data.subtract.outPrecision << "_" <<
data.multiply.values << "_" <<
data.multiply.constantShape << "_" <<
data.multiply.outPrecision;
}
} // namespace subgraph
} // namespace builder
} // namespace ngraph
| 32.555556 | 123 | 0.64818 | [
"shape",
"vector"
] |
5133eb4fdb53ed18771a822c3f8eb0b1fef33d67 | 7,768 | hpp | C++ | solver/modules/slide/include/slide/details/WhaleSolver.hpp | taiheioki/procon2014_ut | 8199ff0a54220f1a0c51acece377f65b64db4863 | [
"MIT"
] | 2 | 2021-04-14T06:41:18.000Z | 2021-04-29T01:56:08.000Z | solver/modules/slide/include/slide/details/WhaleSolver.hpp | taiheioki/procon2014_ut | 8199ff0a54220f1a0c51acece377f65b64db4863 | [
"MIT"
] | null | null | null | solver/modules/slide/include/slide/details/WhaleSolver.hpp | taiheioki/procon2014_ut | 8199ff0a54220f1a0c51acece377f65b64db4863 | [
"MIT"
] | null | null | null | #ifndef SLIDE_DETAILS_WHALE_SOLVER_HPP_
#define SLIDE_DETAILS_WHALE_SOLVER_HPP_
#include <utility>
#include <tbb/parallel_for_each.h>
#include <tbb/parallel_sort.h>
#include <tbb/task_scheduler_init.h>
#include "../ParityFeature.hpp"
#include "../WhaleSolver.hpp"
#include "util/dense_hash_set.hpp"
#include "util/SpinMutex.hpp"
#include "util/ThreadIndexManager.hpp"
namespace slide
{
template<int H, int W>
std::vector<AnswerTreeBoard<H, W>> WhaleSolver::decreaseManhattan(
const PlayBoard<H, W>& start, int selectionLimit, int y, int x, int h, int w
){
if(numThreads == -1){
numThreads = tbb::task_scheduler_init::default_num_threads();
}
if(KurageHashFeature<H, W>::table == nullptr){
KurageHashFeature<H, W>::table.reset(new ZobristTable<H, W>(start.height(), start.width()));
}
using BoardsArray = std::vector<std::vector<WhaleBoard<H, W>>>;
BoardsArray boards(numThreads);
BoardsArray nextBoards(numThreads);
rep(i, numThreads){
nextBoards[i].reserve(totalBeamWidth * 4 / numThreads);
}
// 最初の選択
{
const WhaleBoard<H, W> kurage(start);
if(kurage.isSelected()){
// already selected
BOOST_ASSERT(Point(start(start.selected)).isIn(y, x, h, w));
boards[0].push_back(kurage);
}
else{
// the first select
// パリティ計算
ParityFeature<H, W> parity(start);
int cnt = 0;
rep(i, kurage.height()) rep(j, kurage.width()){
if(Point(kurage(i, j)).isIn(y+1, x+1, h-2, w-2)){
const bool p = parity() ^ (((Point(i, j) - Point(start(i, j))).l1norm()) & 1);
if(!p){
boards[0].emplace_back(kurage);
boards[0][boards[0].size()-1].select(Point(i, j));
++cnt;
}
}
}
if(cnt == 0){
rep(i, kurage.height()) rep(j, kurage.width()){
if(Point(kurage(i, j)).isIn(y+1, x+1, h-2, w-2)){
boards[0].emplace_back(kurage);
boards[0][boards[0].size()-1].select(Point(i, j));
}
}
}
--selectionLimit;
}
}
// const int firstManhattan = kurage.manhattan;
// double remainRatio = 1.0;
// 登場したハッシュ値のリスト
util::dense_hash_set<ull> visited(0ull);
// インデックス
std::vector<std::pair<float, uint>> indices;
indices.reserve(totalBeamWidth * 4);
int indices_shift;
for(indices_shift = 0; (1 << indices_shift) < numThreads; ++indices_shift);
bool finished = false;
int reliability = 10;
int preMinManhattan = 1 << 29;
// r は交換回数
for(int r=0;; ++r){
// board 達をソート
util::StopWatch::start("sorting");
indices.clear();
rep(i, numThreads){
rep(j, boards[i].size()){
indices.push_back({boards[i][j].score, (uint(j)<<uint(indices_shift)) | uint(i)});
}
}
if(indices.size() > totalBeamWidth){
tbb::parallel_sort(indices.begin(), indices.end());
indices.erase(indices.begin() + totalBeamWidth, indices.end());
}
util::StopWatch::stop("sorting");
// visited フラグを追加
util::StopWatch::start("visited");
for(const std::pair<float, uint>& id : indices){
const ull hash = boards[id.second & ((1<<indices_shift)-1)][id.second >> indices_shift].hash();
visited.insert(hash);
}
util::StopWatch::stop("visited");
// 統計情報を計算
int minManhattan = 1 << 29;
for(const std::pair<float, uint>& id : indices){
const WhaleBoard<H, W>& board = boards[id.second & ((1<<indices_shift)-1)][id.second >> indices_shift];
minManhattan = std::min(minManhattan, int(board.manhattan));
}
reliability += preMinManhattan <= minManhattan ? -2 : 1;
reliability = std::min(10, reliability);
preMinManhattan = minManhattan;
if(reliability <= 0){
std::vector<AnswerTreeBoard<H, W>> ret;
ret.reserve(indices.size());
for(const std::pair<float, uint>& id : indices){
const WhaleBoard<H, W>& preboard = boards[id.second & ((1<<indices_shift)-1)][id.second >> indices_shift];
AnswerTreeBoard<H, W> board(preboard);
board.selected = preboard.selected;
board.swappingCount = r;
board.index = preboard.index;
board.thread = preboard.thread;
ret.push_back(std::move(board));
}
std::cout << "minManhattan = " << minManhattan << std::endl;
std::cout << "whale answer size = " << r << std::endl;
return ret;
}
util::SpinMutex scoreMutex;
// !並列!
util::StopWatch::start("parallel");
tbb::parallel_for_each(indices.begin(), indices.end(), [
this,
&boards, &visited, &indices, indices_shift, // read-only
&nextBoards, &scoreMutex, &finished // read and write
]
(std::pair<float, uint> id){
const WhaleBoard<H, W>& board = boards[id.second & ((1<<indices_shift)-1)][id.second >> indices_shift];
const int thread = util::ThreadIndexManager::getLocalId();
// move
int added = 0;
const int preSize = nextBoards[thread].size();
rep(k, 4){
const Direction dir(k);
if(!board.isValidMove(dir) || (!board.preMove.isSelection && board.preMove.getDirection() == dir.opposite())){
continue;
}
const int tmpIndex = preSize + added;
nextBoards[thread].push_back(board);
nextBoards[thread][tmpIndex].move(dir, thread);
// check whether the finished or not
if(nextBoards[thread][tmpIndex].isFinished()){
std::lock_guard<util::SpinMutex> lock(scoreMutex);
if(!finished){
Answer answer = nextBoards[thread][tmpIndex].buildAnswer();
answer.optimize();
onCreatedAnswer(std::move(answer));
finished = true;
}
return;
}
if(visited.count(nextBoards[thread][tmpIndex].hash())){
nextBoards[thread].pop_back();
}
else{
++added;
}
}
// add to next
if(added == 3){
if(nextBoards[thread][preSize].score < nextBoards[thread][preSize+1].score){
if(nextBoards[thread][preSize+1].score > nextBoards[thread][preSize+2].score){
// remain 0 and 2
nextBoards[thread][preSize+1] = std::move(nextBoards[thread][preSize+2]);
}
}
else if(nextBoards[thread][preSize].score > nextBoards[thread][preSize+2].score){
// remain 1 and 2
nextBoards[thread][preSize] = std::move(nextBoards[thread][preSize+2]);
}
nextBoards[thread].pop_back();
}
});
util::StopWatch::stop("parallel");
// swap and clear
rep(i, numThreads){
boards[i].clear();
boards[i].swap(nextBoards[i]);
}
verbose && std::cerr << minManhattan << ' ';
}
}
} // end of namespace slide
#endif
| 34.070175 | 126 | 0.518151 | [
"vector"
] |
5134aa26747e6067332489dea9e43c0f3c01ecfd | 3,898 | cpp | C++ | GLShape/GLFrustum.cpp | chen0040/cpp-steering-behaviors | c73d2ae8037556d42440b54ba6eb6190e467fae9 | [
"MIT"
] | 2 | 2020-11-10T12:24:41.000Z | 2021-09-25T08:24:06.000Z | GLShape/GLFrustum.cpp | chen0040/cpp-steering-behaviors | c73d2ae8037556d42440b54ba6eb6190e467fae9 | [
"MIT"
] | null | null | null | GLShape/GLFrustum.cpp | chen0040/cpp-steering-behaviors | c73d2ae8037556d42440b54ba6eb6190e467fae9 | [
"MIT"
] | 1 | 2021-08-14T16:34:33.000Z | 2021-08-14T16:34:33.000Z | #include "GLFrustum.h"
#include <cmath>
#include <vector>
void GLFrustum::MakeCameraFrustum()
{
GLfloat projection[16];
GLfloat modelview[16];
glGetFloatv(GL_PROJECTION_MATRIX, projection);
glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
glPushMatrix();
glLoadMatrixf(projection);
glMultMatrixf(modelview);
glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
glPopMatrix();
ExtractPlane(this->left, modelview, 1);
ExtractPlane(this->right, modelview, -1);
ExtractPlane(this->bottom, modelview, 2);
ExtractPlane(this->top, modelview, -2);
ExtractPlane(this->near, modelview, 3);
ExtractPlane(this->far, modelview, -3);
}
void GLFrustum::ExtractPlane(GLPlane& plane, const GLfloat* mat, int row)
{
int scale=(row < 0) ? -1 : 1;
row = abs(row) - 1;
// calculate plane coefficients from the matrix;
plane.normal.x=mat[3] + scale * mat[row];
plane.normal.y=mat[7] + scale * mat[row + 4];
plane.normal.z=mat[11] + scale * mat[row + 8];
plane.D=mat[15] + scale * mat[row + 12];
//normalize the plane
double length=plane.normal.length();
plane.normal.x /= length;
plane.normal.y /= length;
plane.normal.z /= length;
plane.D /= length;
}
bool GLFrustum::PointInFrustum(const GLVector& pt) const
{
bool point_outside_plane=false;
point_outside_plane=PointOutsidePlane(this->left, pt);
if(point_outside_plane==true)
{
return false;
}
point_outside_plane=PointOutsidePlane(this->right, pt);
if(point_outside_plane==true)
{
return false;
}
point_outside_plane=PointOutsidePlane(this->top, pt);
if(point_outside_plane==true)
{
return false;
}
point_outside_plane=PointOutsidePlane(this->bottom, pt);
if(point_outside_plane==true)
{
return false;
}
point_outside_plane=PointOutsidePlane(this->near, pt);
if(point_outside_plane==true)
{
return false;
}
point_outside_plane=PointOutsidePlane(this->far, pt);
if(point_outside_plane==true)
{
return false;
}
return true;
}
bool GLFrustum::PointOutsidePlane(const GLPlane& plane, const GLVector& pt) const
{
if((plane.normal.dot(pt) + plane.D) < 0)
{
return true;
}
return false;
}
double GLFrustum::DistFromPointToPlane(const GLPlane& plane, const GLVector& pt) const
{
return plane.normal.dot(pt) + plane.D;
}
bool GLFrustum::SphereOutsidePlane(const GLPlane& plane, const GLSphere& sphere) const
{
if(DistFromPointToPlane(plane, sphere.center) <= -sphere.radius)
{
return true;
}
return false;
}
bool GLFrustum::SphereInFrustum(const GLSphere& sphere) const
{
bool sphere_outside_plane=false;
sphere_outside_plane=SphereOutsidePlane(this->left, sphere);
if(sphere_outside_plane==true)
{
return false;
}
sphere_outside_plane=SphereOutsidePlane(this->right, sphere);
if(sphere_outside_plane==true)
{
return false;
}
sphere_outside_plane=SphereOutsidePlane(this->top, sphere);
if(sphere_outside_plane==true)
{
return false;
}
sphere_outside_plane=SphereOutsidePlane(this->bottom, sphere);
if(sphere_outside_plane==true)
{
return false;
}
sphere_outside_plane=SphereOutsidePlane(this->near, sphere);
if(sphere_outside_plane==true)
{
return false;
}
sphere_outside_plane=SphereOutsidePlane(this->far, sphere);
if(sphere_outside_plane==true)
{
return false;
}
return true;
}
bool GLFrustum::CubeInFrustum(const GLCube& cube) const
{
std::vector<GLVector> pts;
pts.push_back(GLVector(cube.minx, cube.miny, cube.minz));
pts.push_back(GLVector(cube.maxx, cube.miny, cube.minz));
pts.push_back(GLVector(cube.maxx, cube.miny, cube.maxz));
pts.push_back(GLVector(cube.minx, cube.miny, cube.maxz));
pts.push_back(GLVector(cube.minx, cube.maxy, cube.minz));
pts.push_back(GLVector(cube.maxx, cube.maxy, cube.minz));
pts.push_back(GLVector(cube.maxx, cube.maxy, cube.maxz));
pts.push_back(GLVector(cube.minx, cube.maxy, cube.maxz));
for(size_t i=0; i<pts.size(); i++)
{
if(PointInFrustum(pts[i]))
{
return true;
}
}
return false;
} | 23.481928 | 86 | 0.733197 | [
"vector"
] |
513bc8de998b6e6f6ea1ec0d76600b141eb9e068 | 1,440 | cpp | C++ | TowerDefense_old_001/cpp/classes/Structure/abstract/StructureCommons.cpp | Gab-Z/rozetta | 491e255a9eec4bdf803a866a50be35d2ad3e4ff8 | [
"Apache-2.0"
] | 1 | 2019-11-28T08:02:06.000Z | 2019-11-28T08:02:06.000Z | TowerDefense_old_001/cpp/classes/Structure/abstract/StructureCommons.cpp | Gab-Z/rozetta | 491e255a9eec4bdf803a866a50be35d2ad3e4ff8 | [
"Apache-2.0"
] | null | null | null | TowerDefense_old_001/cpp/classes/Structure/abstract/StructureCommons.cpp | Gab-Z/rozetta | 491e255a9eec4bdf803a866a50be35d2ad3e4ff8 | [
"Apache-2.0"
] | null | null | null | #include "StructureCommons.h"
StructureCommons::StructureCommons(){
}
StructureCommons::StructureCommons( int _x, int _y ){
x = _x;
y = _y;
}
StructureCommons::StructureCommons( int _x, int _y, GridIndicesList _points){
x = _x;
y = _y;
positions = _points;
}
StructureCommons::StructureCommons( int _x, int _y, std::vector<int> _points ){
x = _x;
y = _y;
positions.convertTwoPointsList( _points );
}
StructureCommons::StructureCommons( int _x, int _y, std::vector<int> _points, int _w, int _h ){
x = _x;
y = _y;
positions.setVec( _points, _w, _h );
}
void StructureCommons::setGridPositions( GridIndicesList _points ){
positions = _points;
}
void StructureCommons::setGridPositions( std::vector<int> v ){
positions.setVec( v );
}
void StructureCommons::setPosition( int _x, int _y ){
x = _x;
y = _y;
}
std::vector<int> StructureCommons::getTilePos( int i ){
return positions.getPos( i );
}
std::vector<int> StructureCommons::getPosition(){
return std::vector<int> { x, y };
}
int StructureCommons::size(){
return positions.size();
}
std::vector<int> StructureCommons::getGridPositions(){
int nbTiles = positions.size();
std::vector<int> ret ( nbTiles * 2 );
for( int i = 0; i < nbTiles; i++ ){
std::vector<int> tilePos = positions.getPos( i );
//tilePos[ 0 ] += x;
//tilePos[ 1 ] += y;
ret[ i * 2 ] = tilePos[ 0 ] + x;
ret[ i * 2 + 1 ] = tilePos[ 1 ] + y;
}
return ret;
}
| 25.714286 | 95 | 0.65625 | [
"vector"
] |
5140da1fa102d5cc57b1fe8d742c2770ee3ddd6b | 917 | cpp | C++ | src/predecl/InvWishartDistrDecl.cpp | shiruizhao/swift | 2026acce35f0717c7a3e9dc522ff1c69f8dc3227 | [
"BSD-4-Clause-UC",
"BSD-4-Clause"
] | 22 | 2016-07-11T15:34:14.000Z | 2021-04-19T04:11:13.000Z | src/predecl/InvWishartDistrDecl.cpp | shiruizhao/swift | 2026acce35f0717c7a3e9dc522ff1c69f8dc3227 | [
"BSD-4-Clause-UC",
"BSD-4-Clause"
] | 14 | 2016-07-11T14:28:42.000Z | 2017-01-27T02:59:24.000Z | src/predecl/InvWishartDistrDecl.cpp | shiruizhao/swift | 2026acce35f0717c7a3e9dc522ff1c69f8dc3227 | [
"BSD-4-Clause-UC",
"BSD-4-Clause"
] | 7 | 2016-10-03T10:05:06.000Z | 2021-05-31T00:58:35.000Z | #include "InvWishartDistrDecl.h"
namespace swift {
namespace predecl {
InvWishartDistrDecl::InvWishartDistrDecl() :
PreDecl(std::string("InvWishart")) {
}
InvWishartDistrDecl::~InvWishartDistrDecl() {
}
std::shared_ptr<ir::Expr> InvWishartDistrDecl::getNew(
std::vector<std::shared_ptr<ir::Expr>>& args,
fabrica::TypeFactory* fact) const {
// Type Checking
if (args.size() != 2 || args[0] == nullptr || args[1] == nullptr)
return nullptr;
// First arg: matrix, second arg: Non-negative Integer
if (args[0]->getTyp() != fact->getTy(ir::IRConstString::MATRIX))
return nullptr;
if (args[1]->getTyp() != fact->getTy(ir::IRConstString::INT))
return nullptr;
auto ret = std::make_shared<ir::Distribution>(this->getName(), this);
ret->setArgs(args);
ret->setTyp(fact->getTy(ir::IRConstString::MATRIX));
ret->processArgRandomness();
ret->setRandom(true);
return ret;
}
}
}
| 24.783784 | 71 | 0.679389 | [
"vector"
] |
514173d60997371fa8d7457c87a408e19891832f | 2,278 | cpp | C++ | 201510_201609/1003_CR_qualA/Afinal.cpp | kazunetakahashi/atcoder | 16ce65829ccc180260b19316e276c2fcf6606c53 | [
"MIT"
] | 7 | 2019-03-24T14:06:29.000Z | 2020-09-17T21:16:36.000Z | 201510_201609/1003_CR_qualA/Afinal.cpp | kazunetakahashi/atcoder | 16ce65829ccc180260b19316e276c2fcf6606c53 | [
"MIT"
] | null | null | null | 201510_201609/1003_CR_qualA/Afinal.cpp | kazunetakahashi/atcoder | 16ce65829ccc180260b19316e276c2fcf6606c53 | [
"MIT"
] | 1 | 2020-07-22T17:27:09.000Z | 2020-07-22T17:27:09.000Z | #include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <algorithm>
#include <random>
#include <vector>
#include <tuple>
using namespace std;
typedef tuple<double, int, int, int> info;
string query(string url) {
FILE *f = popen(("curl -s -k \"" + url + "\"").c_str(), "r");
if (f == NULL) {
perror("error!");
}
char buf[1024];
string res;
while (!feof(f)) {
if (fgets(buf, 1024, f) == NULL) break;
res += (string)(buf);
}
pclose(f);
return res;
}
string vert(vector<int> V) {
string res = "";
for (unsigned i=0; i<V.size(); i++) {
res += to_string(V[i]);
if (i != V.size()-1) {
res += ",";
}
}
return res;
}
string vert_ch(vector<int> V) {
string res = "";
for (unsigned i=0; i<V.size(); i++) {
res += to_string(V[i]);
if (i != V.size()-1) {
res += " ";
}
}
return res;
}
int main() {
random_device rd;
mt19937 mt(rd());
string token = "D1307BDNFSM68CLQWVW9ALDW912YYWPE";
string url;
string result;
vector<int> V;
double c;
int score;
double d;
vector<info> seed;
while (cin >> c >> d) {
score = (int)d;
int x, y;
cin >> x >> y;
seed.push_back(make_tuple(c, -1 * score, x, y));
}
sort(seed.begin(), seed.end());
for (unsigned i=0; i<seed.size(); i++) {
string choten;
V.clear();
bool visited[1000];
fill(visited, visited+1000, false);
for (unsigned j=i; j<seed.size(); j++) {
// if (j != i && get<0>(seed[j]) < 0.00001) continue;
int x = get<2>(seed[j]);
int y = get<3>(seed[j]);
if (visited[x] || visited[y]) {
cout << "j = " << j << " : same" << endl;
continue;
}
visited[x] = true;
visited[y] = true;
V.push_back(x);
V.push_back(y);
choten = vert(V);
url = "https://game.coderunner.jp/query?token=" + token + "&v=" + choten;
result = query(url);
if (result == "0") {
V.erase(V.end()-1);
V.erase(V.end()-1);
visited[x] = false;
visited[y] = false;
cout << "j = " << j << " : failed" << endl;
} else {
cout << to_string((int)(V.size())) + " " + result + " " + vert_ch(V) << endl;
}
sleep(1);
}
}
return 0;
}
| 21.903846 | 86 | 0.507463 | [
"vector"
] |
5150444cea8f253907be27330a17eeccbdfa47a4 | 64,376 | cpp | C++ | Ruby2CORBA/ext/libr2tao/typecode.cpp | noda50/RubyItk | 2b494e98f14ad1b899a4d4476c61ff369e24b8ce | [
"Apache-2.0"
] | null | null | null | Ruby2CORBA/ext/libr2tao/typecode.cpp | noda50/RubyItk | 2b494e98f14ad1b899a4d4476c61ff369e24b8ce | [
"Apache-2.0"
] | null | null | null | Ruby2CORBA/ext/libr2tao/typecode.cpp | noda50/RubyItk | 2b494e98f14ad1b899a4d4476c61ff369e24b8ce | [
"Apache-2.0"
] | null | null | null | /*--------------------------------------------------------------------
# typecode.cpp - R2TAO CORBA TypeCode support
#
# Author: Martin Corino
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the R2CORBA LICENSE which is
# included with this program.
#
# Copyright (c) Remedy IT Expertise BV
# Chamber of commerce Rotterdam nr.276339, The Netherlands
#------------------------------------------------------------------*/
#include "required.h"
#include "typecode.h"
#include "exception.h"
#include "object.h"
#include "tao/IFR_Client/IFR_BaseC.h"
#include "tao/AnyTypeCode/True_RefCount_Policy.h"
#include "tao/AnyTypeCode/Sequence_TypeCode.h"
#include "tao/AnyTypeCode/Any.h"
#include "tao/AnyTypeCode/BooleanSeqA.h"
#include "tao/AnyTypeCode/CharSeqA.h"
#include "tao/AnyTypeCode/DoubleSeqA.h"
#include "tao/AnyTypeCode/FloatSeqA.h"
#include "tao/AnyTypeCode/LongDoubleSeqA.h"
#include "tao/AnyTypeCode/LongSeqA.h"
#include "tao/AnyTypeCode/OctetSeqA.h"
#include "tao/AnyTypeCode/ShortSeqA.h"
#include "tao/AnyTypeCode/StringSeqA.h"
#include "tao/AnyTypeCode/ULongSeqA.h"
#include "tao/AnyTypeCode/UShortSeqA.h"
#include "tao/AnyTypeCode/WCharSeqA.h"
#include "tao/AnyTypeCode/WStringSeqA.h"
#include "tao/AnyTypeCode/LongLongSeqA.h"
#include "tao/AnyTypeCode/ULongLongSeqA.h"
#include "tao/AnyTypeCode/Any_Dual_Impl_T.h"
#include "tao/BooleanSeqC.h"
#include "tao/CharSeqC.h"
#include "tao/DoubleSeqC.h"
#include "tao/FloatSeqC.h"
#include "tao/LongDoubleSeqC.h"
#include "tao/LongSeqC.h"
#include "tao/OctetSeqC.h"
#include "tao/ShortSeqC.h"
#include "tao/StringSeqC.h"
#include "tao/ULongSeqC.h"
#include "tao/UShortSeqC.h"
#include "tao/WCharSeqC.h"
#include "tao/WStringSeqC.h"
#include "tao/LongLongSeqC.h"
#include "tao/ULongLongSeqC.h"
#include "tao/DynamicAny/DynamicAny.h"
#include "tao/TypeCodeFactory/TypeCodeFactory_Loader.h"
#define CHECK_RTYPE(v,t)\
if (rb_type ((v)) != (t)) \
{ throw CORBA::BAD_PARAM(0, CORBA::COMPLETED_NO); }
VALUE R2TAO_EXPORT r2tao_cTypecode = 0;
static VALUE r2tao_cLongDouble;
//static VALUE r2tao_cTypecode_String;
static VALUE r2tao_cAny;
static VALUE rb_cBigDecimal;
static VALUE ld_alloc(VALUE klass);
static void ld_free(void* ptr);
static VALUE r2tao_LongDouble_initialize(int _argc, VALUE *_argv0, VALUE klass);
static VALUE r2tao_LongDouble_to_s(int _argc, VALUE *_argv, VALUE self);
static VALUE r2tao_LongDouble_to_f(VALUE self);
static VALUE r2tao_LongDouble_to_i(VALUE self);
static VALUE r2tao_LongDouble_size(VALUE self);
static VALUE r2tao_sym_default;
static VALUE tc_alloc(VALUE klass);
static void tc_free(void* ptr);
static VALUE rCORBA_Typecode_init(VALUE self, VALUE kind);
static void r2tao_Typecode_Ruby2Struct (CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rarr, CORBA::ORB_ptr _orb);
static void r2tao_Typecode_Ruby2Union (CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rs, CORBA::ORB_ptr _orb);
static void r2tao_Typecode_Ruby2Sequence(CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rarr, CORBA::ORB_ptr _orb);
static VALUE r2tao_Typecode_Struct2Ruby (const CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rtc, VALUE roottc, CORBA::ORB_ptr _orb);
static VALUE r2tao_Typecode_Union2Ruby (const CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rtc, VALUE roottc, CORBA::ORB_ptr _orb);
static VALUE r2tao_Typecode_Sequence2Ruby(const CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rtc, VALUE roottc, CORBA::ORB_ptr _orb);
static ID get_type_ID;
static ID typecode_for_any_ID;
static ID value_for_any_ID;
void r2tao_Init_Typecode()
{
VALUE k;
VALUE kinc;
if (r2tao_cTypecode) return;
//rb_eval_string("puts 'r2tao_Init_Typecode start' if $VERBOSE");
kinc = rb_eval_string("::R2CORBA::CORBA::Portable::TypeCode");
k = r2tao_cTypecode =
rb_define_class_under (r2tao_nsCORBA, "TypeCode", rb_cObject);
rb_define_alloc_func (r2tao_cTypecode, RUBY_ALLOC_FUNC (tc_alloc));
rb_include_module (r2tao_cTypecode, kinc);
r2tao_sym_default = rb_eval_string(":default");
//rb_eval_string("puts 'r2tao_Init_Typecode 2' if $VERBOSE");
// define Typecode methods
rb_define_private_method(k, "_init", RUBY_METHOD_FUNC(rCORBA_Typecode_init), 1);
// define Typecode-kind constants
rb_define_const (kinc, "TK_NULL", INT2NUM (CORBA::tk_null));
rb_define_const (kinc, "TK_VOID", INT2NUM (CORBA::tk_void));
rb_define_const (kinc, "TK_SHORT", INT2NUM (CORBA::tk_short));
rb_define_const (kinc, "TK_LONG", INT2NUM (CORBA::tk_long));
rb_define_const (kinc, "TK_USHORT", INT2NUM (CORBA::tk_ushort));
rb_define_const (kinc, "TK_ULONG", INT2NUM (CORBA::tk_ulong));
rb_define_const (kinc, "TK_FLOAT", INT2NUM (CORBA::tk_float));
rb_define_const (kinc, "TK_DOUBLE", INT2NUM (CORBA::tk_double));
rb_define_const (kinc, "TK_BOOLEAN", INT2NUM (CORBA::tk_boolean));
rb_define_const (kinc, "TK_CHAR", INT2NUM (CORBA::tk_char));
rb_define_const (kinc, "TK_OCTET", INT2NUM (CORBA::tk_octet));
rb_define_const (kinc, "TK_ANY", INT2NUM (CORBA::tk_any));
rb_define_const (kinc, "TK_TYPECODE", INT2NUM (CORBA::tk_TypeCode));
rb_define_const (kinc, "TK_PRINCIPAL", INT2NUM (CORBA::tk_Principal));
rb_define_const (kinc, "TK_OBJREF", INT2NUM (CORBA::tk_objref));
rb_define_const (kinc, "TK_STRUCT", INT2NUM (CORBA::tk_struct));
rb_define_const (kinc, "TK_UNION", INT2NUM (CORBA::tk_union));
rb_define_const (kinc, "TK_ENUM", INT2NUM (CORBA::tk_enum));
rb_define_const (kinc, "TK_STRING", INT2NUM (CORBA::tk_string));
rb_define_const (kinc, "TK_SEQUENCE", INT2NUM (CORBA::tk_sequence));
rb_define_const (kinc, "TK_ARRAY", INT2NUM (CORBA::tk_array));
rb_define_const (kinc, "TK_ALIAS", INT2NUM (CORBA::tk_alias));
rb_define_const (kinc, "TK_EXCEPT", INT2NUM (CORBA::tk_except));
rb_define_const (kinc, "TK_LONGLONG", INT2NUM (CORBA::tk_longlong));
rb_define_const (kinc, "TK_ULONGLONG", INT2NUM (CORBA::tk_ulonglong));
rb_define_const (kinc, "TK_LONGDOUBLE", INT2NUM (CORBA::tk_longdouble));
rb_define_const (kinc, "TK_WCHAR", INT2NUM (CORBA::tk_wchar));
rb_define_const (kinc, "TK_WSTRING", INT2NUM (CORBA::tk_wstring));
rb_define_const (kinc, "TK_FIXED", INT2NUM (CORBA::tk_fixed));
rb_define_const (kinc, "TK_VALUE", INT2NUM (CORBA::tk_value));
rb_define_const (kinc, "TK_VALUE_BOX", INT2NUM (CORBA::tk_value_box));
rb_define_const (kinc, "TK_NATIVE", INT2NUM (CORBA::tk_native));
rb_define_const (kinc, "TK_ABSTRACT_INTERFACE", INT2NUM (CORBA::tk_abstract_interface));
rb_define_const (kinc, "TK_LOCAL_INTERFACE", INT2NUM (CORBA::tk_local_interface));
rb_define_const (kinc, "TK_COMPONENT", INT2NUM (CORBA::tk_component));
rb_define_const (kinc, "TK_HOME", INT2NUM (CORBA::tk_home));
rb_define_const (kinc, "TK_EVENT", INT2NUM (CORBA::tk_event));
k = r2tao_cLongDouble =
rb_define_class_under (r2tao_nsCORBA, "LongDouble", rb_cObject);
rb_define_alloc_func (r2tao_cLongDouble, RUBY_ALLOC_FUNC (ld_alloc));
rb_define_method(k, "initialize", RUBY_METHOD_FUNC(r2tao_LongDouble_initialize), -1);
rb_define_method(k, "to_s", RUBY_METHOD_FUNC(r2tao_LongDouble_to_s), -1);
rb_define_method(k, "to_f", RUBY_METHOD_FUNC(r2tao_LongDouble_to_f), 0);
rb_define_method(k, "to_i", RUBY_METHOD_FUNC(r2tao_LongDouble_to_i), 0);
rb_define_singleton_method(k, "size", RUBY_METHOD_FUNC(r2tao_LongDouble_size), 0);
rb_require ("bigdecimal");
rb_cBigDecimal = rb_eval_string ("::BigDecimal");
r2tao_cAny = rb_eval_string ("R2CORBA::CORBA::Any");
get_type_ID = rb_intern ("get_type");
typecode_for_any_ID = rb_intern ("typecode_for_any");
value_for_any_ID = rb_intern ("value_for_any");
//rb_eval_string("puts 'r2tao_Init_Typecode end' if $VERBOSE");
}
static VALUE ld_alloc(VALUE klass)
{
VALUE obj;
ACE_CDR::LongDouble* ld = new ACE_CDR::LongDouble;
ACE_CDR_LONG_DOUBLE_ASSIGNMENT ((*ld), 0.0);
obj = Data_Wrap_Struct(klass, 0, ld_free, ld);
return obj;
}
static void ld_free(void* ptr)
{
if (ptr)
delete static_cast<ACE_CDR::LongDouble*> (ptr);
}
#if defined (NONNATIVE_LONGDOUBLE)
#define NATIVE_LONGDOUBLE ACE_CDR::LongDouble::NativeImpl
#else
#define NATIVE_LONGDOUBLE long double
#endif
#define RLD2CLD(_x) \
((NATIVE_LONGDOUBLE)*static_cast<ACE_CDR::LongDouble*> (DATA_PTR (_x)))
#define SETCLD2RLD(_x, _d) \
ACE_CDR_LONG_DOUBLE_ASSIGNMENT ((*static_cast<ACE_CDR::LongDouble*> (DATA_PTR (_x))), _d)
static VALUE r2tao_cld2rld(const NATIVE_LONGDOUBLE& _d)
{
VALUE _rd = Data_Wrap_Struct(r2tao_cLongDouble, 0, ld_free, new ACE_CDR::LongDouble);
SETCLD2RLD (_rd, _d);
return _rd;
}
#define CLD2RLD(_d) \
r2tao_cld2rld(_d)
VALUE r2tao_LongDouble_initialize(int _argc, VALUE *_argv, VALUE self)
{
VALUE v0, v1 = Qnil;
rb_scan_args(_argc, _argv, "11", &v0, &v1);
if (rb_obj_is_kind_of(v0, rb_cFloat) == Qtrue)
{
SETCLD2RLD(self, NUM2DBL(v0));
return self;
}
else if (rb_obj_is_kind_of(v0, rb_cBigDecimal) == Qtrue)
{
if (v1 != Qnil)
{
v0 = rb_funcall (v0, rb_intern ("round"), 1, v1);
}
v0 = rb_funcall (v0, rb_intern ("to_s"), 0);
}
if (rb_obj_is_kind_of(v0, rb_cString) == Qtrue)
{
char* endp = 0;
#if defined (NONNATIVE_LONGDOUBLE) && !defined (ACE_IMPLEMENT_WITH_NATIVE_LONGDOUBLE)
NATIVE_LONGDOUBLE _ld = ::strtod (RSTRING (v0)->ptr, &endp);
#else
NATIVE_LONGDOUBLE _ld = ::strtold (RSTRING (v0)->ptr, &endp);
#endif
if (errno == ERANGE)
rb_raise (rb_eRangeError, "floating point '%s' out-of-range", RSTRING (v0)->ptr);
if (RSTRING (v0)->ptr == endp)
rb_raise (rb_eArgError, "floating point string '%s' invalid", RSTRING (v0)->ptr);
SETCLD2RLD(self, _ld);
return self;
}
rb_raise (rb_eTypeError, "wrong argument type %s (expected Float, String or BigDecimal)",
rb_class2name(CLASS_OF(v0)));
return Qnil;
}
VALUE r2tao_LongDouble_to_s(int _argc, VALUE *_argv, VALUE self)
{
VALUE prec = Qnil;
rb_scan_args(_argc, _argv, "01", &prec);
unsigned long lprec = (prec == Qnil ? 0 : NUM2ULONG (prec));
R2TAO_TRY
{
unsigned long len = (lprec < 512) ? 1024 : 2*lprec;
CORBA::String_var buf = CORBA::string_alloc (len);
#if defined (NONNATIVE_LONGDOUBLE) && !defined (ACE_IMPLEMENT_WITH_NATIVE_LONGDOUBLE)
if (prec == Qnil)
ACE_OS::snprintf ((char*)buf, len-1, "%f", RLD2CLD(self));
else
ACE_OS::snprintf ((char*)buf, len-1, "%.*f", lprec, RLD2CLD(self));
#else
if (prec == Qnil)
ACE_OS::snprintf ((char*)buf, len-1, "%Lf", RLD2CLD(self));
else
ACE_OS::snprintf ((char*)buf, len-1, "%.*Lf", lprec, RLD2CLD(self));
#endif
return rb_str_new2 ((char*)buf);
}
R2TAO_CATCH;
return Qnil;
}
VALUE r2tao_LongDouble_to_f(VALUE self)
{
return rb_float_new (RLD2CLD(self));
}
VALUE r2tao_LongDouble_to_i(VALUE self)
{
unsigned long long l =
static_cast<unsigned long long> (RLD2CLD(self));
return ULL2NUM (l);
}
VALUE r2tao_LongDouble_size(VALUE /*self*/)
{
return INT2FIX (sizeof (NATIVE_LONGDOUBLE) * CHAR_BIT);
}
VALUE tc_alloc(VALUE klass)
{
VALUE obj;
// we start off without the C++ representation
obj = Data_Wrap_Struct(klass, 0, tc_free, 0);
return obj;
}
void tc_free(void* ptr)
{
if (ptr)
CORBA::release ((CORBA::TypeCode_ptr)ptr);
}
VALUE rCORBA_Typecode_init(VALUE self, VALUE kind)
{
CORBA::TypeCode_ptr tc = CORBA::TypeCode::_nil ();
switch ((CORBA::TCKind)NUM2INT (kind))
{
case CORBA::tk_null:
tc = CORBA::_tc_null;
break;
case CORBA::tk_void:
tc = CORBA::_tc_void;
break;
case CORBA::tk_short:
tc = CORBA::_tc_short;
break;
case CORBA::tk_long:
tc = CORBA::_tc_long;
break;
case CORBA::tk_ushort:
tc = CORBA::_tc_ushort;
break;
case CORBA::tk_ulong:
tc = CORBA::_tc_ulong;
break;
case CORBA::tk_longlong:
tc = CORBA::_tc_longlong;
break;
case CORBA::tk_ulonglong:
tc = CORBA::_tc_ulonglong;
break;
case CORBA::tk_float:
tc = CORBA::_tc_float;
break;
case CORBA::tk_double:
tc = CORBA::_tc_double;
break;
case CORBA::tk_longdouble:
tc = CORBA::_tc_longdouble;
break;
case CORBA::tk_boolean:
tc = CORBA::_tc_boolean;
break;
case CORBA::tk_char:
tc = CORBA::_tc_char;
break;
case CORBA::tk_octet:
tc = CORBA::_tc_octet;
break;
case CORBA::tk_wchar:
tc = CORBA::_tc_wchar;
break;
case CORBA::tk_any:
tc = CORBA::_tc_any;
break;
case CORBA::tk_TypeCode:
tc = CORBA::_tc_TypeCode;
break;
case CORBA::tk_Principal:
tc = CORBA::_tc_Principal;
break;
default:
return Qnil;
}
DATA_PTR(self) = CORBA::TypeCode::_duplicate (tc);
return Qnil;
}
/*===================================================================
* Typecodeconversion Ruby --> CORBA
*
*/
R2TAO_EXPORT CORBA::TypeCode_ptr r2tao_Typecode_r2t(VALUE rtc, CORBA::ORB_ptr _orb)
{
r2tao_check_type(rtc, r2tao_cTypecode);
if (DATA_PTR (rtc))
{
CORBA::TypeCode_ptr tc = static_cast<CORBA::TypeCode_ptr> (DATA_PTR (rtc));
return CORBA::TypeCode::_duplicate (tc);
}
CORBA::TypeCode_var _tc = CORBA::TypeCode::_nil ();
VALUE rkind = rb_iv_get (rtc, "@kind");
switch ((CORBA::TCKind)NUM2INT (rkind))
{
case CORBA::tk_objref:
{
VALUE rid = rb_iv_get (rtc, "@id");
VALUE rname = rb_iv_get (rtc, "@name");
_tc = _orb->create_interface_tc (RSTRING(rid)->ptr, RSTRING(rname)->ptr);
}
break;
case CORBA::tk_home:
{
VALUE rid = rb_iv_get (rtc, "@id");
VALUE rname = rb_iv_get (rtc, "@name");
_tc = _orb->create_home_tc (RSTRING(rid)->ptr, RSTRING(rname)->ptr);
}
break;
case CORBA::tk_component:
{
VALUE rid = rb_iv_get (rtc, "@id");
VALUE rname = rb_iv_get (rtc, "@name");
_tc = _orb->create_component_tc (RSTRING(rid)->ptr, RSTRING(rname)->ptr);
}
break;
case CORBA::tk_alias:
{
VALUE rid = rb_iv_get (rtc, "@id");
VALUE rname = rb_iv_get (rtc, "@name");
VALUE raliased_tc = rb_iv_get (rtc, "@aliased_tc");
CORBA::TypeCode_var _aliased_tc = r2tao_Typecode_r2t (raliased_tc, _orb);
_tc = _orb->create_alias_tc (RSTRING(rid)->ptr, RSTRING(rname)->ptr,
_aliased_tc.in ());
}
break;
case CORBA::tk_sequence:
case CORBA::tk_array:
{
VALUE rcontent_tc = rb_iv_get (rtc, "@content_tc");
VALUE is_recursive_tc = rb_funcall (rcontent_tc, rb_intern ("is_recursive_tc?"), 0);
VALUE rcont_bound = rb_iv_get (rtc, "@length");
CORBA::ULong _bound =
rcont_bound == Qnil ? 0 : NUM2ULONG (rcont_bound);
if (is_recursive_tc == Qtrue)
{
VALUE rid = rb_iv_get (rcontent_tc, "@id");
CORBA::TypeCode_var recursive_tc =
_orb->create_recursive_tc (RSTRING(rid)->ptr);
_tc = _orb->create_sequence_tc (_bound, recursive_tc.in ());
}
else
{
CORBA::TypeCode_var _ctc = r2tao_Typecode_r2t (rcontent_tc, _orb);
if (CORBA::tk_sequence == (CORBA::TCKind)NUM2INT (rkind))
{
if (_bound > 0)
{
_tc = _orb->create_sequence_tc (_bound, _ctc.in ());
}
else
{
switch (_ctc->kind ())
{
case CORBA::tk_short:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_ShortSeq);
break;
case CORBA::tk_long:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_LongSeq);
break;
case CORBA::tk_ushort:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_UShortSeq);
break;
case CORBA::tk_ulong:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_ULongSeq);
break;
case CORBA::tk_longlong:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_LongLongSeq);
break;
case CORBA::tk_ulonglong:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_ULongLongSeq);
break;
case CORBA::tk_float:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_FloatSeq);
break;
case CORBA::tk_double:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_DoubleSeq);
break;
case CORBA::tk_longdouble:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_LongDoubleSeq);
break;
case CORBA::tk_boolean:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_BooleanSeq);
break;
case CORBA::tk_char:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_CharSeq);
break;
case CORBA::tk_octet:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_OctetSeq);
break;
case CORBA::tk_wchar:
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_WCharSeq);
break;
default:
_tc = _orb->create_sequence_tc (_bound, _ctc.in ());
break;
}
}
}
else
{
_tc = _orb->create_array_tc (_bound, _ctc.in ());
}
}
}
break;
case CORBA::tk_string:
{
ID id_length = rb_intern ("@length");
VALUE rlength = Qnil;
if (rb_ivar_defined (rtc, id_length) == Qtrue)
rlength = rb_ivar_get (rtc, id_length);
if (rlength != Qnil)
{
_tc = _orb->create_string_tc (NUM2ULONG (rlength));
}
else
{
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_string);
}
}
break;
case CORBA::tk_wstring:
{
ID id_length = rb_intern ("@length");
VALUE rlength = Qnil;
if (rb_ivar_defined (rtc, id_length) == Qtrue)
rlength = rb_ivar_get (rtc, id_length);
if (rlength != Qnil)
{
_tc = _orb->create_wstring_tc (NUM2ULONG (rlength));
}
else
{
_tc = CORBA::TypeCode::_duplicate (CORBA::_tc_wstring);
}
}
break;
case CORBA::tk_except:
case CORBA::tk_struct:
{
VALUE rmembers = rb_iv_get (rtc, "@members");
CHECK_RTYPE(rmembers, T_ARRAY);
unsigned long count = static_cast<unsigned long> (RARRAY (rmembers)->len);
CORBA::StructMemberSeq members (count);
members.length (count);
for (unsigned long m=0; m<count ;++m)
{
VALUE mset = rb_ary_entry (rmembers, m);
CHECK_RTYPE(mset, T_ARRAY);
VALUE mname = rb_ary_entry (mset, 0);
CHECK_RTYPE(mname, T_STRING);
VALUE rmtc = rb_ary_entry (mset, 1);
CORBA::TypeCode_var mtc = r2tao_Typecode_r2t (rmtc, _orb);
members[m].name = CORBA::string_dup (RSTRING (mname)->ptr);
members[m].type = CORBA::TypeCode::_duplicate (mtc.in ());
}
VALUE repo_id = rb_iv_get (rtc, "@id");
VALUE name = rb_iv_get (rtc, "@name");
if (CORBA::tk_struct == (CORBA::TCKind)NUM2INT (rkind))
_tc = _orb->create_struct_tc (RSTRING (repo_id)->ptr,
RSTRING (name)->ptr,
members);
else
_tc = _orb->create_exception_tc (RSTRING (repo_id)->ptr,
RSTRING (name)->ptr,
members);
}
break;
case CORBA::tk_enum:
{
VALUE rmembers = rb_iv_get (rtc, "@members");
CHECK_RTYPE(rmembers, T_ARRAY);
unsigned long count = static_cast<unsigned long> (RARRAY (rmembers)->len);
CORBA::EnumMemberSeq members (count);
members.length (count);
for (unsigned long m=0; m<count ;++m)
{
VALUE el = rb_ary_entry (rmembers, m);
CHECK_RTYPE(el, T_STRING);
members[m] = CORBA::string_dup (RSTRING (el)->ptr);
}
VALUE repo_id = rb_iv_get (rtc, "@id");
VALUE name = rb_iv_get (rtc, "@name");
_tc = _orb->create_enum_tc (RSTRING (repo_id)->ptr,
RSTRING (name)->ptr,
members);
}
break;
case CORBA::tk_union:
{
VALUE rswtc = rb_iv_get (rtc, "@switchtype");
CORBA::TypeCode_var swtc = r2tao_Typecode_r2t (rswtc, _orb);
VALUE rmembers = rb_iv_get (rtc, "@members");
CHECK_RTYPE(rmembers, T_ARRAY);
unsigned long count = static_cast<unsigned long> (RARRAY (rmembers)->len);
CORBA::UnionMemberSeq members (count);
members.length (count);
long default_inx = NUM2ULONG (rb_funcall (rtc, rb_intern ("default_index"), 0));
for (unsigned long m=0; m<count ;++m)
{
VALUE mset = rb_ary_entry (rmembers, m);
CHECK_RTYPE(mset, T_ARRAY);
VALUE mname = rb_ary_entry (mset, 1);
CHECK_RTYPE(mname, T_STRING);
VALUE rmtc = rb_ary_entry (mset, 2);
CORBA::TypeCode_var mtc = r2tao_Typecode_r2t (rmtc, _orb);
if (default_inx<0 || default_inx != (long)m)
{
VALUE mlabel = rb_ary_entry (mset, 0);
r2tao_Typecode_Ruby2Any(members[m].label, swtc.in (), mlabel, _orb);
}
else
{
CORBA::Octet defval = 0;
members[m].label <<= CORBA::Any::from_octet(defval);
}
members[m].name = CORBA::string_dup (RSTRING (mname)->ptr);
members[m].type = CORBA::TypeCode::_duplicate (mtc. in());
}
VALUE repo_id = rb_iv_get (rtc, "@id");
VALUE name = rb_iv_get (rtc, "@name");
_tc = _orb->create_union_tc (RSTRING (repo_id)->ptr,
RSTRING (name)->ptr,
CORBA::TypeCode::_duplicate (swtc.in ()),
members);
}
break;
default:
{
}
break;
}
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc. in());
CORBA::TypeCode_ptr tc = static_cast<CORBA::TypeCode_ptr> (DATA_PTR (rtc));
return CORBA::TypeCode::_duplicate (tc);
}
/*===================================================================
* Typecodeconversion CORBA --> Ruby
*
*/
R2TAO_EXPORT VALUE r2tao_Typecode_t2r(CORBA::TypeCode_ptr _tc, CORBA::ORB_ptr _orb)
{
VALUE rtc = Qnil;
switch (_tc->kind ())
{
case CORBA::tk_null:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_null"), 0);
break;
case CORBA::tk_void:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_void"), 0);
break;
case CORBA::tk_short:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_short"), 0);
break;
case CORBA::tk_long:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_long"), 0);
break;
case CORBA::tk_ushort:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_ushort"), 0);
break;
case CORBA::tk_ulong:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_ulong"), 0);
break;
case CORBA::tk_longlong:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_longlong"), 0);
break;
case CORBA::tk_ulonglong:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_ulonglong"), 0);
break;
case CORBA::tk_float:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_float"), 0);
break;
case CORBA::tk_double:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_double"), 0);
break;
case CORBA::tk_longdouble:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_longdouble"), 0);
break;
case CORBA::tk_boolean:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_boolean"), 0);
break;
case CORBA::tk_char:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_char"), 0);
break;
case CORBA::tk_octet:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_octet"), 0);
break;
case CORBA::tk_wchar:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_wchar"), 0);
break;
case CORBA::tk_any:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_any"), 0);
break;
case CORBA::tk_TypeCode:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_TypeCode"), 0);
break;
case CORBA::tk_Principal:
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_Principal"), 0);
break;
case CORBA::tk_alias:
{
VALUE rid = rb_str_new2 (_tc->id ());
rtc = rb_funcall (r2tao_cTypecode, rb_intern ("typecode_for_id"), 1, rid);
if (rtc == Qnil)
{
CORBA::TypeCode_var alias_tc = _tc->content_type ();
VALUE ralias_tc = r2tao_Typecode_t2r(alias_tc.in (), _orb);
VALUE argv[4];
argv[0] = rid;
argv[1] = rb_str_new2 (_tc->name ());
argv[2] = Qnil;
argv[3] = ralias_tc;
rtc = rb_class_new_instance (4, argv, rb_eval_string ("::CORBA::TypeCode::Alias"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
break;
}
case CORBA::tk_string:
{
if (_tc->length ()>0)
{
VALUE argv[1];
argv[0] = ULL2NUM (_tc->length ());
rtc = rb_class_new_instance (1, argv, rb_eval_string ("::CORBA::TypeCode::String"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
else
{
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_string"), 0);
}
break;
}
case CORBA::tk_wstring:
{
if (_tc->length ()>0)
{
VALUE argv[1];
argv[0] = ULL2NUM (_tc->length ());
rtc = rb_class_new_instance (1, argv, rb_eval_string ("::CORBA::TypeCode::WString"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
else
{
rtc = rb_funcall (r2tao_nsCORBA, rb_intern ("_tc_wstring"), 0);
}
break;
}
case CORBA::tk_objref:
{
VALUE rid = rb_str_new2 (_tc->id ());
rtc = rb_funcall (r2tao_cTypecode, rb_intern ("typecode_for_id"), 1, rid);
if (rtc == Qnil)
{
VALUE argv[3];
argv[0] = rid;
argv[1] = rb_str_new2 (_tc->name ());
argv[2] = r2tao_cObject;
rtc = rb_class_new_instance (3, argv, rb_eval_string ("::CORBA::TypeCode::ObjectRef"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
break;
}
case CORBA::tk_home:
{
VALUE rid = rb_str_new2 (_tc->id ());
rtc = rb_funcall (r2tao_cTypecode, rb_intern ("typecode_for_id"), 1, rid);
if (rtc == Qnil)
{
VALUE argv[3];
argv[0] = rid;
argv[1] = rb_str_new2 (_tc->name ());
argv[2] = r2tao_cObject;
rtc = rb_class_new_instance (3, argv, rb_eval_string ("::CORBA::TypeCode::Home"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
break;
}
case CORBA::tk_component:
{
VALUE rid = rb_str_new2 (_tc->id ());
rtc = rb_funcall (r2tao_cTypecode, rb_intern ("typecode_for_id"), 1, rid);
if (rtc == Qnil)
{
VALUE argv[3];
argv[0] = rid;
argv[1] = rb_str_new2 (_tc->name ());
argv[2] = r2tao_cObject;
rtc = rb_class_new_instance (3, argv, rb_eval_string ("::CORBA::TypeCode::Component"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
break;
}
case CORBA::tk_sequence:
{
CORBA::TypeCode_var ctc = _tc->content_type ();
VALUE rcontent_tc = r2tao_Typecode_t2r(ctc.in (), _orb);
VALUE argv[2];
argv[0] = rcontent_tc;
argv[1] = _tc->length ()>0 ? ULL2NUM (_tc->length ()) : Qnil;
rtc = rb_class_new_instance (2, argv, rb_eval_string ("::CORBA::TypeCode::Sequence"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
break;
}
case CORBA::tk_array:
{
// count dimensions
int numsizes = 1;
CORBA::TypeCode_var _ctc = _tc->content_type ();
while (_ctc->kind () == CORBA::tk_array)
{
numsizes++;
_ctc = _ctc->content_type ();
}
// get actual content type
VALUE rcontent_tc = r2tao_Typecode_t2r(_ctc.in (), _orb);
// setup constructor arguments
ACE_Auto_Basic_Ptr<VALUE> argv(new VALUE[1+numsizes]);
argv.get()[0] = rcontent_tc;
argv.get()[1] = ULL2NUM (_tc->length ());
_ctc = _tc->content_type ();
for (int i=1; i<numsizes ;++i)
{
argv.get()[i+1] = ULL2NUM (_ctc->length ());
_ctc = _ctc->content_type ();
}
// create new Array typecode
rtc = rb_class_new_instance (numsizes+1, argv.get(), rb_eval_string ("::CORBA::TypeCode::Array"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
break;
}
case CORBA::tk_except:
case CORBA::tk_struct:
{
VALUE rid = rb_str_new2 (_tc->id ());
rtc = rb_funcall (r2tao_cTypecode, rb_intern ("typecode_for_id"), 1, rid);
if (rtc == Qnil)
{
unsigned long mcount = _tc->member_count ();
VALUE rmembers = rb_ary_new2 (mcount);
for (unsigned long l=0; l<mcount ;++l)
{
VALUE rmember = rb_ary_new2 (2);
rb_ary_push (rmember, rb_str_new2 (_tc->member_name (l)));
CORBA::TypeCode_var mtc = _tc->member_type (l);
rb_ary_push (rmember, r2tao_Typecode_t2r (mtc.in (), _orb));
rb_ary_push (rmembers, rmember);
}
VALUE argv[4];
argv[0] = rid;
argv[1] = rb_str_new2 (_tc->name ());
argv[2] = Qnil;
argv[3] = rmembers;
rtc = rb_class_new_instance (4, argv,
_tc->kind () == CORBA::tk_struct ?
rb_eval_string ("::CORBA::TypeCode::Struct") :
rb_eval_string ("::CORBA::TypeCode::Except"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
break;
}
case CORBA::tk_enum:
{
VALUE rid = rb_str_new2 (_tc->id ());
rtc = rb_funcall (r2tao_cTypecode, rb_intern ("typecode_for_id"), 1, rid);
if (rtc == Qnil)
{
unsigned long mcount = _tc->member_count ();
VALUE rmembers = rb_ary_new2 (mcount);
for (unsigned long l=0; l<mcount ;++l)
{
rb_ary_push (rmembers, rb_str_new2 (_tc->member_name (l)));
}
VALUE argv[3];
argv[0] = rid;
argv[1] = rb_str_new2 (_tc->name ());
argv[2] = rmembers;
rtc = rb_class_new_instance (3, argv, rb_eval_string ("::CORBA::TypeCode::Enum"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
break;
}
case CORBA::tk_union:
{
VALUE rid = rb_str_new2 (_tc->id ());
rtc = rb_funcall (r2tao_cTypecode, rb_intern ("typecode_for_id"), 1, rid);
if (rtc == Qnil)
{
CORBA::TypeCode_var swtc = _tc->discriminator_type ();
VALUE rswtc = r2tao_Typecode_t2r (swtc.in (), _orb);
unsigned long mcount = _tc->member_count ();
VALUE rmembers = rb_ary_new2 (mcount);
long default_inx = _tc->default_index ();
for (unsigned long l=0; l<mcount ;++l)
{
VALUE rmember = rb_ary_new2 (2);
if (default_inx<0 || default_inx != (long)l)
{
rb_ary_push (rmember, r2tao_Typecode_Any2Ruby(*_tc->member_label (l), swtc.in (), rswtc, rswtc, _orb));
}
else
{
rb_ary_push (rmember, r2tao_sym_default);
}
rb_ary_push (rmember, rb_str_new2 (_tc->member_name (l)));
CORBA::TypeCode_var mtc = _tc->member_type (l);
rb_ary_push (rmember, r2tao_Typecode_t2r (mtc.in (), _orb));
rb_ary_push (rmembers, rmember);
}
VALUE argv[5];
argv[0] = rid;
argv[1] = rb_str_new2 (_tc->name ());
argv[2] = Qnil;
argv[3] = rswtc;
argv[4] = rmembers;
rtc = rb_class_new_instance (4, argv,
rb_eval_string ("::CORBA::TypeCode::Union"));
DATA_PTR(rtc) = CORBA::TypeCode::_duplicate (_tc);
}
break;
}
default:
return Qnil;
}
if (rtc == Qnil)
{
ACE_ERROR ((LM_ERROR, "R2TAO::Unable to convert TAO typecode to Ruby\n"));
throw ::CORBA::BAD_TYPECODE (0, CORBA::COMPLETED_NO);
}
return rtc;
}
/*===================================================================
* Dynamic Any factory
*
*/
DynamicAny::DynAny_ptr r2tao_Typecode_CreateDynAny (CORBA::ORB_ptr _orb, const CORBA::Any& _any)
{
CORBA::Object_var factory_obj =
_orb->resolve_initial_references ("DynAnyFactory");
DynamicAny::DynAnyFactory_var dynany_factory =
DynamicAny::DynAnyFactory::_narrow (factory_obj.in ());
if (CORBA::is_nil (dynany_factory.in ()))
{
ACE_ERROR ((LM_ERROR, "R2TAO::Unable to resolve DynAnyFactory\n"));
throw ::CORBA::INV_OBJREF (0, CORBA::COMPLETED_NO);
}
DynamicAny::DynAny_ptr da =
dynany_factory->create_dyn_any (_any);
return da;
}
DynamicAny::DynAny_ptr r2tao_Typecode_CreateDynAny4tc (CORBA::ORB_ptr _orb, CORBA::TypeCode_ptr _tc)
{
CORBA::Object_var factory_obj =
_orb->resolve_initial_references ("DynAnyFactory");
DynamicAny::DynAnyFactory_var dynany_factory =
DynamicAny::DynAnyFactory::_narrow (factory_obj.in ());
if (CORBA::is_nil (dynany_factory.in ()))
{
ACE_ERROR ((LM_ERROR, "R2TAO::Unable to resolve DynAnyFactory\n"));
throw ::CORBA::INV_OBJREF (0, CORBA::COMPLETED_NO);
}
DynamicAny::DynAny_ptr da =
dynany_factory->create_dyn_any_from_type_code (_tc);
return da;
}
/*===================================================================
* Dataconversion Ruby --> CORBA Any
*
*/
void r2tao_Typecode_Ruby2Struct (CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rs, CORBA::ORB_ptr _orb)
{
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny4tc (_orb, _tc);
DynamicAny::DynStruct_var das = DynamicAny::DynStruct::_narrow (da.in ());
if (rs != Qnil)
{
CORBA::ULong mcount = _tc->member_count ();
DynamicAny::NameValuePairSeq_var nvps = das->get_members ();
for (CORBA::ULong m=0; m<mcount ;++m)
{
CORBA::TypeCode_var mtc = _tc->member_type (m);
VALUE mval = rb_funcall (rs, rb_intern (_tc->member_name (m)), 0);
r2tao_Typecode_Ruby2Any (nvps[m].value, mtc.in (), mval, _orb);
}
das->set_members (nvps);
}
CORBA::Any_var av = das->to_any ();
_any = av.in ();
das->destroy ();
}
void r2tao_Typecode_Ruby2Union (CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE ru, CORBA::ORB_ptr _orb)
{
if (TAO_debug_level > 5)
ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - Typecode_Ruby2Union:: kind=%d, rval=%d\n", _tc->kind (), ru));
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny4tc (_orb, _tc);
DynamicAny::DynUnion_var dau = DynamicAny::DynUnion::_narrow (da.in ());
if (ru != Qnil)
{
VALUE at_default = rb_funcall (ru, rb_intern ("_is_at_default?"), 0);
VALUE value = rb_iv_get (ru, "@value");
VALUE disc = rb_iv_get (ru, "@discriminator");
if (at_default == Qfalse)
{
if (disc == Qnil)
{
dau->set_to_no_active_member ();
}
else
{
CORBA::Any_var _any = new CORBA::Any;
CORBA::TypeCode_var dtc = _tc->discriminator_type ();
r2tao_Typecode_Ruby2Any(*_any, dtc.in (), disc, _orb);
DynamicAny::DynAny_var _dyna = r2tao_Typecode_CreateDynAny (_orb, *_any);
dau->set_discriminator (_dyna.in ());
}
}
else
{
dau->set_to_default_member ();
}
if (disc != Qnil && value != Qnil)
{
VALUE rvaltc = rb_funcall (ru, rb_intern("_value_tc"), 0);
CORBA::TypeCode_var valtc = r2tao_Typecode_r2t (rvaltc, _orb);
CORBA::Any_var _any = new CORBA::Any;
r2tao_Typecode_Ruby2Any(*_any, valtc.in (), value, _orb);
DynamicAny::DynAny_var dynval = dau->member ();
dynval->from_any (*_any);
}
}
CORBA::Any_var av = dau->to_any ();
_any = av.in ();
dau->destroy ();
}
void r2tao_Typecode_Ruby2Sequence(CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rarr, CORBA::ORB_ptr _orb)
{
CORBA::TypeCode_var _ctc = _tc->content_type ();
if (TAO_debug_level > 5)
ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - Typecode_Ruby2Sequence:: content kind=%d, rval type=%d\n", _ctc->kind (), rb_type (rarr)));
CORBA::ULong alen = 0;
if (rarr != Qnil)
{
switch (_ctc->kind ())
{
case CORBA::tk_char:
case CORBA::tk_octet:
CHECK_RTYPE(rarr, T_STRING);
alen = static_cast<unsigned long> (RSTRING (rarr)->len);
break;
default:
CHECK_RTYPE(rarr, T_ARRAY);
alen = static_cast<unsigned long> (RARRAY (rarr)->len);
break;
}
}
switch (_ctc->kind ())
{
case CORBA::tk_short:
{
CORBA::ShortSeq_var tmp = new CORBA::ShortSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::Short)NUM2INT (el);
}
_any <<= tmp;
return;
}
case CORBA::tk_long:
{
CORBA::LongSeq_var tmp = new CORBA::LongSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::Long)NUM2LONG (el);
}
_any <<= tmp;
return;
}
case CORBA::tk_ushort:
{
CORBA::UShortSeq_var tmp = new CORBA::UShortSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::UShort)NUM2UINT (el);
}
_any <<= tmp;
return;
}
case CORBA::tk_ulong:
{
CORBA::ULongSeq_var tmp = new CORBA::ULongSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::ULong)NUM2ULONG (el);
}
_any <<= tmp;
return;
}
case CORBA::tk_longlong:
{
CORBA::LongLongSeq_var tmp = new CORBA::LongLongSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::LongLong)NUM2LL (el);
}
_any <<= tmp;
return;
}
case CORBA::tk_ulonglong:
{
CORBA::ULongLongSeq_var tmp = new CORBA::ULongLongSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::ULongLong)NUM2ULL (el);
}
_any <<= tmp;
return;
}
case CORBA::tk_float:
{
CORBA::FloatSeq_var tmp = new CORBA::FloatSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::Float)NUM2DBL (el);
}
_any <<= tmp;
return;
}
case CORBA::tk_double:
{
CORBA::DoubleSeq_var tmp = new CORBA::DoubleSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::Double)NUM2DBL (el);
}
_any <<= tmp;
return;
}
case CORBA::tk_longdouble:
{
CORBA::LongDoubleSeq_var tmp = new CORBA::LongDoubleSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
ACE_CDR_LONG_DOUBLE_ASSIGNMENT (tmp[l], CLD2RLD (el));
}
_any <<= tmp;
return;
}
case CORBA::tk_boolean:
{
CORBA::BooleanSeq_var tmp = new CORBA::BooleanSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::Boolean)(el == Qtrue ? true : false);
}
_any <<= tmp;
return;
}
case CORBA::tk_char:
{
char* s = rarr != Qnil ? RSTRING (rarr)->ptr : 0;
CORBA::CharSeq_var tmp = new CORBA::CharSeq();
tmp->length (alen);
for (unsigned long l=0; l<alen ;++l)
{
tmp[l] = s[l];
}
_any <<= tmp;
return;
}
case CORBA::tk_octet:
{
unsigned char* s = rarr != Qnil ? (unsigned char*)RSTRING (rarr)->ptr : 0;
CORBA::OctetSeq_var tmp = new CORBA::OctetSeq();
tmp->length (alen);
for (unsigned long l=0; l<alen ;++l)
{
tmp[l] = s[l];
}
_any <<= tmp;
return;
}
case CORBA::tk_wchar:
{
CORBA::WCharSeq_var tmp = new CORBA::WCharSeq();
tmp->length (alen);
for (CORBA::ULong l=0; l<alen ;++l)
{
VALUE el = rb_ary_entry (rarr, l);
tmp[l] = (CORBA::WChar)NUM2INT (el);
}
_any <<= tmp;
return;
}
default:
{
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny4tc (_orb, _tc);
DynamicAny::DynSequence_var das = DynamicAny::DynSequence::_narrow (da.in ());
if (rarr != Qnil && alen > 0)
{
CORBA::ULong seqmax = _tc->length ();
DynamicAny::AnySeq_var elems =
seqmax == 0 ? new DynamicAny::AnySeq () : new DynamicAny::AnySeq (seqmax);
elems->length (alen);
for (CORBA::ULong e=0; e<alen ;++e)
{
VALUE eval = rb_ary_entry (rarr, e);
r2tao_Typecode_Ruby2Any (elems[e], _ctc.in (), eval, _orb);
}
das->set_elements (elems);
}
CORBA::Any_var av = das->to_any ();
_any = av.in ();
das->destroy ();
return;
}
}
ACE_ERROR ((LM_ERROR, "R2TAO::Unable to convert Ruby sequence to TAO\n"));
throw ::CORBA::NO_IMPLEMENT (0, CORBA::COMPLETED_NO);
}
R2TAO_EXPORT void r2tao_Typecode_Ruby2Any(CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rval, CORBA::ORB_ptr _orb)
{
if (TAO_debug_level > 5)
ACE_DEBUG ((LM_INFO, "R2TAO (%P|%t) - Typecode_Ruby2Any:: kind=%d, rval=%d\n", _tc->kind (), rval));
switch (_tc->kind ())
{
case CORBA::tk_null:
case CORBA::tk_void:
break;
case CORBA::tk_alias:
{
CORBA::TypeCode_var _ctc = _tc->content_type ();
r2tao_Typecode_Ruby2Any(_any, _ctc.in (), rval, _orb);
return;
}
case CORBA::tk_short:
{
CORBA::Short val = rval == Qnil ? 0 : NUM2INT (rval);
_any <<= val;
return;
}
case CORBA::tk_long:
{
CORBA::Long val = rval == Qnil ? 0 : NUM2INT (rval);
_any <<= val;
return;
}
case CORBA::tk_ushort:
{
CORBA::UShort val = rval == Qnil ? 0 : NUM2UINT (rval);
_any <<= val;
return;
}
case CORBA::tk_ulong:
{
CORBA::ULong val = rval == Qnil ? 0 : NUM2ULONG (rval);
_any <<= val;
return;
}
case CORBA::tk_longlong:
{
CORBA::LongLong val = rval == Qnil ? 0 : NUM2LL (rval);
_any <<= val;
return;
}
case CORBA::tk_ulonglong:
{
CORBA::ULongLong val = rval == Qnil ? 0 : NUM2ULL (rval);
_any <<= val;
return;
}
case CORBA::tk_float:
{
CORBA::Float val = rval == Qnil ? 0.0f : (CORBA::Float)NUM2DBL (rval);
_any <<= val;
return;
}
case CORBA::tk_double:
{
CORBA::Double val = rval == Qnil ? 0.0 : NUM2DBL (rval);
_any <<= val;
return;
}
case CORBA::tk_longdouble:
{
CORBA::LongDouble val;
ACE_CDR_LONG_DOUBLE_ASSIGNMENT (val, rval == Qnil ? 0.0 : RLD2CLD (rval));
_any <<= val;
return;
}
case CORBA::tk_boolean:
{
CORBA::Boolean val = (rval == Qnil || rval == Qfalse) ? 0 : 1;
_any <<= CORBA::Any::from_boolean (val);
return;
}
case CORBA::tk_char:
{
CORBA::Char val = 0;
if (rval != Qnil)
{
CHECK_RTYPE(rval, T_STRING);
val = *RSTRING (rval)->ptr;
}
_any <<= CORBA::Any::from_char (val);
return;
}
case CORBA::tk_octet:
{
CORBA::Octet val = rval == Qnil ? 0 : NUM2UINT (rval);
_any <<= CORBA::Any::from_octet (val);
return;
}
case CORBA::tk_wchar:
{
CORBA::WChar val = rval == Qnil ? 0 : NUM2UINT (rval);
_any <<= CORBA::Any::from_wchar (val);
return;
}
case CORBA::tk_string:
{
if (rval == Qnil)
{
_any <<= (char*)0;
}
else
{
CHECK_RTYPE(rval, T_STRING);
_any <<= RSTRING (rval)->ptr;
}
return;
}
case CORBA::tk_wstring:
{
if (rval == Qnil)
{
_any <<= (CORBA::WChar*)0;
}
else
{
CHECK_RTYPE(rval, T_ARRAY);
CORBA::ULong alen = static_cast<unsigned long> (RARRAY (rval)->len);
CORBA::WString_var ws = CORBA::wstring_alloc (alen+1);
for (CORBA::ULong l=0; l<alen ;++l)
{
ws[l] = static_cast<CORBA::WChar> (NUM2INT (rb_ary_entry (rval, l)));
}
ws[alen] = static_cast<CORBA::WChar> (0);
_any <<= ws;
}
return;
}
case CORBA::tk_enum:
{
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny4tc (_orb, _tc);
DynamicAny::DynEnum_var das = DynamicAny::DynEnum::_narrow (da.in ());
if (rval != Qnil)
{
das->set_as_ulong (NUM2ULONG (rval));
}
CORBA::Any_var av = das->to_any ();
_any = av.in ();
das->destroy ();
return;
}
case CORBA::tk_array:
{
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny4tc (_orb, _tc);
DynamicAny::DynArray_var das = DynamicAny::DynArray::_narrow (da.in ());
if (rval != Qnil)
{
CORBA::ULong arrlen = _tc->length ();
DynamicAny::AnySeq_var elems = new DynamicAny::AnySeq (arrlen);
elems->length (arrlen);
CORBA::TypeCode_var etc = _tc->content_type ();
for (CORBA::ULong e=0; e<arrlen ;++e)
{
VALUE eval = rb_ary_entry (rval, e);
r2tao_Typecode_Ruby2Any (elems[e], etc.in (), eval, _orb);
}
das->set_elements (elems);
}
CORBA::Any_var av = das->to_any ();
_any = av.in ();
das->destroy ();
return;
}
case CORBA::tk_sequence:
{
r2tao_Typecode_Ruby2Sequence(_any, _tc, rval, _orb);
return;
}
case CORBA::tk_except:
case CORBA::tk_struct:
{
r2tao_Typecode_Ruby2Struct (_any, _tc, rval, _orb);
return;
}
case CORBA::tk_union:
{
r2tao_Typecode_Ruby2Union (_any, _tc, rval, _orb);
return;
}
case CORBA::tk_objref:
{
if (rval != Qnil)
{
_any <<= r2tao_Object_r2t (rval);
}
else
{
_any <<= CORBA::Object::_nil ();
}
return;
}
case CORBA::tk_any:
{
CORBA::Any anyval;
r2tao_Ruby_to_Any(anyval, rval, _orb);
_any <<= anyval;
return;
}
case CORBA::tk_TypeCode:
{
if (rval != Qnil)
{
CORBA::TypeCode_var tctc = r2tao_Typecode_r2t (rval, _orb);
_any <<= tctc.in ();
}
else
{
_any <<= CORBA::TypeCode::_nil ();
}
return;
}
case CORBA::tk_Principal:
{
break;
}
default:
break;
}
ACE_ERROR ((LM_ERROR, "R2TAO::Unable to convert Ruby data to TAO\n"));
throw ::CORBA::NO_IMPLEMENT (0, CORBA::COMPLETED_NO);
}
void r2tao_Ruby_to_Any(CORBA::Any& _any, VALUE val, CORBA::ORB_ptr _orb)
{
if (val != Qnil)
{
VALUE rvaltc = rb_funcall (r2tao_cAny, typecode_for_any_ID, 1, val);
if (rvaltc == Qnil)
{
ACE_ERROR ((LM_ERROR, "R2TAO::invalid datatype for CORBA::Any\n"));
throw ::CORBA::MARSHAL (0, ::CORBA::COMPLETED_NO);
}
CORBA::TypeCode_var atc = r2tao_Typecode_r2t (rvaltc, _orb);
r2tao_Typecode_Ruby2Any (_any,
atc.in (),
rb_funcall (r2tao_cAny, value_for_any_ID, 1, val),
_orb);
}
}
/*===================================================================
* Dataconversion CORBA Any --> Ruby
*
*/
#define R2TAO_TCTYPE(rtc) \
rb_funcall ((rtc), get_type_ID, 0)
#define R2TAO_NEW_TCOBJECT(rtc) \
rb_class_new_instance (0, 0, rb_funcall ((rtc), get_type_ID, 0))
VALUE r2tao_Typecode_Struct2Ruby (const CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rtc, VALUE roottc, CORBA::ORB_ptr _orb)
{
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny (_orb, _any);
DynamicAny::DynStruct_var das = DynamicAny::DynStruct::_narrow (da.in ());
VALUE new_rs = R2TAO_NEW_TCOBJECT (roottc);
CORBA::ULong mcount = _tc->member_count ();
DynamicAny::NameValuePairSeq_var nvps = das->get_members ();
VALUE rtc_members = rb_iv_get (rtc, "@members");
for (CORBA::ULong m=0; m<mcount ;++m)
{
CORBA::TypeCode_var mtc = _tc->member_type (m);
VALUE mset = rb_ary_entry (rtc_members, m);
VALUE mrtc = rb_ary_entry (mset, 1);
VALUE rmval = r2tao_Typecode_Any2Ruby (nvps[m].value, mtc.in (), mrtc, mrtc, _orb);
const char* name = _tc->member_name (m);
CORBA::String_var mname = CORBA::string_alloc (2 + ACE_OS::strlen (name));
ACE_OS::sprintf ((char*)mname.in (), "@%s", name);
rb_iv_set (new_rs, mname.in (), rmval);
}
das->destroy ();
return new_rs;
}
VALUE r2tao_Typecode_Union2Ruby (const CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rtc, VALUE roottc, CORBA::ORB_ptr _orb)
{
VALUE new_ru = R2TAO_NEW_TCOBJECT (roottc);
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny (_orb, _any);
DynamicAny::DynUnion_var dau = DynamicAny::DynUnion::_narrow (da.in ());
if (!dau->has_no_active_member ())
{
DynamicAny::DynAny_var dyndisc = dau->get_discriminator ();
CORBA::Any_var anydisc = dyndisc->to_any ();
CORBA::Octet defval;
VALUE rdisc;
if ((anydisc >>= CORBA::Any::to_octet (defval)) == 1 && defval == 0)
{
rdisc = r2tao_sym_default;
}
else
{
VALUE rdisctype = rb_funcall (rtc, rb_intern ("discriminator_type"), 0);
CORBA::TypeCode_var dtc = _tc->discriminator_type ();
rdisc = r2tao_Typecode_Any2Ruby (*anydisc, dtc.in (), rdisctype, rdisctype, _orb);
}
rb_iv_set (new_ru, "@discriminator", rdisc);
DynamicAny::DynAny_var dynval = dau->member ();
CORBA::Any_var anyval = dynval->to_any ();
VALUE rvaltc = rb_funcall (new_ru, rb_intern ("_value_tc"), 0);
CORBA::TypeCode_var valtc = r2tao_Typecode_r2t (rvaltc, _orb);
VALUE rvalue = r2tao_Typecode_Any2Ruby (*anyval, valtc.in (), rvaltc, rvaltc, _orb);
rb_iv_set (new_ru, "@value", rvalue);
}
dau->destroy ();
return new_ru;
}
VALUE r2tao_Typecode_Sequence2Ruby(const CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rtc, VALUE roottc, CORBA::ORB_ptr _orb)
{
VALUE rtcklass = R2TAO_TCTYPE(roottc);
switch (_tc->content_type ()->kind ())
{
case CORBA::tk_short:
{
const CORBA::ShortSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::ShortSeq>::extract (
_any,
CORBA::ShortSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, INT2FIX ((int)(*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_long:
{
const CORBA::LongSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::LongSeq>::extract (
_any,
CORBA::LongSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, INT2FIX ((long)(*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_ushort:
{
const CORBA::UShortSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::UShortSeq>::extract (
_any,
CORBA::UShortSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, INT2FIX ((int)(*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_ulong:
{
const CORBA::ULongSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::ULongSeq>::extract (
_any,
CORBA::ULongSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, ULONG2NUM ((unsigned long)(*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_longlong:
{
const CORBA::LongLongSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::LongLongSeq>::extract (
_any,
CORBA::LongLongSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, LL2NUM ((*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_ulonglong:
{
const CORBA::ULongLongSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::ULongLongSeq>::extract (
_any,
CORBA::ULongLongSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, ULL2NUM ((*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_float:
{
const CORBA::FloatSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::FloatSeq>::extract (
_any,
CORBA::FloatSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, rb_float_new ((CORBA::Double)(*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_double:
{
const CORBA::DoubleSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::DoubleSeq>::extract (
_any,
CORBA::DoubleSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, rb_float_new ((*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_longdouble:
{
const CORBA::LongDoubleSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::LongDoubleSeq>::extract (
_any,
CORBA::DoubleSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, CLD2RLD ((*tmp)[l]));
}
return ret;
}
break;
}
case CORBA::tk_boolean:
{
const CORBA::BooleanSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::BooleanSeq>::extract (
_any,
CORBA::BooleanSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, ((*tmp)[l] ? Qtrue : Qfalse));
}
return ret;
}
break;
}
case CORBA::tk_char:
{
const CORBA::CharSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::CharSeq>::extract (
_any,
CORBA::CharSeq::_tao_any_destructor,
_tc,
tmp))
{
return rb_str_new ((char*)tmp->get_buffer (), (long)tmp->length ());
}
break;
}
case CORBA::tk_octet:
{
const CORBA::OctetSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::OctetSeq>::extract (
_any,
CORBA::OctetSeq::_tao_any_destructor,
_tc,
tmp))
{
return rb_str_new ((char*)tmp->get_buffer (), (long)tmp->length ());
}
break;
}
case CORBA::tk_wchar:
{
const CORBA::WCharSeq* tmp;
if (TAO::Any_Dual_Impl_T<CORBA::WCharSeq>::extract (
_any,
CORBA::WCharSeq::_tao_any_destructor,
_tc,
tmp))
{
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)tmp->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<tmp->length () ;++l)
{
rb_ary_push (ret, INT2FIX ((int)(*tmp)[l]));
}
return ret;
}
break;
}
default:
{
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny (_orb, _any);
DynamicAny::DynSequence_var das = DynamicAny::DynSequence::_narrow (da.in ());
DynamicAny::AnySeq_var elems = das->get_elements ();
CORBA::ULong seqlen = elems->length ();
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)seqlen) :
rb_class_new_instance (0, 0, rtcklass);
CORBA::TypeCode_var etc = _tc->content_type ();
VALUE ertc = rb_iv_get (rtc, "@content_tc");
VALUE is_recursive_tc = rb_funcall (ertc, rb_intern ("is_recursive_tc?"), 0);
if (is_recursive_tc == Qtrue)
{
ertc = rb_funcall (ertc, rb_intern ("recursed_tc"), 0);
}
for (CORBA::ULong l=0; l<seqlen ;++l)
{
VALUE rval = r2tao_Typecode_Any2Ruby (elems[l], etc.in (), ertc, ertc, _orb);
rb_ary_push (ret, rval);
}
das->destroy ();
return ret;
}
}
ACE_ERROR ((LM_ERROR, "R2TAO::Cannot convert TAO sequence to Ruby\n"));
throw ::CORBA::NO_IMPLEMENT (0, CORBA::COMPLETED_NO);
return Qnil;
}
R2TAO_EXPORT VALUE r2tao_Typecode_Any2Ruby(const CORBA::Any& _any, CORBA::TypeCode_ptr _tc, VALUE rtc, VALUE roottc, CORBA::ORB_ptr _orb)
{
switch (_tc->kind ())
{
case CORBA::tk_null:
case CORBA::tk_void:
return Qnil;
case CORBA::tk_alias:
{
VALUE raliased_type = rb_iv_get (rtc, "@aliased_tc");
CORBA::TypeCode_var ctc = _tc->content_type ();
return r2tao_Typecode_Any2Ruby(_any, ctc.in (), raliased_type, roottc, _orb);
}
case CORBA::tk_short:
{
CORBA::Short val;
_any >>= val;
return INT2FIX ((int)val);
}
case CORBA::tk_long:
{
CORBA::Long val;
_any >>= val;
return LONG2NUM (val);
}
case CORBA::tk_ushort:
{
CORBA::UShort val;
_any >>= val;
return UINT2NUM ((unsigned int)val);
}
case CORBA::tk_ulong:
{
CORBA::ULong val;
_any >>= val;
return ULONG2NUM (val);
}
case CORBA::tk_longlong:
{
CORBA::LongLong val;
_any >>= val;
return LL2NUM (val);
}
case CORBA::tk_ulonglong:
{
CORBA::ULongLong val;
_any >>= val;
return ULL2NUM (val);
}
case CORBA::tk_float:
{
CORBA::Float val;
_any >>= val;
return rb_float_new ((double)val);
}
case CORBA::tk_double:
{
CORBA::Double val;
_any >>= val;
return rb_float_new ((double)val);
}
case CORBA::tk_longdouble:
{
CORBA::LongDouble val;
_any >>= val;
return CLD2RLD (val);
}
case CORBA::tk_boolean:
{
CORBA::Boolean val;
_any >>= CORBA::Any::to_boolean (val);
return (val ? Qtrue : Qfalse);
}
case CORBA::tk_char:
{
CORBA::Char val;
_any >>= CORBA::Any::to_char (val);
return rb_str_new (&val, 1);
}
case CORBA::tk_octet:
{
CORBA::Octet val;
_any >>= CORBA::Any::to_octet (val);
return INT2FIX ((int)val);
}
case CORBA::tk_wchar:
{
CORBA::WChar val;
_any >>= CORBA::Any::to_wchar (val);
return INT2FIX ((int)val);
}
case CORBA::tk_string:
{
if (_tc->length ()>0)
{
char *tmp;
_any >>= CORBA::Any::to_string (tmp, _tc->length ());
return rb_str_new (tmp, (long)_tc->length ());
}
else
{
const char *tmp;
_any >>= tmp;
return tmp ? rb_str_new2 (tmp) : Qnil;
}
}
case CORBA::tk_wstring:
{
VALUE rtcklass = R2TAO_TCTYPE(roottc);
if (_tc->length ()>0)
{
CORBA::WChar *tmp;
_any >>= CORBA::Any::to_wstring (tmp, _tc->length ());
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)_tc->length ()) :
rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; l<_tc->length () ;++l)
rb_ary_push (ret, INT2FIX (tmp[l]));
return ret;
}
else
{
const CORBA::WChar *tmp;
_any >>= tmp;
if (tmp == 0)
return Qnil;
VALUE ret = rb_class_new_instance (0, 0, rtcklass);
for (CORBA::ULong l=0; tmp[l] != CORBA::WChar(0) ;++l)
rb_ary_push (ret, INT2FIX (tmp[l]));
return ret;
}
}
case CORBA::tk_enum:
{
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny (_orb, _any);
DynamicAny::DynEnum_var das = DynamicAny::DynEnum::_narrow (da.in ());
VALUE ret = ULL2NUM (das->get_as_ulong ());
das->destroy ();
return ret;
}
case CORBA::tk_array:
{
DynamicAny::DynAny_var da = r2tao_Typecode_CreateDynAny (_orb, _any);
DynamicAny::DynArray_var das = DynamicAny::DynArray::_narrow (da.in ());
DynamicAny::AnySeq_var elems = das->get_elements ();
CORBA::ULong arrlen = elems->length ();
VALUE rtcklass = R2TAO_TCTYPE(roottc);
VALUE ret = (rtcklass == rb_cArray) ?
rb_ary_new2 ((long)arrlen) :
rb_class_new_instance (0, 0, rtcklass);
CORBA::TypeCode_var etc = _tc->content_type ();
VALUE ertc = rb_iv_get (rtc, "@content_tc");
for (CORBA::ULong l=0; l<arrlen ;++l)
{
VALUE rval = r2tao_Typecode_Any2Ruby (elems[l], etc.in (), ertc, ertc, _orb);
rb_ary_push (ret, rval);
}
das->destroy ();
return ret;
}
case CORBA::tk_sequence:
{
return r2tao_Typecode_Sequence2Ruby (_any, _tc, rtc, roottc, _orb);
}
case CORBA::tk_except:
case CORBA::tk_struct:
{
return r2tao_Typecode_Struct2Ruby (_any, _tc, rtc, roottc, _orb);
}
case CORBA::tk_union:
{
return r2tao_Typecode_Union2Ruby (_any, _tc, rtc, roottc, _orb);
}
case CORBA::tk_objref:
{
CORBA::Object_var val;
_any >>= CORBA::Any::to_object (val.out ());
if (CORBA::is_nil (val))
return Qnil;
VALUE robj = r2tao_Object_t2r(val.in ());
VALUE obj_type = rb_funcall (rtc, rb_intern ("get_type"), 0);
VALUE ret = rb_funcall (obj_type, rb_intern ("_narrow"), 1, robj);
return ret;
}
case CORBA::tk_any:
{
const CORBA::Any *_anyval;
_any >>= _anyval;
CORBA::TypeCode_var atc = _anyval->type ();
rtc = r2tao_Typecode_t2r(atc.in (), _orb);
return r2tao_Typecode_Any2Ruby (*_anyval, atc.in (), rtc, rtc, _orb);
}
case CORBA::tk_TypeCode:
{
CORBA::TypeCode_ptr _tcval;
_any >>= _tcval;
return r2tao_Typecode_t2r(_tcval, _orb);
}
case CORBA::tk_Principal:
{
break;
}
default:
break;
}
ACE_ERROR ((LM_ERROR, "R2TAO::Cannot convert TAO data to Ruby\n"));
throw ::CORBA::NO_IMPLEMENT (0, CORBA::COMPLETED_NO);
return Qnil;
}
| 29.858998 | 137 | 0.582515 | [
"object"
] |
5159c936aa68b2b70ccd9d0ad1823dbcf6d0f0ea | 3,048 | cpp | C++ | AllChapters/Code/Chapter09Sample01.cpp | percentcer/Hands-On-Game-Animation-Programming | 52f9bdb9db964192bfdddc512c6a40055830f17a | [
"MIT"
] | 103 | 2020-05-22T09:17:54.000Z | 2022-03-29T07:31:05.000Z | AllChapters/Code/Chapter09Sample01.cpp | PacktPublishing/Game-Animation-Programming | 62c589661c51aaa83c4d060b0475b26b31e53a1d | [
"MIT"
] | 2 | 2020-10-14T20:09:58.000Z | 2021-02-07T05:15:41.000Z | AllChapters/Code/Chapter09Sample01.cpp | PacktPublishing/Game-Animation-Programming | 62c589661c51aaa83c4d060b0475b26b31e53a1d | [
"MIT"
] | 32 | 2020-06-15T20:15:28.000Z | 2022-03-27T07:22:09.000Z | #define _CRT_SECURE_NO_WARNINGS
#include "Chapter09Sample01.h"
#include "GLTFLoader.h"
void Chapter09Sample01::Initialize() {
cgltf_data* gltf = LoadGLTFFile("Assets/Woman.gltf");
mRestPose = LoadRestPose(gltf);
mClips = LoadAnimationClips(gltf);
FreeGLTFFile(gltf);
mRestPoseVisual = new DebugDraw();
mRestPoseVisual->FromPose(mRestPose);
mRestPoseVisual->UpdateOpenGLBuffers();
mCurrentClip = 0;
mCurrentPose = mRestPose;
mCurrentPoseVisual = new DebugDraw();
mCurrentPoseVisual->FromPose(mCurrentPose);
mCurrentPoseVisual->UpdateOpenGLBuffers();
// For the UI
mNumUIClips = (unsigned int)mClips.size();
mUIClipNames = new char* [mNumUIClips];
for (unsigned int i = 0; i < mNumUIClips; ++i) {
std::string& clipName = mClips[i].GetName();
unsigned int nameLength = (unsigned int)clipName.length();
mUIClipNames[i] = new char[nameLength + 1];
memset(mUIClipNames[i], 0, nameLength + 1);
strcpy(mUIClipNames[i], clipName.c_str());
}
mShowRestPose = true;
mShowCurrentPose = true;
}
void Chapter09Sample01::Update(float deltaTime) {
mPlaybackTime = mClips[mCurrentClip].Sample(mCurrentPose, mPlaybackTime + deltaTime);
mCurrentPoseVisual->FromPose(mCurrentPose);
}
void Chapter09Sample01::Render(float inAspectRatio) {
mat4 projection = perspective(60.0f, inAspectRatio, 0.01f, 1000.0f);
mat4 view = lookAt(vec3(0, 4, -7), vec3(0, 4, 0), vec3(0, 1, 0));
mat4 mvp = projection * view; // No model
if (mShowRestPose) {
mRestPoseVisual->Draw(DebugDrawMode::Lines, vec3(1, 0, 0), mvp);
}
if (mShowCurrentPose) {
mCurrentPoseVisual->UpdateOpenGLBuffers();
mCurrentPoseVisual->Draw(DebugDrawMode::Lines, vec3(0, 0, 1), mvp);
}
}
void Chapter09Sample01::Shutdown() {
delete mRestPoseVisual;
delete mCurrentPoseVisual;
mClips.clear();
for (unsigned int i = 0; i < mNumUIClips; ++i) {
delete[] mUIClipNames[i];
}
delete[] mUIClipNames;
mNumUIClips = 0;
}
void Chapter09Sample01::ImGui(nk_context* ctx) {
nk_begin(ctx, "Chapter 9, Sample 1", nk_rect(5.0f, 5.0f, 300.0f, 115.0f), NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR);
static const float layout[] = { 75, 200 };
nk_layout_row(ctx, NK_STATIC, 25, 2, layout);
nk_label(ctx, "Animation:", NK_TEXT_LEFT);
int selected = nk_combo(ctx, (const char**)mUIClipNames, mNumUIClips, (int)mCurrentClip, 25, nk_vec2(200, 200));
if ((unsigned int)selected != mCurrentClip) {
mCurrentPose = mRestPose;
mCurrentClip = (unsigned int)selected;
}
nk_label(ctx, "Playback:", NK_TEXT_LEFT);
float startTime = mClips[mCurrentClip].GetStartTime();
float duration = mClips[mCurrentClip].GetDuration();
float progress = (mPlaybackTime - startTime) / duration;
size_t prog = (size_t)(progress * 200.0f);
nk_progress(ctx, &prog, 200, NK_FIXED);
nk_layout_row_dynamic(ctx, 20, 1);
int show = (int)mShowRestPose;
if (nk_checkbox_label(ctx, "Show Rest Pose", &show)) {
mShowRestPose = (bool)show;
}
show = (int)mShowCurrentPose;
if (nk_checkbox_label(ctx, "Show Current Pose", &show)) {
mShowCurrentPose = (bool)show;
}
nk_end(ctx);
}
| 29.592233 | 118 | 0.723097 | [
"render",
"model"
] |
515cb95b5e2b494f3268da596ef16c03d1a34056 | 8,765 | cpp | C++ | Units/ScreenMultideck/ScreenMultideck.cpp | FlowsheetSimulation/Dyssol-open | 557d57d959800868e1b3fd161b26cad16481382b | [
"BSD-3-Clause"
] | 7 | 2020-12-02T02:54:31.000Z | 2022-03-08T20:37:46.000Z | Units/ScreenMultideck/ScreenMultideck.cpp | FlowsheetSimulation/Dyssol-open | 557d57d959800868e1b3fd161b26cad16481382b | [
"BSD-3-Clause"
] | 33 | 2021-03-26T12:20:18.000Z | 2022-02-23T11:37:56.000Z | Units/ScreenMultideck/ScreenMultideck.cpp | FlowsheetSimulation/Dyssol-open | 557d57d959800868e1b3fd161b26cad16481382b | [
"BSD-3-Clause"
] | 6 | 2020-07-17T08:17:37.000Z | 2022-02-24T13:45:16.000Z | /* Copyright (c) 2021, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */
#define DLL_EXPORT
#include "ScreenMultideck.h"
extern "C" DECLDIR CBaseUnit* DYSSOL_CREATE_MODEL_FUN()
{
return new CScreenMultideck();
}
void CScreenMultideck::CreateBasicInfo()
{
SetUnitName("Screen Multi-deck");
SetAuthorName("SPE TUHH, TU Bergakademie Freiberg IART");
SetUniqueID("AAAFADC1877B46629B07A456C7FA22A1");
}
void CScreenMultideck::CreateStructure()
{
constexpr size_t decksNumber = 5;
m_decks.resize(decksNumber);
/// Ports
m_portIn = AddPort("Input", EUnitPort::INPUT);
m_portsCoarse.clear();
for (size_t i = 0; i < decksNumber; ++i)
m_portsCoarse.push_back(AddPort("Coarse " + std::to_string(i + 1), EUnitPort::OUTPUT));
m_portFines = AddPort("Fines", EUnitPort::OUTPUT);
/// Unit parameters
for (size_t i = 0; i < m_decks.size(); ++i)
{
// deck index as string
const auto I = " " + std::to_string(i + 1);
// add unit parameters
m_decks[i].model = AddComboParameter("Model" + I, None, { None, Plitt, Molerus, Teipel, Probability }, { "-", "Plitt", "Molerus & Hoffmann", "Teipel & Hennig", "Probability" }, "Classification model");
m_decks[i].xCut = AddTDParameter("Cut size" + I, 0.002 , "m", "Cut size of the classification model, deck" + I, 0 );
m_decks[i].alpha = AddTDParameter("Alpha" + I, 8 , "-", "Sharpness of separation, deck" + I, 0, 100);
m_decks[i].beta = AddTDParameter("Beta" + I, 0.5 , "-", "Sharpness of separation 2, deck" + I, 0, 100);
m_decks[i].offset = AddTDParameter("Offset" + I, 0.2 , "-", "Separation offset, deck" + I, 0, 1 );
m_decks[i].mean = AddTDParameter("Mean" + I, 0.001 , "m", "Mean value of the normal output distribution, deck" + I, 0 );
m_decks[i].deviation = AddTDParameter("Deviation" + I, 0.0001, "m", "Standard deviation of the normal output distribution, deck" + I, 0 );
// group unit parameters
AddParametersToGroup("Model" + I, "Plitt" , { "Cut size" + I, "Alpha" + I });
AddParametersToGroup("Model" + I, "Molerus & Hoffmann", { "Cut size" + I, "Alpha" + I });
AddParametersToGroup("Model" + I, "Teipel & Hennig" , { "Cut size" + I, "Alpha" + I, "Beta" + I, "Offset" + I });
AddParametersToGroup("Model" + I, "Probability" , { "Mean" + I, "Deviation" + I });
}
/// Internal streams
for (size_t i = 0; i < decksNumber - 1; ++i)
{
// create internal fines stream for each deck except the last one.
m_decks[i].streamOutF = AddStream("Deck " + std::to_string(i + 1) + " fine");
}
}
void CScreenMultideck::Initialize(double _time)
{
/// Check flowsheet parameters
if (!IsPhaseDefined(EPhase::SOLID)) RaiseError("Solid phase has not been defined.");
if (!IsDistributionDefined(DISTR_SIZE)) RaiseError("Size distribution has not been defined.");
/// Get and set pointers to streams
for (size_t i = 0; i < m_decks.size(); ++i)
{
m_decks[i].streamIn = i != 0 ? m_decks[i - 1].streamOutF : m_portIn->GetStream();
m_decks[i].streamOutC = m_portsCoarse[i]->GetStream();
}
m_decks.back().streamOutF = m_portFines->GetStream();
/// Get PSD grid parameters
m_classesNum = GetClassesNumber(DISTR_SIZE);
m_grid = GetNumericGrid(DISTR_SIZE);
m_diameters = GetClassesMeans(DISTR_SIZE); // Classes means of PSD
/// Create and initialize transformation matrices
m_transformC.Clear();
m_transformF.Clear();
m_transformC.SetDimensions(DISTR_SIZE, static_cast<unsigned>(m_classesNum));
m_transformF.SetDimensions(DISTR_SIZE, static_cast<unsigned>(m_classesNum));
}
void CScreenMultideck::Simulate(double _time)
{
for (const auto& deck : m_decks)
{
deck.streamOutC->CopyFromStream(_time, deck.streamIn);
deck.streamOutF->CopyFromStream(_time, deck.streamIn);
// if deck is disabled - just propagate stream
if (static_cast<EModel>(deck.model->GetValue()) == None)
{
deck.streamOutC->SetMassFlow(_time, 0.0);
continue;
}
const double massFactor = CreateTransformMatrix(_time, deck);
if (massFactor == -1.0) return; // cannot calculate transformation matrix
// apply transformation matrices
deck.streamOutC->ApplyTM(_time, m_transformC);
deck.streamOutF->ApplyTM(_time, m_transformF);
// recalculate and apply mass flows
const double massFlowIn = deck.streamIn->GetMassFlow(_time);
deck.streamOutC->SetMassFlow(_time, massFlowIn * massFactor);
deck.streamOutF->SetMassFlow(_time, massFlowIn * (1 - massFactor));
}
}
double CScreenMultideck::CreateTransformMatrix(double _time, const SDeck& _deck)
{
for (const auto& deck : m_decks)
switch(static_cast<EModel>(deck.model->GetValue()))
{
case Plitt: return CreateTransformMatrixPlitt(_time, _deck);
case Molerus: return CreateTransformMatrixMolerus(_time, _deck);
case Teipel: return CreateTransformMatrixTeipel(_time, _deck);
case Probability: return CreateTransformMatrixProbability(_time, _deck);
case None: break;
}
return -1;
}
double CScreenMultideck::CreateTransformMatrixPlitt(double _time, const SDeck& _deck)
{
// get parameters
const double xcut = _deck.xCut->GetValue(_time);
const double alpha = _deck.alpha->GetValue(_time);
// check parameters
if (xcut == 0.0) RaiseError("Parameter '" + _deck.xCut->GetName() + "' may not be equal to 0");
// return if any error occurred
if (HasError()) return -1;
// calculate transformations matrices
double factor = 0;
const std::vector<double> psd = _deck.streamIn->GetDistribution(_time, DISTR_SIZE);
for (unsigned i = 0; i < psd.size(); ++i)
{
const double value = 1 - std::exp(-0.693 * std::pow(m_diameters[i] / xcut, alpha));
factor += value * psd[i];
m_transformC.SetValue(i, i, value);
m_transformF.SetValue(i, i, 1 - value);
}
return factor;
}
double CScreenMultideck::CreateTransformMatrixMolerus(double _time, const SDeck& _deck)
{
// get parameters
const double xcut = _deck.xCut->GetValue(_time);
const double alpha = _deck.alpha->GetValue(_time);
// Check parameters
if (xcut == 0.0) RaiseError("Parameter '" + _deck.xCut->GetName() + "' may not be equal to 0");
// return if any error occurred
if (HasError()) return -1;
// calculate transformations matrices
double factor = 0;
const std::vector<double> psd = _deck.streamIn->GetDistribution(_time, DISTR_SIZE);
for (unsigned i = 0; i < psd.size(); ++i)
{
const double value = 1 / (1 + std::pow(xcut / m_diameters[i], 2.) * std::exp(alpha * (1 - std::pow(m_diameters[i] / xcut, 2.0))));
factor += value * psd[i];
m_transformC.SetValue(i, i, value);
m_transformF.SetValue(i, i, 1 - value);
}
return factor;
}
double CScreenMultideck::CreateTransformMatrixTeipel(double _time, const SDeck& _deck)
{
// get parameters
const double xcut = _deck.xCut->GetValue(_time);
const double alpha = _deck.alpha->GetValue(_time);
const double beta = _deck.beta->GetValue(_time);
const double offset = _deck.offset->GetValue(_time);
// check parameters
if (xcut == 0.0) RaiseError("Parameter '" + _deck.xCut->GetName() + "' may not be equal to 0");
// return if any error occurred
if (HasError()) return -1;
// calculate transformations matrices
double factor = 0;
const std::vector<double> psd = _deck.streamIn->GetDistribution(_time, DISTR_SIZE);
for (unsigned i = 0; i < psd.size(); ++i)
{
const double value = (1 - std::pow(1 + 3 * std::pow(m_diameters[i] / xcut, (m_diameters[i] / xcut + alpha) * beta), -0.5)) * (1 - offset) + offset;
factor += value * psd[i];
m_transformC.SetValue(i, i, value);
m_transformF.SetValue(i, i, 1 - value);
}
return factor;
}
double CScreenMultideck::CreateTransformMatrixProbability(double _time, const SDeck& _deck)
{
// get parameters
const double mu = _deck.mean->GetValue(_time);
const double sigma = _deck.deviation->GetValue(_time);
// check parameters
if (sigma == 0.0) RaiseError("Parameter '" + _deck.deviation->GetName() + "' may not be equal to 0");
// return if any error occurred.
if (HasError()) return -1;
// calculate transformations matrices
double factor = 0;
const std::vector<double> psd = _deck.streamIn->GetDistribution(_time, DISTR_SIZE);
double totalSum = 0;
for (unsigned i = 0; i < psd.size(); ++i)
totalSum += std::exp(-std::pow(m_diameters[i] - mu, 2) / (2 * sigma * sigma));
double currSum = 0;
for (unsigned i = 0; i < psd.size(); ++i)
{
currSum += std::exp(-std::pow(m_diameters[i] - mu, 2) / (2 * sigma * sigma));
const double value = currSum / totalSum;
factor += value * psd[i];
m_transformC.SetValue(i, i, value);
m_transformF.SetValue(i, i, 1 - value);
}
return factor;
}
| 37.139831 | 207 | 0.674615 | [
"vector",
"model",
"solid"
] |
51608af11709c0c68b7f8602e18e9948cf87d64e | 3,905 | cpp | C++ | common/src/utilities.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | 3 | 2021-07-01T14:31:06.000Z | 2022-03-29T20:41:21.000Z | common/src/utilities.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | null | null | null | common/src/utilities.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | null | null | null | #include "utilities.h"
#include "direction.h"
#include <array>
namespace utils {
bool isInteger(std::string_view str) {
auto it = str.begin();
if ((*it) == '-') {
it++;
}
return std::all_of(it, str.end(), [](char l) {
return (l >= '0' && l <= '9');
});
}
/*
* returns the number found in str starting at the position pos
*/
int getNumber(std::string_view str, int& pos) {
int nr = 0;
bool isNegative = false;
if (str[pos] == '-') {
isNegative = true;
pos++;
}
while (pos < str.size() && str[pos] >= '0' && str[pos] <= '9') {
nr = nr * 10 + str[pos] - '0';
pos++;
}
return isNegative * (-1) * nr + !isNegative * nr;
}
std::vector<std::string> splitString(std::string_view str, std::string_view delimeters) {
std::vector<std::string> output;
std::size_t prev = 0, pos;
while ((pos = str.find_first_of(delimeters, prev)) != std::string::npos)
{
if (pos > prev)
output.emplace_back(str.substr(prev, pos - prev));
prev = pos + 1;
}
if (prev < str.length())
output.emplace_back(str.substr(prev, std::string::npos));
return output;
}
std::vector<int> splitStringToInt(std::string_view str, std::string_view delimeters) {
std::vector<std::string> output = splitString(str, delimeters);
std::vector<int> nr(output.size(), 0);
for (int i = 0; i < output.size(); ++i) {
nr[i] = std::stoi(output[i]);
}
return nr;
}
/*
* return the decimal value of binary string str with 1 being represented by the character
* typically call this with '1' as default but sometimes the value might be represented by another character
*/
unsigned long long decimalToInt(std::string_view str, char character) {
unsigned long long nr = 0;
for (const auto& c : str) {
nr *= 2;
if (c == character) {
nr++;
}
}
return nr;
}
int decimalToInt(const std::vector<bool>&str, bool defaultValue) {
int nr = 0;
for (const auto& c : str) {
nr *= 2;
if (c == defaultValue) {
nr++;
}
}
return nr;
}
int manhattanDistance(int x1, int y1, int x2, int y2) {
return std::abs(x1 - x2) + std::abs(y1 - y2);
}
bool isAnagram(std::string_view s1, std::string_view s2) {
if (s1.size() != s2.size()) return false;
std::array<int, 26> letters;
letters.fill(0);
for (const auto& l : s1) {
letters[l - 'a']++;
}
for (const auto& l : s2) {
letters[l - 'a']--;
}
for (const auto& e : letters) {
if (e != 0) return false;
}
return true;
}
std::vector<point> getListOfNeighbours4Directions(int x, int y, const std::vector<std::vector<int>>& map) {
direction::Direction dir;
std::vector<point> neighbours;
for (const auto& d : dir.directions) {
if (x + d.x >= 0 && x + d.x < map.size() && y + d.y >= 0 && y + d.y < map[0].size()) {
neighbours.push_back({x + d.x, y + d.y});
}
}
return neighbours;
}
std::vector<point> getListOfNeighboursAllDirections(int x, int y, const std::vector<std::vector<int>>& map) {
direction::Direction dir;
std::vector<point> neighbours;
for (const auto& d : dir.fullDirections) {
if (x + d.x >= 0 && x + d.x < map.size() && y + d.y >= 0 && y + d.y < map[0].size()) {
neighbours.push_back({x + d.x, y + d.y});
}
}
return neighbours;
}
} | 31.24 | 113 | 0.493982 | [
"vector"
] |
5165260e4d3132241dc841ed58928d53120e4cdf | 1,238 | cpp | C++ | code-forces/615 Div 3/B.cpp | ErickJoestar/competitive-programming | 76afb766dbc18e16315559c863fbff19a955a569 | [
"MIT"
] | 1 | 2020-04-23T00:35:38.000Z | 2020-04-23T00:35:38.000Z | code-forces/615 Div 3/B.cpp | ErickJoestar/competitive-programming | 76afb766dbc18e16315559c863fbff19a955a569 | [
"MIT"
] | null | null | null | code-forces/615 Div 3/B.cpp | ErickJoestar/competitive-programming | 76afb766dbc18e16315559c863fbff19a955a569 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
#define ENDL '\n'
#define deb(u) cout << #u " : " << (u) << ENDL;
#define deba(alias, u) cout << alias << ": " << (u) << ENDL;
#define debp(u, v) cout << u << " : " << v << ENDL;
#define pb push_back
#define F first
#define S second
#define lli long long
#define pii pair<int, int>
#define pll pair<lli, lli>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define FORN(i, a, n) for (int i = (a - 1); i >= n; --i)
#define IO \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
using namespace std;
int main()
{
IO;
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<pii> box(n);
FOR(i, 0, n)
{
cin >> box[i].F >> box[i].S;
}
sort(ALL(box));
string s = "";
bool ok = true;
int x = 0, y = 0;
for (auto b : box)
{
if (b.S < y)
{
ok = false;
break;
}
FOR(i, x, b.F)
s += 'R';
FOR(i, y, b.S)
s += 'U';
x = b.F;
y = b.S;
}
if (ok)
{
cout << "YES" << ENDL;
cout << s << ENDL;
}
else
{
cout << "NO" << ENDL;
}
}
return 0;
} | 19.046154 | 60 | 0.424879 | [
"vector"
] |
516ecd7faa604cb9d8f6a5a93e38a7c6cfa7b64f | 1,349 | cpp | C++ | Game/src/PostProcessors/SSReflectionProcessor.cpp | strager/PhotonBox | aba8ad303012dd1ca75b7c00ab6b8d5fff2e4128 | [
"MIT"
] | null | null | null | Game/src/PostProcessors/SSReflectionProcessor.cpp | strager/PhotonBox | aba8ad303012dd1ca75b7c00ab6b8d5fff2e4128 | [
"MIT"
] | null | null | null | Game/src/PostProcessors/SSReflectionProcessor.cpp | strager/PhotonBox | aba8ad303012dd1ca75b7c00ab6b8d5fff2e4128 | [
"MIT"
] | null | null | null | #ifndef SSREFLECTION_PROCESSOR_CPP
#define SSREFLECTION_PROCESSOR_CPP
#include <core/system/Renderer.h>
#include <resource/PostProcessor.h>
#include <resource/Material.h>
#include "../Shader/SSReflectionShader.cpp"
#ifdef PB_MEM_DEBUG
#include "PhotonBox/util/MEMDebug.h"
#define new DEBUG_NEW
#endif
class SSReflectionProcessor : public PostProcessor
{
public:
SSReflectionProcessor(int index) : PostProcessor(index)
{
_ssreflection = new Material(SSReflectionShader::getInstance());
_ssreflection->setTexture("mainBuffer", mainBuffer, "color");
_ssreflection->setTexture("gPosition", Renderer::getGBuffer(), "gPosition");
_ssreflection->setTexture("gNormal", Renderer::getGBuffer(), "gNormal");
_ssreflection->setTexture("gMetallic", Renderer::getGBuffer(), "gMetallic");
_ssreflection->setTexture("gRoughness", Renderer::getGBuffer(), "gRoughness");
}
void render(FrameBuffer* nextBuffer) override
{
nextBuffer->enable();
mainBuffer->render("color");
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(GL_FALSE);
glDepthFunc(GL_EQUAL);
mainBuffer->render(_ssreflection);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LESS);
glDisable(GL_BLEND);
}
void destroy() override
{
delete _ssreflection;
}
private:
Material * _ssreflection;
};
#endif // SSREFLECTION_PROCESSOR_CPP | 26.45098 | 80 | 0.765752 | [
"render"
] |
5170c9c257b9c31bc5c189f4d53906b2cb29aef2 | 1,592 | cpp | C++ | ProducerConsumer/interface/bindproducer.cpp | cosunae/cloudruption | abfaf51aa7f7adad35c63564d3e468049759f8d3 | [
"MIT"
] | null | null | null | ProducerConsumer/interface/bindproducer.cpp | cosunae/cloudruption | abfaf51aa7f7adad35c63564d3e468049759f8d3 | [
"MIT"
] | null | null | null | ProducerConsumer/interface/bindproducer.cpp | cosunae/cloudruption | abfaf51aa7f7adad35c63564d3e468049759f8d3 | [
"MIT"
] | null | null | null | #include <algorithm>
#include "../KafkaProducer.h"
#ifdef AWSSDK
#include <aws/core/Aws.h>
#include <aws/monitoring/CloudWatchClient.h>
#include <aws/monitoring/model/PutMetricDataRequest.h>
#endif
extern "C"
{
KafkaProducer *create_producer(const char *broker, const char *product)
{
KafkaProducer *producer = new KafkaProducer(broker, product);
return producer;
}
void produce(KafkaProducer *producer, KeyMessage &key, float *data, size_t datasize,
const char *topic)
{
producer->produce(key, data, datasize, topic);
}
#ifdef AWSSDK
void aws_put_metric(const char *ns, const char *metricname, long long value)
{
Aws::SDKOptions options;
Aws::InitAPI(options);
{
Aws::CloudWatch::CloudWatchClient cw;
Aws::CloudWatch::Model::MetricDatum datum;
datum.SetMetricName(metricname);
datum.SetUnit(Aws::CloudWatch::Model::StandardUnit::Seconds);
datum.SetValue(value);
Aws::CloudWatch::Model::PutMetricDataRequest request;
request.SetNamespace(ns);
request.AddMetricData(datum);
auto outcome = cw.PutMetricData(request);
if (!outcome.IsSuccess())
{
std::cout << "Failed to put sample metric data:" << outcome.GetError().GetMessage() << std::endl;
}
else
{
std::cout << "Successfully put sample metric data" << std::endl;
}
}
Aws::ShutdownAPI(options);
}
#endif
}
| 29.481481 | 113 | 0.598618 | [
"model"
] |
51762c0271164c1de70dfa653fb8ec5f91198fa4 | 15,532 | cpp | C++ | tests/test_objectpacker.cpp | GamePad64/cborpp | b0b5ebe83b7065d7f398757c7f2c19d6bd4510aa | [
"MIT"
] | 1 | 2017-01-28T10:07:24.000Z | 2017-01-28T10:07:24.000Z | tests/test_objectpacker.cpp | GamePad64/unicbor | b0b5ebe83b7065d7f398757c7f2c19d6bd4510aa | [
"MIT"
] | null | null | null | tests/test_objectpacker.cpp | GamePad64/unicbor | b0b5ebe83b7065d7f398757c7f2c19d6bd4510aa | [
"MIT"
] | null | null | null | /* Copyright (C) 2015 Alexander Shishenko <alex@shishenko.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <unicbor/object.h>
#include <unicbor/packer.h>
#include <gtest/gtest.h>
#include "testdata.h"
class TestObjectPacker : public ::testing::Test {
protected:
void SetUp(){
object_ = new unicbor::object();
packer_ = new unicbor::packer(os_);
}
void TearDown(){
delete object_;
delete packer_;
}
std::ostringstream os_;
unicbor::object* object_;
unicbor::packer* packer_;
};
TEST_F(TestObjectPacker, int1){
object_->set(0);
packer_->pack(*object_);
ASSERT_EQ(int1, os_.str());
}
TEST_F(TestObjectPacker, int2){
object_->set(1);
packer_->pack(*object_);
ASSERT_EQ(int2, os_.str());
}
TEST_F(TestObjectPacker, int3){
object_->set(10);
packer_->pack(*object_);
ASSERT_EQ(int3, os_.str());
}
TEST_F(TestObjectPacker, int4){
object_->set(23);
packer_->pack(*object_);
ASSERT_EQ(int4, os_.str());
}
TEST_F(TestObjectPacker, int5){
object_->set(24);
packer_->pack(*object_);
ASSERT_EQ(int5, os_.str());
}
TEST_F(TestObjectPacker, int6){
object_->set(25);
packer_->pack(*object_);
ASSERT_EQ(int6, os_.str());
}
TEST_F(TestObjectPacker, int7){
object_->set(100);
packer_->pack(*object_);
ASSERT_EQ(int7, os_.str());
}
TEST_F(TestObjectPacker, int8){
object_->set(1000);
packer_->pack(*object_);
ASSERT_EQ(int8, os_.str());
}
TEST_F(TestObjectPacker, int9){
object_->set(1000000ul);
packer_->pack(*object_);
ASSERT_EQ(int9, os_.str());
}
TEST_F(TestObjectPacker, int10){
object_->set(1000000000000ull);
packer_->pack(*object_);
ASSERT_EQ(int10, os_.str());
}
TEST_F(TestObjectPacker, int11){
object_->set(18446744073709551615ull);
packer_->pack(*object_);
ASSERT_EQ(int11, os_.str());
}
TEST_F(TestObjectPacker, bigint1){
object_->add_tag(unicbor::tag::BIGNUM_POSITIVE);
object_->set_bin("\x01\0\0\0\0\0\0\0\0", 9);
packer_->pack(*object_);
ASSERT_EQ(bigint1, os_.str());
}
TEST_F(TestObjectPacker, neg_bigint1){
object_
->set_neg_int(18446744073709551615ull); // C and C++ don't have a type to hold -18446744073709551615, but this is not considered bigint in CBOR, so...
packer_->pack(*object_);
ASSERT_EQ(neg_bigint1, os_.str());
}
TEST_F(TestObjectPacker, neg_bigint2){
object_->add_tag(unicbor::tag::BIGNUM_NEGATIVE);
object_->set_bin("\x01\0\0\0\0\0\0\0\0", 9);
packer_->pack(*object_);
ASSERT_EQ(neg_bigint2, os_.str());
}
TEST_F(TestObjectPacker, neg_int1){
object_->set(-1);
packer_->pack(*object_);
ASSERT_EQ(neg_int1, os_.str());
}
TEST_F(TestObjectPacker, neg_int2){
object_->set(-10);
packer_->pack(*object_);
ASSERT_EQ(neg_int2, os_.str());
}
TEST_F(TestObjectPacker, neg_int3){
object_->set(-100);
packer_->pack(*object_);
ASSERT_EQ(neg_int3, os_.str());
}
TEST_F(TestObjectPacker, neg_int4){
object_->set(-1000);
packer_->pack(*object_);
ASSERT_EQ(neg_int4, os_.str());
}
TEST_F(TestObjectPacker, float1){
object_->set(0.0);
packer_->pack(*object_);
ASSERT_EQ(float1, os_.str());
}
TEST_F(TestObjectPacker, float2){
object_->set(-0.0);
packer_->pack(*object_);
ASSERT_EQ(float2, os_.str());
}
TEST_F(TestObjectPacker, float3){
object_->set(1.0);
packer_->pack(*object_);
ASSERT_EQ(float3, os_.str());
}
TEST_F(TestObjectPacker, float4){
object_->set(1.1);
packer_->pack(*object_);
ASSERT_EQ(float4, os_.str());
}
TEST_F(TestObjectPacker, float5){
object_->set(1.5);
packer_->pack(*object_);
ASSERT_EQ(float5, os_.str());
}
TEST_F(TestObjectPacker, float6){
object_->set(65504.0);
packer_->pack(*object_);
ASSERT_EQ(float6, os_.str());
}
TEST_F(TestObjectPacker, float7){
object_->set(100000.0);
packer_->pack(*object_);
ASSERT_EQ(float7, os_.str());
}
TEST_F(TestObjectPacker, float8){
object_->set(3.4028234663852886e+38);
packer_->pack(*object_);
ASSERT_EQ(float8, os_.str());
}
TEST_F(TestObjectPacker, float9){
object_->set(1.0e+300);
packer_->pack(*object_);
ASSERT_EQ(float9, os_.str());
}
TEST_F(TestObjectPacker, float10){
object_->set(5.960464477539063e-8);
packer_->pack(*object_);
ASSERT_EQ(float10, os_.str());
}
TEST_F(TestObjectPacker, float11){
object_->set(0.00006103515625);
packer_->pack(*object_);
ASSERT_EQ(float11, os_.str());
}
TEST_F(TestObjectPacker, float12){
object_->set(-4.0);
packer_->pack(*object_);
ASSERT_EQ(float12, os_.str());
}
TEST_F(TestObjectPacker, float13){
object_->set(-4.1);
packer_->pack(*object_);
ASSERT_EQ(float13, os_.str());
}
TEST_F(TestObjectPacker, half_limits1){
object_->set(unicbor::half(INFINITY));
packer_->pack(*object_);
ASSERT_EQ(half_limits1, os_.str());
}
TEST_F(TestObjectPacker, half_limits2){
object_->set(unicbor::half(NAN));
packer_->pack(*object_);
ASSERT_EQ(half_limits2, os_.str());
}
TEST_F(TestObjectPacker, half_limits3){
object_->set(unicbor::half(-INFINITY));
packer_->pack(*object_);
ASSERT_EQ(half_limits3, os_.str());
}
// Disabled all other *_limits* tests, because our object implementaation uses canonical representation of numbers.
TEST_F(TestObjectPacker, DISABLED_float_limits1){
object_->set(float(INFINITY));
packer_->pack(*object_);
ASSERT_EQ(float_limits1, os_.str());
}
TEST_F(TestObjectPacker, DISABLED_float_limits2){
object_->set(float(NAN));
packer_->pack(*object_);
ASSERT_EQ(float_limits2, os_.str());
}
TEST_F(TestObjectPacker, DISABLED_float_limits3){
object_->set(float(-INFINITY));
packer_->pack(*object_);
ASSERT_EQ(float_limits3, os_.str());
}
TEST_F(TestObjectPacker, DISABLED_double_limits1){
object_->set(double(INFINITY));
packer_->pack(*object_);
ASSERT_EQ(double_limits1, os_.str());
}
TEST_F(TestObjectPacker, DISABLED_double_limits2){
object_->set(double(NAN));
packer_->pack(*object_);
ASSERT_EQ(double_limits2, os_.str());
}
TEST_F(TestObjectPacker, DISABLED_double_limits3){
object_->set(double(-INFINITY));
packer_->pack(*object_);
ASSERT_EQ(double_limits3, os_.str());
}
TEST_F(TestObjectPacker, simple1){
object_->set(false);
packer_->pack(*object_);
ASSERT_EQ(simple1, os_.str());
}
TEST_F(TestObjectPacker, simple2){
object_->set(true);
packer_->pack(*object_);
ASSERT_EQ(simple2, os_.str());
}
TEST_F(TestObjectPacker, simple3){
object_->set(nullptr);
packer_->pack(*object_);
ASSERT_EQ(simple3, os_.str());
}
TEST_F(TestObjectPacker, simple4){
object_->set(unicbor::undefined);
packer_->pack(*object_);
ASSERT_EQ(simple4, os_.str());
}
TEST_F(TestObjectPacker, simple5){
object_->set(unicbor::simple_value(16));
packer_->pack(*object_);
ASSERT_EQ(simple5, os_.str());
}
TEST_F(TestObjectPacker, simple6){
object_->set(unicbor::simple_value(24));
packer_->pack(*object_);
ASSERT_EQ(simple6, os_.str());
}
TEST_F(TestObjectPacker, simple7){
object_->set(unicbor::simple_value(255));
packer_->pack(*object_);
ASSERT_EQ(simple7, os_.str());
}
TEST_F(TestObjectPacker, tag1){
object_->add_tag(unicbor::tag::DATETIME_STRING);
object_->set("2013-03-21T20:04:00Z");
packer_->pack(*object_);
ASSERT_EQ(tag1, os_.str());
}
TEST_F(TestObjectPacker, tag2){
object_->add_tag(unicbor::tag::DATETIME_NUMERIC);
object_->set(1363896240);
packer_->pack(*object_);
ASSERT_EQ(tag2, os_.str());
}
TEST_F(TestObjectPacker, tag3){
object_->add_tag(unicbor::tag::DATETIME_NUMERIC);
object_->set(1363896240.5);
packer_->pack(*object_);
ASSERT_EQ(tag3, os_.str());
}
TEST_F(TestObjectPacker, tag4){
object_->add_tag(unicbor::tag::EXPECT_HEX);
object_->set_bin("\x01\x02\x03\x04", 4);
packer_->pack(*object_);
ASSERT_EQ(tag4, os_.str());
}
TEST_F(TestObjectPacker, tag5){
object_->add_tag(unicbor::tag::ENCODED_CBOR);
object_->set_bin("\x64\x49\x45\x54\x46", 5);
packer_->pack(*object_);
ASSERT_EQ(tag5, os_.str());
}
TEST_F(TestObjectPacker, tag6){
object_->add_tag(unicbor::tag::URI);
object_->set("http://www.example.com");
packer_->pack(*object_);
ASSERT_EQ(tag6, os_.str());
}
TEST_F(TestObjectPacker, bin_string1){
object_->set_bin("", 0);
packer_->pack(*object_);
ASSERT_EQ(bin_string1, os_.str());
}
TEST_F(TestObjectPacker, bin_string2){
object_->set_bin("\x01\x02\x03\x04", 4);
packer_->pack(*object_);
ASSERT_EQ(bin_string2, os_.str());
}
TEST_F(TestObjectPacker, string1){
object_->set("");
packer_->pack(*object_);
ASSERT_EQ(string1, os_.str());
}
TEST_F(TestObjectPacker, string2){
object_->set("a");
packer_->pack(*object_);
ASSERT_EQ(string2, os_.str());
}
TEST_F(TestObjectPacker, string3){
object_->set("IETF");
packer_->pack(*object_);
ASSERT_EQ(string3, os_.str());
}
TEST_F(TestObjectPacker, string4){
object_->set("\"\\");
packer_->pack(*object_);
ASSERT_EQ(string4, os_.str());
}
TEST_F(TestObjectPacker, string5){
object_->set("\u00fc");
packer_->pack(*object_);
ASSERT_EQ(string5, os_.str());
}
TEST_F(TestObjectPacker, string6){
object_->set("\u6c34");
packer_->pack(*object_);
ASSERT_EQ(string6, os_.str());
}
TEST_F(TestObjectPacker, string7){
object_->set("\xf0\x90\x85\x91");
packer_->pack(*object_);
ASSERT_EQ(string7, os_.str());
}
TEST_F(TestObjectPacker, array1){
object_->set(std::vector<int>()); // Explicitly set_array, because std::vector<uint8_t> is BINARY_STRING type here.
packer_->pack(*object_);
ASSERT_EQ(array1, os_.str());
}
TEST_F(TestObjectPacker, array2){
//object_->set(std::vector<uint8_t>()); // std::vector<uint8_t> is BINARY_STRING type here.
object_->set(std::vector<int>({1, 2, 3}));
packer_->pack(*object_);
ASSERT_EQ(array2, os_.str());
}
TEST_F(TestObjectPacker, array3){
object_->reset(unicbor::object::ARRAY);
object_->add_item(1);
object_->add_item(std::vector<int>({2, 3}));
object_->add_item(std::vector<int>({4, 5}));
packer_->pack(*object_);
ASSERT_EQ(array3, os_.str());
}
TEST_F(TestObjectPacker, array4){
object_->set(std::vector<int>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}));
packer_->pack(*object_);
ASSERT_EQ(array4, os_.str());
}
TEST_F(TestObjectPacker, array4_for){
object_->reset(unicbor::object::ARRAY);
for(int i = 1; i <= 25; i++)
object_->add_item(i);
packer_->pack(*object_);
ASSERT_EQ(array4, os_.str());
}
TEST_F(TestObjectPacker, map1){
object_->set(std::map<int, int>());
packer_->pack(*object_);
ASSERT_EQ(map1, os_.str());
}
TEST_F(TestObjectPacker, map2){
object_->set(std::map<int, int>({{1, 2},
{3, 4}}));
packer_->pack(*object_);
ASSERT_EQ(map2, os_.str());
}
TEST_F(TestObjectPacker, map3){
object_->reset(unicbor::object::MAP);
object_->add_item("a");
object_->add_item(1);
object_->add_item("b");
object_->add_item(std::vector<int8_t>({2, 3}));
packer_->pack(*object_);
ASSERT_EQ(map3, os_.str());
}
/*
TEST_F(TestObjectPacker, map3_stl){
object_->set({{"a", 1}, {"b", std::vector<uint8_t>({2, 3})}});
packer_->pack(*object_);
ASSERT_EQ(map3, os_.str());
}*/
TEST_F(TestObjectPacker, map4){
object_->reset(unicbor::object::ARRAY);
object_->add_item("a");
object_->add_item(std::map<std::string, std::string>({{"b", "c"}}));
packer_->pack(*object_);
ASSERT_EQ(map4, os_.str());
}
TEST_F(TestObjectPacker, map5){
object_->set(std::map<std::string, std::string>({
{"a", "A"},
{"b", "B"},
{"c", "C"},
{"d", "D"},
{"e", "E"}
}));
packer_->pack(*object_);
ASSERT_EQ(map5, os_.str());
}
/*
TEST_F(TestObjectPacker, indef1){
object_->start_bin();
object_->add_element((const uint8_t*)"\x01\x02", 2);
object_->add_element((const uint8_t*)"\x03\x04\x05", 3);
object_->stop_bin();
packer_->pack(*object_);
ASSERT_EQ(indef1, os_.str());
}
TEST_F(TestObjectPacker, indef2){
object_->start_string();
object_->add_element("strea");
object_->add_element("ming");
object_->stop_string();
packer_->pack(*object_);
ASSERT_EQ(indef2, os_.str());
}
TEST_F(TestObjectPacker, indef3){
object_->start_array();
object_->stop_array();
packer_->pack(*object_);
ASSERT_EQ(indef3, os_.str());
}
TEST_F(TestObjectPacker, indef4){
object_->start_array();
object_->add_element(1);
object_->add_element(std::vector<uint8_t>({2, 3}));
unicbor::object& nested = object_->add_element();
nested.start_array();
nested.add_element(4);
nested.add_element(5);
nested.stop_array();
object_->stop_array();
packer_->pack(*object_);
ASSERT_EQ(indef4, os_.str());
}
TEST_F(TestObjectPacker, indef5){
object_->start_array();
object_->add_element(1);
object_->add_element(std::vector<uint8_t>({2, 3}));
object_->add_element(std::vector<uint8_t>({4, 5}));
object_->stop_array();
packer_->pack(*object_);
ASSERT_EQ(indef5, os_.str());
}
TEST_F(TestObjectPacker, indef6){
object_->start_array(3);
object_->add_element(1);
object_->add_element(std::vector<uint8_t>({2, 3}));
unicbor::object& nested = object_->add_element();
nested.start_array();
nested.add_element(4);
nested.add_element(5);
ASSERT_TRUE(!object_->complete());
nested.stop_array();
ASSERT_TRUE(object_->complete());
packer_->pack(*object_);
ASSERT_EQ(indef6, os_.str());
}
TEST_F(TestObjectPacker, indef7){
object_->start_array(3);
object_->add_element(1);
unicbor::object& nested = object_->add_element();
nested.start_array();
nested.add_element(2);
nested.add_element(3);
ASSERT_TRUE(!object_->complete());
nested.stop_array();
ASSERT_TRUE(!object_->complete());
object_->add_element(std::vector<uint8_t>({4, 5}));
ASSERT_TRUE(object_->complete());
packer_->pack(*object_);
ASSERT_EQ(indef7, os_.str());
}
TEST_F(TestObjectPacker, indef8){
object_->start_array();
for(int i = 1; i <= 25; i++)
object_->add_element(i);
object_->stop_array();
packer_->pack(*object_);
ASSERT_EQ(indef8, os_.str());
}
TEST_F(TestObjectPacker, indef9){
object_->start_map();
object_->add_element(std::make_pair("a", 1));
object_->add_element("b");
unicbor::object& nested = object_->add_element();
nested.start_array();
nested.add_element(2);
nested.add_element(3);
nested.stop_array();
object_->stop_map();
packer_->pack(*object_);
ASSERT_EQ(indef9, os_.str());
}
TEST_F(TestObjectPacker, indef10){
object_->start_array(2);
object_->add_element("a");
unicbor::object& nested = object_->add_element();
nested.start_map();
nested.add_element("b");
nested.add_element("c");
nested.stop_map();
packer_->pack(*object_);
ASSERT_EQ(indef10, os_.str());
}
TEST_F(TestObjectPacker, indef11){
object_->start_map();
object_->add_element(std::make_pair("Fun", true));
object_->add_element(std::make_pair("Amt", -2));
object_->stop_map();
packer_->pack(*object_);
ASSERT_EQ(indef11, os_.str());
}*/ | 23.604863 | 155 | 0.70197 | [
"object",
"vector"
] |
517ebbde7f2ecdd4cc13b93928f1a9692eda8b18 | 1,932 | cpp | C++ | lib/Target/Sophon/BM188x/TGRelu.cpp | zakk0610/onnc | ed470ff76dce0c5338b285ecfbd88b03e667d295 | [
"BSD-3-Clause"
] | 1 | 2018-08-27T02:51:59.000Z | 2018-08-27T02:51:59.000Z | lib/Target/Sophon/BM188x/TGRelu.cpp | ffk0716/onnc | 91e4955ade64b479db17aaeccacf4b7339fe44d2 | [
"BSD-3-Clause"
] | null | null | null | lib/Target/Sophon/BM188x/TGRelu.cpp | ffk0716/onnc | 91e4955ade64b479db17aaeccacf4b7339fe44d2 | [
"BSD-3-Clause"
] | null | null | null | //===---------------------------------------------------------------------===//
//
// The ONNC Project
//
// Copyright(c) 2018, The ONNC Team
//
// This file is part of the ONNC Project and is distributed under
// 3-clause BSD license (https://opensource.org/licenses/BSD-3-Clause)
//
// See LICENSE.TXT for details.
//
//===---------------------------------------------------------------------===//
#define DEBUG_TYPE "tg_relu"
#include "TGRelu.h"
#include "BM188xCodeEmitter.h"
#include <onnc/Support/Debug.h>
#include <onnc/Target/Sophon/BM188x/bmkernel_api.h>
namespace onnc {
namespace BM188X {
TGRelu::TGRelu(const xNode &pNode)
: BM188xComputeOperator(pNode, std::string("Relu")), m_NegativeSlope(0)
{
const std::vector<xDimension> inDim = pNode.inputs()[0]->sizes();
if (inDim.size() == 4) {
m_N = inDim[0].dim;
m_C = inDim[1].dim;
m_H = inDim[2].dim;
m_W = inDim[3].dim;
} else if (inDim.size() == 2) {
m_N = inDim[0].dim;
m_C = 1;
m_H = inDim[1].dim;
m_W = 1;
} else {
assert(0 && "inDim.size() != 4 & !=2");
}
}
TGRelu *TGRelu::addMemOperands(MemOperand *pInput, MemOperand *pOutput)
{
m_MemOperands.push_back(pInput);
m_MemOperands.push_back(pOutput);
return this;
}
void TGRelu::emit() const
{
DEBUG(dbgs()
<< "TGRelu::emit\n" << " "
<< m_MemOperands[0]->m_Addr << " " << m_MemOperands[1]->m_Addr << " "
<< m_N << " " << m_C << " " << m_H << " " << m_W << " "
<< m_NegativeSlope << "\n");
bmnet::bmnet_asm::bmnet_relu_fixed_forward_bmkernel(
m_MemOperands[0]->m_Addr, // input_gaddr
m_MemOperands[1]->m_Addr, // output_gaddr
m_NegativeSlope, // negative_slope
m_N, // input_n
m_C, // input_c
m_H, // input_h
m_W // input_w
);
}
} // namespace BM188X
} // namespace onnc
| 28 | 79 | 0.52795 | [
"vector"
] |
517fb5c5a403ec221f604e3855b78917dd3da144 | 426 | cpp | C++ | Priority Queues/Kth Largest Elements.cpp | Unknownone-af/Data-Structures | a4d591f012b2998dd34d249dcc0f293be272f617 | [
"MIT"
] | 1 | 2020-06-21T23:57:34.000Z | 2020-06-21T23:57:34.000Z | Priority Queues/Kth Largest Elements.cpp | Unknownone-af/Data-Structures | a4d591f012b2998dd34d249dcc0f293be272f617 | [
"MIT"
] | null | null | null | Priority Queues/Kth Largest Elements.cpp | Unknownone-af/Data-Structures | a4d591f012b2998dd34d249dcc0f293be272f617 | [
"MIT"
] | null | null | null | #include<iostream>
#include<vector>
using namespace std;
#include<queue>
int kthLargest(vector<int> a, int n, int k){
priority_queue<int> pq;
for(int i=0;i<n;i++){
pq.push(a[i]);
}
for(int i=1;i<k;i++){
pq.pop();
}
return pq.top();
}
int main(){
int n,k,s;
vector<int> arr;
cin >>n;
for(int i=0;i<n;i++){
cin >>s;
arr.push_back(s);
}
cin >>k;
cout <<kthLargest(arr, n, k)<<endl;
}
| 14.689655 | 44 | 0.556338 | [
"vector"
] |
3d60ddfb20460dfc7f7ed14dcbf55ff750d9ae25 | 7,355 | hpp | C++ | library/math/gaussian_elimination.hpp | suisen-cp/cp-library-cpp | 8fbbdcdbceb60f5adc56ff4740549ce3c1a1ea43 | [
"CC0-1.0"
] | 2 | 2021-10-04T15:46:56.000Z | 2022-01-14T19:28:43.000Z | library/math/gaussian_elimination.hpp | suisen-cp/cp-library-cpp | 8fbbdcdbceb60f5adc56ff4740549ce3c1a1ea43 | [
"CC0-1.0"
] | null | null | null | library/math/gaussian_elimination.hpp | suisen-cp/cp-library-cpp | 8fbbdcdbceb60f5adc56ff4740549ce3c1a1ea43 | [
"CC0-1.0"
] | null | null | null | #ifndef SUISEN_GAUSSIAN_ELIMINATION
#define SUISEN_GAUSSIAN_ELIMINATION
#include <cmath>
#include <optional>
#include <vector>
namespace suisen {
namespace internal {
namespace gauss_jordan {
template <typename T>
bool equals_zero(const T& v) {
return v == 0;
}
template <>
bool equals_zero<long double>(const long double &v) {
static constexpr long double EPS = 1e-9;
return std::abs(v) < EPS;
}
template <typename T>
std::pair<unsigned int, unsigned int> pivoting(const std::vector<std::vector<T>> &Ab, const T &zero, const unsigned int i) {
const unsigned int n = Ab.size(), m = Ab[0].size() - 1;
unsigned int mse = m, pivot = n;
for (unsigned int row = i; row < n; ++row) {
for (unsigned int col = 0; col < mse; ++col) {
if (not equals_zero(Ab[row][col])) {
mse = col, pivot = row;
break;
}
}
}
return {mse, pivot};
}
// Gauss pivoting
template <>
std::pair<unsigned int, unsigned int> pivoting<long double>(const std::vector<std::vector<long double>> &Ab, const long double &zero, const unsigned int i) {
const unsigned int n = Ab.size(), m = Ab[0].size() - 1;
unsigned int mse = m, pivot = n;
long double max_val = 0;
for (unsigned int row = i; row < n; ++row) {
if (mse < m and std::abs(Ab[row][mse]) > max_val) {
pivot = row;
max_val = std::abs(Ab[row][mse]);
}
for (unsigned int col = 0; col < mse; ++col) {
if (not equals_zero(Ab[row][col])) {
mse = col, pivot = row, max_val = std::abs(Ab[row][col]);
break;
}
}
}
return {mse, pivot};
}
template <typename T> constexpr T add_fp_f2(T x, T y) { return x ^ y; }
template <typename T> constexpr T add_inv_fp_f2(T x) { return x; }
template <typename T> constexpr T mul_fp_f2(T x, T y) { return x & y; }
template <typename T> constexpr T mul_inv_fp_f2(T x) { return x; }
template <typename T> constexpr T add_fp_arithmetic(T x, T y) { return x + y; }
template <typename T> constexpr T add_inv_fp_arithmetic(T x) { return 0 - x; }
template <typename T> constexpr T mul_fp_arithmetic(T x, T y) { return x * y; }
template <typename T> constexpr T mul_inv_fp_arithmetic(T x) { return 1 / x; }
}
}
template <typename T, T(*add_fp)(T, T), T(*add_inv_fp)(T), T(*mul_fp)(T, T), T(*mul_inv_fp)(T)>
class GaussianElimination {
public:
GaussianElimination(std::vector<std::vector<T>> &A, std::vector<T> &b, const T zero, const T one) {
unsigned int n = A.size();
for (unsigned int i = 0; i < n; ++i) A[i].push_back(b[i]);
solve(zero, one, A);
}
GaussianElimination(std::vector<std::vector<T>> &A, std::vector<T> &b) {
unsigned int n = A.size();
for (unsigned int i = 0; i < n; ++i) A[i].push_back(b[i]);
solve(T(0), T(1), A);
}
bool has_solution() const { return not _empty; }
bool has_unique_solution() const { return not _empty and _basis.size() == 0; }
bool has_multiple_solutions() const { return _basis.size() > 0; }
const std::optional<std::vector<T>> get_solution() const {
return _empty ? std::nullopt : std::make_optional(_x0);
}
const std::vector<std::vector<T>>& get_basis() const {
return _basis;
}
int dimension() const {
return _empty ? -1 : _basis.size();
}
private:
std::vector<T> _x0;
std::vector<std::vector<T>> _basis;
bool _empty = false;
void solve(const T zero, const T one, std::vector<std::vector<T>> &Ab) {
const unsigned int n = Ab.size(), m = Ab[0].size() - 1;
for (unsigned int i = 0; i < n; ++i) {
auto [mse, pivot] = internal::gauss_jordan::pivoting(Ab, zero, i);
if (pivot == n) break;
Ab[i].swap(Ab[pivot]);
T mse_val_inv = mul_inv_fp(Ab[i][mse]);
for (unsigned int row = i + 1; row < n; ++row) {
if (not internal::gauss_jordan::equals_zero(Ab[row][mse])) {
T coef = add_inv_fp(mul_fp(Ab[row][mse], mse_val_inv));
for (unsigned int col = mse; col <= m; ++col) {
Ab[row][col] = add_fp(Ab[row][col], mul_fp(coef, Ab[i][col]));
}
}
}
}
unsigned int basis_num = m;
std::vector<char> down(m, false);
_x0.assign(m, zero);
for (unsigned int i = n; i --> 0;) {
unsigned int mse = m + 1;
for (unsigned int col = 0; col <= m; ++col) {
if (not internal::gauss_jordan::equals_zero(Ab[i][col])) {
mse = col;
break;
}
}
if (mse < m) {
T mse_val_inv = mul_inv_fp(Ab[i][mse]);
for (unsigned int row = 0; row < i; ++row) {
if (not internal::gauss_jordan::equals_zero(Ab[row][mse])) {
T coef = add_inv_fp(mul_fp(Ab[row][mse], mse_val_inv));
for (unsigned int col = mse; col <= m; ++col) {
Ab[row][col] = add_fp(Ab[row][col], mul_fp(coef, Ab[i][col]));
}
}
}
for (unsigned int col = mse; col <= m; ++col) {
Ab[i][col] = mul_fp(Ab[i][col], mse_val_inv);
}
_x0[mse] = Ab[i][m];
down[mse] = true;
--basis_num;
} else if (mse == m) {
_empty = true;
return;
}
}
_basis.assign(basis_num, std::vector<T>(m));
int basis_id = 0;
for (unsigned int j = 0; j < m; ++j) {
if (down[j]) continue;
for (unsigned int j2 = 0, i = 0; j2 < m; ++j2) {
_basis[basis_id][j2] = down[j2] ? Ab[i++][j] : zero;
}
_basis[basis_id][j] = add_inv_fp(one);
basis_id++;
}
}
};
template <typename T>
using GaussianEliminationF2 = GaussianElimination<
T,
internal::gauss_jordan::add_fp_f2, internal::gauss_jordan::add_inv_fp_f2,
internal::gauss_jordan::mul_fp_f2, internal::gauss_jordan::mul_inv_fp_f2>;
template <typename T>
using GaussianEliminationArithmetic = GaussianElimination<
T,
internal::gauss_jordan::add_fp_arithmetic, internal::gauss_jordan::add_inv_fp_arithmetic,
internal::gauss_jordan::mul_fp_arithmetic, internal::gauss_jordan::mul_inv_fp_arithmetic>;
} // namespace suisen
#endif // SUISEN_GAUSSIAN_ELIMINATION | 43.011696 | 165 | 0.488375 | [
"vector"
] |
3d637d1b3070b22ac52d0bd6ca6d04ca8a16ded2 | 4,915 | hxx | C++ | MessageBuffer.hxx | cbond/msrp | d498f1ac8848319f4ecb617ad251e76de827a9a2 | [
"BSL-1.0"
] | null | null | null | MessageBuffer.hxx | cbond/msrp | d498f1ac8848319f4ecb617ad251e76de827a9a2 | [
"BSL-1.0"
] | null | null | null | MessageBuffer.hxx | cbond/msrp | d498f1ac8848319f4ecb617ad251e76de827a9a2 | [
"BSL-1.0"
] | 1 | 2021-07-20T12:14:59.000Z | 2021-07-20T12:14:59.000Z | #ifndef MSRP_MESSAGECONTENTS_HXX
#define MSRP_MESSAGECONTENTS_HXX
#include <cassert>
#include <cstddef>
#include <memory>
#include <stdexcept>
#include <string>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/spirit.hpp>
#include <boost/range.hpp>
#include <asio/buffer.hpp>
#include "msrp/Exception.hxx"
#include "msrp/Message.hxx"
namespace msrp
{
class MessageBuffer
{
public:
struct Exception : public msrp::Exception
{
Exception(const std::string& s, const ExceptionContext& context) :
msrp::Exception(s, context)
{}
};
MessageBuffer(std::size_t size = 65536);
asio::mutable_buffer mutableBuffer()
{
return asio::mutable_buffer(&mBuffer.get()[mStored], mBufferSize - mStored);
}
asio::const_buffer buffer() const
{
return asio::const_buffer(mBuffer.get(), mStored);
}
// contents in context of the message
asio::const_buffer contents() const;
// free buffer space for incoming data
void erase();
// reset parse state and buffer
void reset();
// indicate that data has been read into mutableBuffer()
void read(std::size_t);
enum State
{
Status, // wait for status line
Headers, // wait for header block
Content, // wait for contents
Complete // full message received
};
State state() const
{
return mState;
}
Message::MsgStatus status() const
{
return mStatus;
}
Message::Method method() const
{
return mMethod;
}
// If the buffer goes from State::Status to Complete in one read, you may
// wish to parse the message including contents. If you know the message
// will be disposed of before you call erase or reset on MessageBuffer,
// you may create a Data overlay for the contents to avoid a copy. If
// the entire message has not received, you will generally want to preparse
// to figure out where to route the message and then read the contents with
// MessageBuffer::contents() afterward.
enum ParseMode
{
CopyContents,
OverlayContents,
NoContents
};
boost::shared_ptr<Message> parse(const ParseMode) const;
private:
typedef const char* const_iterator;
boost::scoped_ptr<char> mBuffer;
std::size_t mBufferSize;
std::size_t mStored;
State mState;
Message::Method mMethod;
Message::MsgStatus mStatus;
// transaction ID
std::string mTid;
boost::spirit::rule<> mParser;
boost::iterator_range<const_iterator> mStatusRange;
boost::iterator_range<const_iterator> mHeaderRange;
boost::iterator_range<const_iterator> mContentRange;
boost::iterator_range<const_iterator> mTokenRange;
bool getTransaction(boost::iterator_range<const_iterator>&);
bool getHeader(boost::iterator_range<const_iterator>&);
bool getEndToken(boost::iterator_range<const_iterator>&);
void setContentRange();
std::size_t offset(const_iterator i) const;
// erase pointers into the buffer without erasing the buffer
void resetRanges();
// search in reverse for the end token
const_iterator reverseKey(const_iterator, std::size_t) const;
// based on mTransactionId
const std::string endToken() const;
static const std::size_t Safety;
};
}
#endif
// Copyright 2007 Chris Bond
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
| 29.608434 | 85 | 0.680773 | [
"object"
] |
3d63c3d321e9501efde00837a743ce7f264336d3 | 3,443 | hh | C++ | src/graphics/Mesh.hh | othieno/clockwork | ac2b7d2e0324fff1440df90670de181dce234dd0 | [
"MIT"
] | 6 | 2016-09-19T09:02:32.000Z | 2021-03-01T05:50:53.000Z | src/graphics/Mesh.hh | othieno/clockwork | ac2b7d2e0324fff1440df90670de181dce234dd0 | [
"MIT"
] | null | null | null | src/graphics/Mesh.hh | othieno/clockwork | ac2b7d2e0324fff1440df90670de181dce234dd0 | [
"MIT"
] | 2 | 2016-06-01T02:18:07.000Z | 2021-06-25T13:32:22.000Z | /*
* This file is part of Clockwork.
*
* Copyright (c) 2013-2016 Jeremy Othieno.
*
* The MIT License (MIT)
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CLOCKWORK_MESH_HH
#define CLOCKWORK_MESH_HH
#include "Resource.hh"
#include "Material.hh"
#include <QList>
#include <QVector3D>
#include <QPointF>
namespace clockwork {
/**
*
*/
class Mesh : public Resource {
friend class ResourceManager;
public:
/**
* A polygon mesh's triangular face.
*/
struct Face {
/**
* The number of elements in the face.
*/
constexpr static std::size_t length = 3;
/**
* An array of pointers to geometric positions.
*/
using Positions = std::array<const QVector3D*, Face::length>;
/**
* An array of pointers to 2D texture coordinates.
*/
using TextureCoordinates = std::array<const QPointF*, Face::length>;
/**
* An array of pointers to 3D normal vectors.
*/
using Normals = std::array<const QVector3D*, Face::length>;
/**
* Instantiates a Face object with references to the specified positions,
* texture coordinates and normal vectors.
*/
Face(const Positions&, const TextureCoordinates&, const Normals&);
/**
* The positions of each vertex in the face.
*/
const Positions positions;
/**
* The texture coordinates for each vertex in the face.
*/
const TextureCoordinates textureCoordinates;
/**
* The normal vectors for each vertex in the face.
*/
const Normals normals;
/**
* The surface normal.
*/
const QVector3D surfaceNormal;
};
/**
*
*/
Mesh(const Mesh&) = delete;
/**
*
*/
Mesh(Mesh&&) = delete;
/**
*
*/
Mesh& operator=(const Mesh&) = delete;
/**
*
*/
Mesh& operator=(Mesh&&) = delete;
/**
* Removes all data from the mesh's arrays.
*/
void clear();
/**
* The polygon mesh's vertex positions.
*/
QList<QVector3D> positions;
/**
* The polygon mesh's texture coordinates.
*/
QList<QPointF> textureCoordinates;
/**
* The polygon mesh's vertex normals.
*/
QList<QVector3D> normals;
/**
* The polygon mesh's faces.
*/
QList<Face> faces;
/**
* The polygon mesh's material information.
*/
Material material;
private:
/**
*
*/
Mesh() = default;
/**
* Loads a polygon mesh from the specified file.
* @param file a file containing the data to load.
*/
void load(QFile& file) override;
};
} // namespace clockwork
#endif // CLOCKWORK_MESH_HH
| 24.949275 | 80 | 0.684868 | [
"mesh",
"object",
"3d"
] |
3d6566a25529ee6b6b2a6a7e6423027cd93ec649 | 12,751 | cc | C++ | applications/camera_calibration/src/camera_calibration/relative_pose_initialization/noncentral_camera_planar_target.cc | lingbo-yu/camera_calibration | ff5f09fa2253b01b80c24ec600936f5d083d03f3 | [
"BSD-3-Clause"
] | 474 | 2019-12-09T06:20:57.000Z | 2022-03-31T06:14:38.000Z | applications/camera_calibration/src/camera_calibration/relative_pose_initialization/noncentral_camera_planar_target.cc | lingbo-yu/camera_calibration | ff5f09fa2253b01b80c24ec600936f5d083d03f3 | [
"BSD-3-Clause"
] | 60 | 2020-01-10T08:41:57.000Z | 2022-03-19T15:39:43.000Z | applications/camera_calibration/src/camera_calibration/relative_pose_initialization/noncentral_camera_planar_target.cc | lingbo-yu/camera_calibration | ff5f09fa2253b01b80c24ec600936f5d083d03f3 | [
"BSD-3-Clause"
] | 90 | 2019-12-09T08:48:06.000Z | 2022-03-31T06:14:38.000Z | // Copyright 2019 ETH Zürich, Thomas Schöps
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#include "camera_calibration/relative_pose_initialization/algorithms.h"
namespace vis {
bool NonCentralCameraPlanarCalibrationObjectRelativePose(const Point3fCloud clouds[3], SE3d cloud2_tr_cloud[2], SE3d gt_cloud2_tr_cloud[2]) {
usize num_points = clouds[0].size();
// * 2 constraints per point triple
// * 23 unknowns in system of homogeneous equations (... = 0)
// * solution only possible up to scale
// --> 11 point triples required
if (num_points < 11) {
return false;
}
Mat3d gt_R0 = gt_cloud2_tr_cloud[0].rotationMatrix();
// Vec3f gt_t0 = gt_cloud2_tr_cloud[0].translation();
// Mat3f gt_R1 = gt_cloud2_tr_cloud[1].rotationMatrix();
// Vec3f gt_t1 = gt_cloud2_tr_cloud[1].translation();
// Normalize position and scaling of homogeneous points.
vector<Vec2d> normalized_clouds[3];
Vec2d sum = Vec2d::Zero();
for (int i = 0; i < 3; ++ i) {
for (usize r = 0; r < num_points; ++ r) {
const Vec3f& p = clouds[i][r].position();
if (fabs(p.z()) > 1e-6) {
std::cout << "ERROR: The z coordinate of all input points must be zero!\n";
return false;
}
sum += Vec2d(p.x(), p.y());
}
}
Vec2d mean = sum / (3 * num_points);
double dist_sum = 0;
for (int i = 0; i < 3; ++ i) {
normalized_clouds[i].resize(num_points);
for (usize r = 0; r < num_points; ++ r) {
const Vec3f& p = clouds[i][r].position();
normalized_clouds[i][r] = Vec2d(p.x(), p.y()) - mean;
dist_sum += normalized_clouds[i][r].norm();
}
}
double mean_dist = dist_sum / (3 * num_points);
double norm_factor = sqrtf(2) / mean_dist;
for (int i = 0; i < 3; ++ i) {
for (usize r = 0; r < num_points; ++ r) {
normalized_clouds[i][r] = norm_factor * normalized_clouds[i][r];
}
}
// Assemble coefficients matrices.
Eigen::Matrix<double, Eigen::Dynamic, 23> C;
C.resize(2 * num_points, Eigen::NoChange);
for (usize point = 0; point < num_points; ++ point) {
// Q corresponds to clouds[2][point] (the cloud with fixed pose).
const Vec2d& Q = normalized_clouds[2][point];
// Q' corresponds to clouds[0][point].
const Vec2d& Qp = normalized_clouds[0][point];
// Q'' corresponds to clouds[1][point].
const Vec2d& Qpp = normalized_clouds[1][point];
// Row 1 (for V):
int r = 2 * point + 0;
C(r, 1 - 1) = Q.y() * Qp.x() * 1;
C(r, 2 - 1) = Q.y() * Qp.y() * 1;
C(r, 3 - 1) = Q.y() * 1 * Qpp.x();
C(r, 4 - 1) = Q.y() * 1 * Qpp.y();
C(r, 5 - 1) = Q.y() * 1 * 1;
C(r, 6 - 1) = 1 * Qp.x() * Qpp.x();
C(r, 7 - 1) = 1 * Qp.x() * Qpp.y();
C(r, 8 - 1) = 1 * Qp.x() * 1;
C(r, 9 - 1) = 1 * Qp.y() * Qpp.x();
C(r, 10 - 1) = 1 * Qp.y() * Qpp.y();
C(r, 11 - 1) = 1 * Qp.y() * 1;
C(r, 12 - 1) = 1 * 1 * Qpp.x();
C(r, 13 - 1) = 1 * 1 * Qpp.y();
C(r, 14 - 1) = 1 * 1 * 1;
for (int i = 15; i < 15 + 9; ++ i) {
C(r, i - 1) = 0;
}
// Row 2 (for W):
r = 2 * point + 1;
C(r, 1 - 1) = Q.x() * Qp.x() * 1;
C(r, 2 - 1) = Q.x() * Qp.y() * 1;
C(r, 3 - 1) = Q.x() * 1 * Qpp.x();
C(r, 4 - 1) = Q.x() * 1 * Qpp.y();
C(r, 5 - 1) = Q.x() * 1 * 1;
for (int i = 6; i < 6 + 9; ++ i) {
C(r, i - 1) = 0;
}
C(r, 15 - 1) = 1 * Qp.x() * Qpp.x();
C(r, 16 - 1) = 1 * Qp.x() * Qpp.y();
C(r, 17 - 1) = 1 * Qp.x() * 1;
C(r, 18 - 1) = 1 * Qp.y() * Qpp.x();
C(r, 19 - 1) = 1 * Qp.y() * Qpp.y();
C(r, 20 - 1) = 1 * Qp.y() * 1;
C(r, 21 - 1) = 1 * 1 * Qpp.x();
C(r, 22 - 1) = 1 * 1 * Qpp.y();
C(r, 23 - 1) = 1 * 1 * 1;
}
// Compute solution vector U (up to scale), containing the values of V and W from the original algorithm.
JacobiSVD<MatrixXd> svd_U(C, ComputeFullV);
Matrix<double, 23, 1> U = svd_U.matrixV().col(22);
// U(1-1)..U(5-1) corresponds to both V(6-6)..V(10-6) and W(1-1)..W(5-1).
// U(6-1)..U(14-1) corresponds to V(11-6)..V(19-6).
// U(15-1)..U(23-1) corresponds to W(11-6)..W(19-6).
// DEBUG
// std::cout << "gt_R0(2, 0): " << gt_R0(2, 0) << " vs. " << gt_lambda_1 * U(1-1) << endl;
// std::cout << "t'3: " << gt_t0.z() << " vs. " << gt_lambda_1 * up << endl;
// std::cout << "t''3: " << gt_t1.z() << " vs. " << gt_lambda_1 * upp << endl;
// Set up first system to extract some rotation components.
Matrix<double, 4, 4> A;
A << -U(3-1), 0, -U(1-1), 0,
-U(4-1), 0, 0, -U(1-1),
0, -U(3-1), -U(2-1), 0,
0, -U(4-1), 0, -U(2-1);
Matrix<double, 4, 1> A1_b;
A1_b << U(6-1),
U(7-1),
U(9-1),
U(10-1);
// DEBUG
// std::cout << "b from gt:\n" << (A * Matrix<double, 4, 1>(gt_R0(1, 0), gt_R0(1, 1), gt_R1(1, 0), gt_R1(1, 1))) << endl;
// std::cout << "assembled b:\n" << A1_b << endl;
// Obtain solution with one free parameter.
// m = 4, r = 3, n = 4.
// In the SVD, U is 4x4, V is 4x4.
JacobiSVD<MatrixXd> svd_A1(A, ComputeFullU | ComputeFullV);
Matrix<double, 4, 1> b1_prime = svd_A1.matrixU().transpose() * A1_b;
Matrix<double, 4, 1> y1;
for (int i = 0; i < 3; ++ i) {
y1[i] = b1_prime[i] / svd_A1.singularValues()[i];
}
y1[3] = 0;
Matrix<double, 4, 1> solution_a1 = svd_A1.matrixV() * y1;
// Matrix<double, 4, 1> solution_b1 = svd_A1.matrixV().col(3);
// Set up second system to extract some rotation components.
Matrix<double, 4, 1> A2_b;
A2_b << U(15-1),
U(16-1),
U(18-1),
U(19-1);
// DEBUG
// std::cout << "b2 from gt:\n" << (A * Matrix<double, 4, 1>(gt_R0(0, 0), gt_R0(0, 1), gt_R1(0, 0), gt_R1(0, 1))) << endl;
// std::cout << "assembled b2:\n" << A2_b << endl;
// Obtain solution with one free parameter.
// m = 4, r = 3, n = 4.
// In the SVD, U is 4x4, V is 4x4.
JacobiSVD<MatrixXd> svd_A2(A, ComputeFullU | ComputeFullV);
Matrix<double, 4, 1> b2_prime = svd_A2.matrixU().transpose() * A2_b;
Matrix<double, 4, 1> y2;
for (int i = 0; i < 3; ++ i) {
y2[i] = b2_prime[i] / svd_A2.singularValues()[i];
}
y2[3] = 0;
Matrix<double, 4, 1> solution_a2 = svd_A2.matrixV() * y2;
// Matrix<double, 4, 1> solution_b2 = svd_A2.matrixV().col(3);
// Set up system to extract the scaling of the previous solutions.
// Use the same indexing as in S. Ramalingam's PhD thesis for convenience.
auto a = [&](int i){return (i <= 4) ? solution_a1[i-1] : solution_a2[i - 5];};
// auto b = [&](int i){return (i <= 4) ? solution_b1[i-1] : solution_b2[i - 5];};
// TODO: Use closed-form expressions for a as well. Those are not given in
// the paper "due to lack of space".
// Using the approach from "A unifying model for camera calibration" instead
// of the more complicated one from the PhD thesis. Index mapping:
// thesis - paper
// V6 - V8
// V7 - V9
// V8 - V11
// V9 - V12
Matrix<double, 6, 3> A3;
A3(0, 0) = a(1)*U(2-1) + U(1-1)*a(2);
A3(1, 0) = -a(3)*U(4-1) - U(3-1)*a(4);
A3(2, 0) = 2*a(1)*U(1-1);
A3(3, 0) = 2*a(2)*U(2-1);
A3(4, 0) = -2*a(3)*U(3-1);
A3(5, 0) = -2*a(4)*U(4-1);
A3(0, 1) = a(5)*U(2-1) + U(1-1)*a(6);
A3(1, 1) = -a(7)*U(4-1) - U(3-1)*a(8);
A3(2, 1) = 2*a(5)*U(1-1);
A3(3, 1) = 2*a(6)*U(2-1);
A3(4, 1) = -2*a(7)*U(3-1);
A3(5, 1) = -2*a(8)*U(4-1);
A3(0, 2) = U(1-1)*U(2-1);
A3(1, 2) = U(3-1)*U(4-1);
A3(2, 2) = U(1-1)*U(1-1);
A3(3, 2) = U(2-1)*U(2-1);
A3(4, 2) = U(3-1)*U(3-1);
A3(5, 2) = U(4-1)*U(4-1);
Matrix<double, 6, 1> A5_b;
A5_b << -a(5)*a(6) - a(1)*a(2),
-a(7)*a(8) - a(3)*a(4),
1 - a(1)*a(1) - a(5)*a(5),
1 - a(2)*a(2) - a(6)*a(6),
1 - a(3)*a(3) - a(7)*a(7),
1 - a(4)*a(4) - a(8)*a(8);
// Solve the system.
Matrix<double, 3, 1> solution_d = (A3.transpose() * A3).inverse() * (A3.transpose() * A5_b);
double l1 = solution_d[0];
double l2 = solution_d[1];
// TODO: Only computing the solution for +lambda here!
// TODO: Use the ground truth to decide for the sign of lambda
double lambda_squared = 1 / (solution_d[2] - l1*l1 - l2*l2);
if (lambda_squared < -1e-3) {
std::cout << "WARNING: Negative value in sqrt(): " << lambda_squared << endl;
}
double lambda = sqrt(std::max(0., lambda_squared));
Mat3d R0, R1;
R0(1, 0) = a(1) + l1 * U(1-1);
R0(1, 1) = a(2) + l1 * U(2-1);
R1(1, 0) = a(3) + l1 * -U(3-1);
R1(1, 1) = a(4) + l1 * -U(4-1);
R0(0, 0) = a(5) + l2 * U(1-1);
R0(0, 1) = a(6) + l2 * U(2-1);
R1(0, 0) = a(7) + l2 * -U(3-1);
R1(0, 1) = a(8) + l2 * -U(4-1);
// HACK: Use the ground truth to decide for the sign of lambda
if (gt_R0(2, 0) * (U(1-1) / lambda) < 0) {
lambda = -lambda;
}
R0(2, 0) = U(1-1) / lambda;
R0(2, 1) = U(2-1) / lambda;
R1(2, 0) = -U(3-1) / lambda;
R1(2, 1) = -U(4-1) / lambda;
R0.col(2) = R0.col(0).cross(R0.col(1));
R1.col(2) = R1.col(0).cross(R1.col(1));
Vec3d t0, t1;
double denom1 = -U(4-1)*U(6-1) + U(3-1)*U(7-1);
double denom2 = U(4-1)*U(15-1) - U(3-1)*U(16-1);
double up; // corresponds to u'
if (fabs(denom1) > fabs(denom2)) {
up = ((-U(4-1)*U(12-1) + U(3-1)*U(13-1)) * U(1-1)) / denom1;
} else {
up = ((U(4-1)*U(21-1) - U(3-1)*U(22-1)) * U(1-1)) / denom2;
}
double upp = up - U(5-1); // corresponds to u''
t0.z() = up / lambda;
t1.z() = upp / lambda;
if (fabs(U(3-1)) > fabs(U(4-1))) {
t0.x() = (U(21-1) + R1(0, 0) * up) / (-U(3-1));
t0.y() = (U(12-1) + R1(1, 0) * up) / (-U(3-1));
} else {
t0.x() = (U(22-1) + R1(0, 1) * up) / (-U(4-1));
t0.y() = (U(13-1) + R1(1, 1) * up) / (-U(4-1));
}
if (fabs(U(1-1)) > fabs(U(2-1))) {
t1.x() = (R0(0, 0) * upp - U(17-1)) / U(1-1);
t1.y() = (R0(1, 0) * upp - U(8-1)) / U(1-1);
} else {
t1.x() = (R0(0, 1) * upp - U(20-1)) / U(2-1);
t1.y() = (R0(1, 1) * upp - U(11-1)) / U(2-1);
}
// Try to improve numerical stability a bit more by going over V_19 / W_19
// in case either t1.x/y or t2.x/y are very unstable.
// V19 = t'2 t''3 - t''2 t'3
// W19 = t'1 t''3 - t''1 t'3
constexpr double kEpsilon = 1e-5f;
if (fabs(U(3-1)) < kEpsilon &&
fabs(U(4-1)) < kEpsilon &&
fabs(t1.z()) >= kEpsilon) {
t0.x() = (U(23-1) / lambda + t1.x() * t0.z()) / t1.z();
t0.y() = (U(14-1) / lambda + t1.y() * t0.z()) / t1.z();
} else if (fabs(U(1-1)) < kEpsilon &&
fabs(U(2-1)) < kEpsilon &&
fabs(t0.z()) >= kEpsilon) {
t1.x() = (t0.x() * t1.z() - U(23-1) / lambda) / t0.z();
t1.y() = (t0.y() * t1.z() - U(14-1) / lambda) / t0.z();
}
cloud2_tr_cloud[0] = SE3d(R0, t0);
cloud2_tr_cloud[1] = SE3d(R1, t1);
// De-normalize the solution.
cloud2_tr_cloud[0].translation() /= norm_factor;
cloud2_tr_cloud[1].translation() /= norm_factor;
cloud2_tr_cloud[0] = SE3d(Quaterniond::Identity(), Vec3d(mean.x(), mean.y(), 0)) *
cloud2_tr_cloud[0] *
SE3d(Quaterniond::Identity(), Vec3d(-mean.x(), -mean.y(), 0));
cloud2_tr_cloud[1] = SE3d(Quaterniond::Identity(), Vec3d(mean.x(), mean.y(), 0)) *
cloud2_tr_cloud[1] *
SE3d(Quaterniond::Identity(), Vec3d(-mean.x(), -mean.y(), 0));
return true;
}
}
| 35.518106 | 141 | 0.532664 | [
"vector",
"model"
] |
3d6a7d0a58f947dc9e875f889b741a123526c634 | 34,953 | cpp | C++ | SCANVariants/other-projects/dbscan-v1.0.0/parallel_mpi/dbscan.cpp | CheYulin/ScanOptimizing | 691b39309da1c6b5df46b264b5a300a35d644f70 | [
"MIT"
] | 19 | 2019-05-22T13:17:58.000Z | 2021-11-26T11:42:08.000Z | SCANVariants/other-projects/dbscan-v1.0.0/parallel_mpi/dbscan.cpp | CheYulin/ScanOptimizing | 691b39309da1c6b5df46b264b5a300a35d644f70 | [
"MIT"
] | 2 | 2020-08-15T05:00:16.000Z | 2021-11-16T06:09:42.000Z | SCANVariants/other-projects/dbscan-v1.0.0/parallel_mpi/dbscan.cpp | CheYulin/ScanOptimizing | 691b39309da1c6b5df46b264b5a300a35d644f70 | [
"MIT"
] | 9 | 2018-12-20T10:09:00.000Z | 2021-11-26T11:42:10.000Z | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Files: mpi_main.cpp clusters.cpp clusters.h utils.h utils.cpp */
/* dbscan.cpp dbscan.h kdtree2.cpp kdtree2.hpp */
/* geometric_partitioning.h geometric_partitioning.cpp */
/* */
/* Description: an mpi implementation of dbscan clustering algorithm */
/* using the disjoint set data structure */
/* */
/* Author: Md. Mostofa Ali Patwary */
/* EECS Department, Northwestern University */
/* email: mpatwary@eecs.northwestern.edu */
/* */
/* Copyright, 2012, Northwestern University */
/* See COPYRIGHT notice in top-level directory. */
/* */
/* Please cite the following publication if you use this package */
/* */
/* Md. Mostofa Ali Patwary, Diana Palsetia, Ankit Agrawal, Wei-keng Liao, */
/* Fredrik Manne, and Alok Choudhary, "A New Scalable Parallel DBSCAN */
/* Algorithm Using the Disjoint Set Data Structure", Proceedings of the */
/* International Conference on High Performance Computing, Networking, */
/* Storage and Analysis (Supercomputing, SC'12), pp.62:1-62:11, 2012. */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "dbscan.h"
namespace NWUClustering
{
void ClusteringAlgo::set_dbscan_params(double eps, int minPts)
{
m_epsSquare = eps * eps;
m_minPts = minPts;
m_messages_per_round = -1; // always -1
m_compression = 0; // can set to 1 if want to compress specailly in the first round of communication
}
ClusteringAlgo::~ClusteringAlgo()
{
m_noise.clear();
m_visited.clear();
m_parents.clear();
m_parents_pr.clear();
m_child_count.clear();
m_corepoint.clear();
m_member.clear();
}
void ClusteringAlgo::trivial_decompression(vector <int>* data, int nproc, int rank, int round, double& dcomtime)
{
double start = MPI_Wtime();
vector <int> parser;
parser.reserve((*data).size());
parser = (*data);
(*data).clear();
int pid_count = parser[0], pos, i, j, pid, npid, npid_count;
pos++;
while(pid_count > 0)
{
pid = parser[pos++];
npid_count = parser[pos++];
for(j = 0; j < npid_count; j++)
{
(*data).push_back(pid);
(*data).push_back(parser[pos++]);
}
pid_count--;
}
parser.clear();
double stop = MPI_Wtime();
dcomtime += (stop - start);
}
void ClusteringAlgo::trivial_compression(vector <int>* data, vector < vector <int> >* parser, int nproc, int rank, int round, double& comtime, double& sum_comp_rate)
{
double start = MPI_Wtime();
double org = 0, comp = 0;
int pairs, pid, npid, i, j, pid_count, npid_count;
pairs = (*data).size()/2;
org = (*data).size();
for(i = 0; i < pairs; i++)
{
pid = (*data)[2 * i];
npid = (*data)[2 * i + 1];
(*parser)[pid].push_back(npid);
}
(*data).clear();
pid_count = 0;
(*data).push_back(pid_count); // uniques pids, should update later
for(i = 0; i < m_pts->m_i_num_points; i++)
{
npid_count = (*parser)[i].size();
if(npid_count > 0)
{
(*data).push_back(i);
(*data).push_back(npid_count);
for(j = 0; j < npid_count; j++)
(*data).push_back((*parser)[i][j]);
pid_count++;
(*parser)[i].clear();
}
}
(*data)[0] = pid_count;
comp = (*data).size();
double stop = MPI_Wtime();
comtime += (stop - start);
sum_comp_rate += (comp / org);
}
void ClusteringAlgo::convert(vector < vector <int> >* data, int nproc, int rank, int round)
{
int j, tid, size, pid, v1, v2, pairs, count;
vector < vector <int> > parser;
vector <int> init, verify;
int min, max;
for(tid = 0; tid < nproc; tid++)
{
pairs = (*data)[tid].size()/2;
verify.resize(2 * pairs, -1);
if(pairs == 0)
continue;
min = m_pts->m_i_num_points;
max = -1;
for(pid = 0; pid < pairs; pid++)
{
if((*data)[tid][2 * pid] < min)
min = (*data)[tid][2 * pid];
if((*data)[tid][2 * pid] > max)
max = (*data)[tid][2 * pid];
verify[2 * pid] = (*data)[tid][2 * pid];
verify[2 * pid + 1] = (*data)[tid][2 * pid + 1];
}
init.clear();
parser.resize(max - min + 1, init);
for(pid = 0; pid < pairs; pid++)
{
v2 = (*data)[tid].back();
(*data)[tid].pop_back();
v1 = (*data)[tid].back();
(*data)[tid].pop_back();
parser[v1 - min].push_back(v2);
}
count = 0;
(*data)[tid].push_back(-1); // insert local root count later
for(pid = min; pid <= max; pid++)
{
size = parser[pid - min].size();
if(size > 0)
{
count++;
(*data)[tid].push_back(pid);
(*data)[tid].push_back(size);
for(j = 0; j < size; j++)
{
(*data)[tid].push_back(parser[pid - min].back());
parser[pid - min].pop_back();
}
}
}
(*data)[tid][0] = count;
parser.clear();
count = (*data)[tid][0];
int k = 1, size, u = 0;
for(pid = 0; pid < count; pid++)
{
v2 = (*data)[tid][k++];
size = (*data)[tid][k++];
for(j = k; j < size; j++, k++)
{
v1 = (*data)[tid][k++];
if(v2 != verify[u++])
cout << "SOMETHING IS WRONG" << endl;
if(v1 != verify[u++])
cout << "SOMETHING IS WRONG" << endl;
}
}
}
}
void ClusteringAlgo::get_clusters_distributed()
{
int rank, nproc, i;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
// get the root all the local points first
// store in a message buffer in case need to ask other processors
vector < vector <int > > merge_received;
vector < vector <int > > merge_send1;
vector < vector <int > > merge_send2;
vector <int> init;
merge_received.resize(nproc, init);
merge_send1.resize(nproc, init);
merge_send2.resize(nproc, init);
int pid;
for(pid = 0; pid < nproc; pid++)
{
merge_received[pid].reserve(m_pts->m_i_num_points);
merge_send1[pid].reserve(m_pts->m_i_num_points);
merge_send2[pid].reserve(m_pts->m_i_num_points);
}
vector < vector <int > >* pswap;
vector < vector <int > >* p_cur_send;
vector < vector <int > >* p_cur_insert;
p_cur_send = &merge_send1;
p_cur_insert = &merge_send2;
m_child_count.reserve(m_pts->m_i_num_points);
m_child_count.resize(m_pts->m_i_num_points, 0);
int root, local_continue_to_run = 0, global_continue_to_run;
for(i = 0; i < m_pts->m_i_num_points; i++)
{
// find the point containing i
root = i;
while(m_parents_pr[root] == rank)
{
if(m_parents[root] == root)
break;
root = m_parents[root];
}
if(m_parents[root] == root && m_parents_pr[root] == rank) // root is a local root
{
// set the root of i directly to root
m_parents[i] = root;
m_child_count[root] = m_child_count[root] + 1; // increase the child count by one
//m_parents_pr[i] = rank; // NO NEED TO SET THIS AS IT
}
else
{
(*p_cur_insert)[m_parents_pr[root]].push_back(0); // flag: 0 means query and 1 means a reply
(*p_cur_insert)[m_parents_pr[root]].push_back(m_parents[root]);
(*p_cur_insert)[m_parents_pr[root]].push_back(i);
(*p_cur_insert)[m_parents_pr[root]].push_back(rank);
local_continue_to_run++;
}
}
// MAY BE REMOVED
//MPI_Barrier(MPI_COMM_WORLD);
int pos, round = 0, quadraples, scount, tid, tag = 0, rtag, rsource, rcount, isend[nproc], irecv[nproc], flag;
MPI_Request s_req_recv[nproc], s_req_send[nproc], d_req_send[nproc], d_req_recv[nproc]; // better to malloc the memory
MPI_Status s_stat, d_stat_send[nproc], d_stat;
int target_point, source_point, source_pr;
while(1)
{
global_continue_to_run = 0;
MPI_Allreduce(&local_continue_to_run, &global_continue_to_run, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if(global_continue_to_run == 0)
break;
pswap = p_cur_insert;
p_cur_insert = p_cur_send;
p_cur_send = pswap;
for(tid = 0; tid < nproc; tid++)
(*p_cur_insert)[tid].clear();
scount = 0;
for(tid = 0; tid < nproc; tid++)
{
isend[tid] = (*p_cur_send)[tid].size();
if(isend[tid] > 0)
{
MPI_Isend(&(*p_cur_send)[tid][0], isend[tid], MPI_INT, tid, tag + 1, MPI_COMM_WORLD, &d_req_send[scount]);
scount++;
}
}
MPI_Alltoall(&isend[0], 1, MPI_INT, &irecv[0], 1, MPI_INT, MPI_COMM_WORLD);
rcount = 0;
for(tid = 0; tid < nproc; tid++)
{
if(irecv[tid] > 0)
{
merge_received[tid].clear();
merge_received[tid].assign(irecv[tid], -1);
MPI_Irecv(&merge_received[tid][0], irecv[tid], MPI_INT, tid, tag + 1, MPI_COMM_WORLD, &d_req_recv[rcount]);
rcount++;
}
}
local_continue_to_run = 0;
for(tid = 0; tid < rcount; tid++)
{
MPI_Waitany(rcount, &d_req_recv[0], &pos, &d_stat);
rtag = d_stat.MPI_TAG;
rsource = d_stat.MPI_SOURCE;
if(rtag == tag + 1)
{
quadraples = merge_received[rsource].size()/4;
for(pid = 0; pid < quadraples; pid++)
{
// get the quadraple
source_pr = merge_received[rsource].back();
merge_received[rsource].pop_back();
source_point = merge_received[rsource].back();
merge_received[rsource].pop_back();
target_point = merge_received[rsource].back();
merge_received[rsource].pop_back();
flag = merge_received[rsource].back();
merge_received[rsource].pop_back();
if(flag == 0)
{
root = target_point;
while(m_parents_pr[root] == rank)
{
if(m_parents[root] == root)
break;
root = m_parents[root];
}
if(m_parents[root] == root && m_parents_pr[root] == rank) // root is a local root
{
m_child_count[root] = m_child_count[root] + 1; // increase the child count by one
// have to return the child about root
(*p_cur_insert)[source_pr].push_back(1);
(*p_cur_insert)[source_pr].push_back(source_point);
(*p_cur_insert)[source_pr].push_back(m_parents[root]);
(*p_cur_insert)[source_pr].push_back(m_parents_pr[root]);
local_continue_to_run++;
}
else
{
(*p_cur_insert)[m_parents_pr[root]].push_back(0);
(*p_cur_insert)[m_parents_pr[root]].push_back(m_parents[root]);
(*p_cur_insert)[m_parents_pr[root]].push_back(source_point);
(*p_cur_insert)[m_parents_pr[root]].push_back(source_pr);
local_continue_to_run++;
}
}
else
{
// got a reply, so just set the parent
m_parents[target_point] = source_point;
m_parents_pr[target_point] = source_pr;
}
}
}
}
tag++;
round++;
if(scount > 0)
MPI_Waitall(scount, &d_req_send[0], &d_stat_send[0]); // wait for all the sending operation
}
// MAY BE REMOVED
//MPI_Barrier(MPI_COMM_WORLD);
int final_cluster_root = 0, total_final_cluster_root = 0;
int points_in_cluster_final = 0, total_points_in_cluster_final = 0;
for(i = 0; i < m_pts->m_i_num_points; i++)
{
if(m_parents[i] == i && m_parents_pr[i] == rank && m_child_count[i] > 1)
{
points_in_cluster_final += m_child_count[i];
final_cluster_root++;
}
}
MPI_Allreduce(&points_in_cluster_final, &total_points_in_cluster_final, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&final_cluster_root, &total_final_cluster_root, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
int total_points = 0;
MPI_Allreduce(&m_pts->m_i_num_points, &total_points, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if(rank == proc_of_interest) cout << "Points in clusters " << total_points_in_cluster_final << " Noise " << total_points - total_points_in_cluster_final << " Total points " << total_points << endl;
if(rank == proc_of_interest) cout << "Total number of clusters " << total_final_cluster_root << endl;
vector<int> global_roots;
global_roots.resize(nproc, 0);
MPI_Allgather(&final_cluster_root, sizeof(int), MPI_BYTE, &global_roots[0], sizeof(int), MPI_BYTE, MPI_COMM_WORLD);
int cluster_offset = 0;
for(i = 0; i <= rank; i++)
cluster_offset += global_roots[i];
m_pid_to_cid.clear();
m_pid_to_cid.resize(m_pts->m_i_num_points, -1);
// assign for the global roots only
for(i = 0; i < m_pts->m_i_num_points; i++)
{
if(m_parents[i] == i && m_parents_pr[i] == rank)
{
if(m_child_count[i] > 1)
{
m_pid_to_cid[i] = cluster_offset;
cluster_offset++;
}
else
m_pid_to_cid[i] = 0; // noise point
}
}
for(i = 0; i < m_pts->m_i_num_points; i++)
{
if(m_parents_pr[i] == rank)
{
if(m_parents[i] != i) //skip the noise points
{
m_pid_to_cid[i] = m_pid_to_cid[m_parents[i]];
}
}
else
{
// ask the outer to to send back the clusterID
(*p_cur_insert)[m_parents_pr[i]].push_back(0);
(*p_cur_insert)[m_parents_pr[i]].push_back(m_parents[i]);
(*p_cur_insert)[m_parents_pr[i]].push_back(i);
(*p_cur_insert)[m_parents_pr[i]].push_back(rank);
}
}
// MAY BE REMOVED
//MPI_Barrier(MPI_COMM_WORLD);
tag++;
int later_count;
for(later_count = 0; later_count < 2; later_count++)
{
pswap = p_cur_insert;
p_cur_insert = p_cur_send;
p_cur_send = pswap;
for(tid = 0; tid < nproc; tid++)
(*p_cur_insert)[tid].clear();
scount = 0;
for(tid = 0; tid < nproc; tid++)
{
isend[tid] = (*p_cur_send)[tid].size();
if(isend[tid] > 0)
{
MPI_Isend(&(*p_cur_send)[tid][0], isend[tid], MPI_INT, tid, tag + 1, MPI_COMM_WORLD, &d_req_send[scount]);
scount++;
}
}
MPI_Alltoall(&isend[0], 1, MPI_INT, &irecv[0], 1, MPI_INT, MPI_COMM_WORLD);
rcount = 0;
for(tid = 0; tid < nproc; tid++)
{
if(irecv[tid] > 0)
{
merge_received[tid].clear();
merge_received[tid].assign(irecv[tid], -1);
MPI_Irecv(&merge_received[tid][0], irecv[tid], MPI_INT, tid, tag + 1, MPI_COMM_WORLD, &d_req_recv[rcount]);
rcount++;
}
}
for(tid = 0; tid < rcount; tid++)
{
MPI_Waitany(rcount, &d_req_recv[0], &pos, &d_stat);
rtag = d_stat.MPI_TAG;
rsource = d_stat.MPI_SOURCE;
if(rtag == tag + 1)
{
quadraples = merge_received[rsource].size()/4;
for(pid = 0; pid < quadraples; pid++)
{
// get the quadraple
source_pr = merge_received[rsource].back();
merge_received[rsource].pop_back();
source_point = merge_received[rsource].back();
merge_received[rsource].pop_back();
target_point = merge_received[rsource].back();
merge_received[rsource].pop_back();
flag = merge_received[rsource].back();
merge_received[rsource].pop_back();
if(flag == 0)
{
(*p_cur_insert)[source_pr].push_back(1);
(*p_cur_insert)[source_pr].push_back(source_point);
(*p_cur_insert)[source_pr].push_back(m_pid_to_cid[m_parents[target_point]]);
(*p_cur_insert)[source_pr].push_back(-1); // One extra INT, may be needed in future
}
else
{
// got a reply, so just set the parent
m_pid_to_cid[target_point] = source_point; // this assigns the clusterID
}
}
}
}
if(scount > 0)
MPI_Waitall(scount, &d_req_send[0], &d_stat_send[0]); // wait for all the sending operation
//MPI_Barrier(MPI_COMM_WORLD); // MAY NEED TO ACTIVATE THIS
tag++;
}
merge_received.clear();
merge_send1.clear();
merge_send2.clear();
init.clear();
global_roots.clear();
}
void ClusteringAlgo::writeCluster_distributed(string outfilename)
{
int rank, nproc;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
int i;
// get the total number of points
int total_points = 0;
MPI_Allreduce(&m_pts->m_i_num_points, &total_points, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
vector<int> point_count;
point_count.resize(nproc, 0);
MPI_Allgather(&m_pts->m_i_num_points, sizeof(int), MPI_BYTE, &point_count[0], sizeof(int), MPI_BYTE, MPI_COMM_WORLD);
int ret, ncfile;
string outfilename_dis = outfilename;
outfilename_dis = outfilename_dis; //"_clusters.nc";
// create the file, if exists, open the file.
ret = ncmpi_create(MPI_COMM_WORLD, outfilename_dis.c_str(), NC_CLOBBER, MPI_INFO_NULL, &ncfile);
if (ret != NC_NOERR)
{
handle_error(ret, __LINE__);
return;
}
MPI_Offset num_particles = total_points;
int num_particles_id;
ret = ncmpi_def_dim(ncfile, "num_particles", num_particles, &num_particles_id);
if (ret != NC_NOERR)
{
handle_error(ret, __LINE__);
return;
}
string column_name_initial = "position_col_X";
stringstream column_name_id;
string column_name;
int j, ncolumn = 1, col_id = 0, varid[m_pts->m_i_dims + 1]; //number of column is 1, col_id is 0 as we use the first one
// write the columns
for(j = 0; j < m_pts->m_i_dims; j++)
{
column_name_id.str("");
column_name_id << j;
column_name = column_name_initial + column_name_id.str();
ret = ncmpi_def_var(ncfile, column_name.c_str(), NC_FLOAT, ncolumn, &col_id, &varid[j]);
if (ret != NC_NOERR)
{
handle_error(ret, __LINE__);
return;
}
}
column_name = "cluster_id";
ret = ncmpi_def_var(ncfile, column_name.c_str(), NC_INT, ncolumn, &col_id, &varid[j]);
if (ret != NC_NOERR)
{
handle_error(ret, __LINE__);
return;
}
ret = ncmpi_enddef(ncfile);
if (ret != NC_NOERR)
{
handle_error(ret, __LINE__);
return;
}
MPI_Offset start[2], count[2];
start[0] = 0;
for(i = 0; i < rank; i++)
{
start[0] += point_count[i];
}
count[0] = point_count[rank];
start[1] = 0; // this to satisfy PnetCDF requirement
count[1] = 1;//dim_sizes[dimids[1]];
// allocate memory
float *data = new float[count[0] * count[1]];
// write the data columns
for(j = 0; j < m_pts->m_i_dims; j++)
{
// get the partial column data
for(i = 0; i < m_pts->m_i_num_points; i++)
data[i] = m_pts->m_points[i][j];
// write the data
ret = ncmpi_put_vara_float_all(ncfile, varid[j], start, count, data);
if (ret != NC_NOERR)
{
handle_error(ret, __LINE__);
return;
}
}
delete [] data;
int *data_id = new int[count[0] * count[1]];
//write the cluster_ids
for(i = 0; i < m_pts->m_i_num_points; i++)
data_id[i] = m_pid_to_cid[i];
ret = ncmpi_put_vara_int_all(ncfile, varid[m_pts->m_i_dims], start, count, data_id);
if (ret != NC_NOERR)
{
handle_error(ret, __LINE__);
return;
}
delete [] data_id;
// close the file
ret = ncmpi_close(ncfile);
if (ret != NC_NOERR)
{
handle_error(ret, __LINE__);
return;
}
//cout << "rank " << rank << " AT the end of wrting PnetCDF file" << endl;
}
void run_dbscan_algo_uf_mpi_interleaved(ClusteringAlgo& dbs)
{
double start = MPI_Wtime();
int i, pid, j, k, npid, prID;
int rank, nproc, mpi_namelen;
kdtree2_result_vector ne;
kdtree2_result_vector ne_outer;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
// initialize some parameters
dbs.m_clusters.clear();
// assign parent to itestf
dbs.m_parents.resize(dbs.m_pts->m_i_num_points, -1);
dbs.m_parents_pr.resize(dbs.m_pts->m_i_num_points, -1);
int total_points = 0, points_per_pr[nproc], start_pos[nproc];
// getting the total number of local points and assigning postions
MPI_Allgather(&dbs.m_pts->m_i_num_points, 1, MPI_INT, &points_per_pr[0], 1, MPI_INT, MPI_COMM_WORLD);
for(i = 0; i < nproc; i++)
{
start_pos[i] = total_points;
total_points += points_per_pr[i];
}
// assign proc IDs
vector <int> vec_prID;
vec_prID.resize(total_points, -1);
k = 0;
for(i = 0; i < nproc; i++)
{
for(j = 0; j < points_per_pr[i]; j++)
{
vec_prID[k++] = i;
}
}
// restting the membership and corepoints values
dbs.m_member.resize(dbs.m_pts->m_i_num_points, 0);
dbs.m_corepoint.resize(dbs.m_pts->m_i_num_points, 0);
vector<int>* ind = dbs.m_kdtree->getIndex();
vector<int>* ind_outer = dbs.m_kdtree_outer->getIndex();
// setting paretns to itself and corresponding proc IDs
for(i = 0; i < dbs.m_pts->m_i_num_points; i++)
{
pid = (*ind)[i];
dbs.m_parents[pid] = pid;
dbs.m_parents_pr[pid] = rank;
}
vector < vector <int > > merge_received;
vector < vector <int > > merge_send1;
vector < vector <int > > merge_send2;
vector <int> init;
int rtag, rsource, tag = 0, pos = 0, scount, rcount, isend[nproc], irecv[nproc];
merge_received.resize(nproc, init);
merge_send1.resize(nproc, init);
merge_send2.resize(nproc, init);
// reserving communication buffer memory
for(pid = 0; pid < nproc; pid++)
{
merge_received[pid].reserve(dbs.m_pts->m_i_num_points * nproc);
merge_send1[pid].reserve(dbs.m_pts->m_i_num_points * nproc);
merge_send2[pid].reserve(dbs.m_pts->m_i_num_points * nproc);
}
int root, root1, root2, tid;
vector < vector <int > >* pswap;
vector < vector <int > >* p_cur_send;
vector < vector <int > >* p_cur_insert;
p_cur_send = &merge_send1;
p_cur_insert = &merge_send2;
if(rank == proc_of_interest) cout << "Init time " << MPI_Wtime() - start << endl;
MPI_Barrier(MPI_COMM_WORLD);
// the main part of the DBSCAN algorithm (called local computation)
start = MPI_Wtime();
for(i = 0; i < dbs.m_pts->m_i_num_points; i++)
{
pid = (*ind)[i];
// getting the local neighborhoods of local point
ne.clear();
dbs.m_kdtree->r_nearest_around_point(pid, 0, dbs.m_epsSquare, ne);
ne_outer.clear();
vector<float> qv(dbs.m_pts->m_i_dims);
for (int u = 0; u < dbs.m_pts->m_i_dims; u++)
qv[u] = dbs.m_kdtree->the_data[pid][u];
// getting the remote neighborhood of the local point
if(dbs.m_pts_outer->m_i_num_points > 0)
dbs.m_kdtree_outer->r_nearest(qv, dbs.m_epsSquare, ne_outer);
qv.clear();
if(ne.size() + ne_outer.size() >= dbs.m_minPts)
{
// pid is a core point
root = pid;
dbs.m_corepoint[pid] = 1;
dbs.m_member[pid] = 1;
// traverse the rmote neighbors and add in the communication buffers
for(j = 0; j < ne_outer.size(); j++)
{
npid = ne_outer[j].idx;
(*p_cur_insert)[dbs.m_pts_outer->m_prIDs[npid]].push_back(pid);
(*p_cur_insert)[dbs.m_pts_outer->m_prIDs[npid]].push_back(dbs.m_pts_outer->m_ind[npid]);
}
//traverse the local neighbors and perform union operation
for (j = 0; j < ne.size(); j++)
{
npid = ne[j].idx;
// get the root containing npid
root1 = npid;
root2 = root;
if(dbs.m_corepoint[npid] == 1 || dbs.m_member[npid] == 0)
{
dbs.m_member[npid] = 1;
// REMS algorithm to (union) merge the trees
while(dbs.m_parents[root1] != dbs.m_parents[root2])
{
if(dbs.m_parents[root1] < dbs.m_parents[root2])
{
if(dbs.m_parents[root1] == root1)
{
dbs.m_parents[root1] = dbs.m_parents[root2];
root = dbs.m_parents[root2];
break;
}
// splicing comression technique
int z = dbs.m_parents[root1];
dbs.m_parents[root1] = dbs.m_parents[root2];
root1 = z;
}
else
{
if(dbs.m_parents[root2] == root2)
{
dbs.m_parents[root2] = dbs.m_parents[root1];
root = dbs.m_parents[root1];
break;
}
// splicing compressio technique
int z = dbs.m_parents[root2];
dbs.m_parents[root2] = dbs.m_parents[root1];
root2 = z;
}
}
}
}
}
}
MPI_Barrier(MPI_COMM_WORLD);
int v1, v2, par_proc, triples, local_count, global_count;
double temp_inter_med, inter_med, stop = MPI_Wtime();
if(rank == proc_of_interest) cout << "Local computation took " << stop - start << endl;
inter_med = MPI_Wtime();
start = stop;
i = 0;
MPI_Request s_req_recv[nproc], s_req_send[nproc], d_req_send[nproc], d_req_recv[nproc]; // better to malloc the memory
MPI_Status s_stat, d_stat_send[nproc], d_stat;
start = MPI_Wtime();
local_count = 0;
// performing additional compression for the local points that are being sent
// this steps identifies the points that actually going to connect the trees in other processors
// this step will eventually helps further compression before the actual communication happens
for(tid = 0; tid < nproc; tid++)
{
triples = (*p_cur_insert)[tid].size()/2;
local_count += triples;
for(pid = 0; pid < triples; pid++)
{
v1 = (*p_cur_insert)[tid][2 * pid];
root1 = v1;
while(dbs.m_parents[root1] != root1)
root1 = dbs.m_parents[root1];
while(dbs.m_parents[v1] != root1)
{
int tmp = dbs.m_parents[v1];
dbs.m_parents[v1] = root1;
v1 = tmp;
}
(*p_cur_insert)[tid][2 * pid] = root1;
}
}
local_count = local_count/nproc;
global_count = 0;
MPI_Allreduce(&local_count, &global_count, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
//message_per_round
int uv, uf, um, ul, ucount;
int local_continue_to_run, global_continue_to_run;
double dcomtime = 0, comtime = 0, sum_comp_rate = 0;
vector <vector <int> > parser;
vector <int> init_ex;
parser.resize(dbs.m_pts->m_i_num_points, init_ex);
while(1)
{
pswap = p_cur_insert;
p_cur_insert = p_cur_send;
p_cur_send = pswap;
for(tid = 0; tid < nproc; tid++)
(*p_cur_insert)[tid].clear();
// Uncommend the following if you want to compress in the first round, where compression ratio could be high
//if(dbs.m_compression == 1 && i == 0)
//{
// dbs.trivial_compression(p_cur_send, &parser, nproc, rank, i, comtime, sum_comp_rate);
//}
// send all the data
// compress the data before send
//dbs.convert(p_cur_send, nproc, rank, i);
scount = 0;
for(tid = 0; tid < nproc; tid++)
{
if(dbs.m_compression == 1 && i == 0 && (*p_cur_send)[tid].size() > 0)
{
dbs.trivial_compression(&(*p_cur_send)[tid], &parser, nproc, rank, i, comtime, sum_comp_rate);
}
isend[tid] = (*p_cur_send)[tid].size();
if(isend[tid] > 0)
{
MPI_Isend(&(*p_cur_send)[tid][0], isend[tid], MPI_INT, tid, tag + 1, MPI_COMM_WORLD, &d_req_send[scount]);
scount++;
}
}
MPI_Alltoall(&isend[0], 1, MPI_INT, &irecv[0], 1, MPI_INT, MPI_COMM_WORLD);
rcount = 0;
for(tid = 0; tid < nproc; tid++)
{
if(irecv[tid] > 0)
{
merge_received[tid].clear();
merge_received[tid].assign(irecv[tid], -1);
MPI_Irecv(&merge_received[tid][0], irecv[tid], MPI_INT, tid, tag + 1, MPI_COMM_WORLD, &d_req_recv[rcount]);
rcount++;
}
}
local_count = 0;
//get the data and process them
for(tid = 0; tid < rcount; tid++)
{
MPI_Waitany(rcount, &d_req_recv[0], &pos, &d_stat);
rtag = d_stat.MPI_TAG;
rsource = d_stat.MPI_SOURCE;
if(rtag == tag + 1)
{
// process received the data now
if(dbs.m_messages_per_round == -1 && i == 0)
{
if(dbs.m_compression == 1)
{
// call the decompression function
dbs.trivial_decompression(&merge_received[rsource], nproc, rank, i, dcomtime);
triples = merge_received[rsource].size()/2;
par_proc = rsource;
}
else
{
triples = merge_received[rsource].size()/2;
par_proc = rsource;
}
}
else
triples = merge_received[rsource].size()/3;
for(pid = 0; pid < triples; pid++)
{
// get the pair
v1 = merge_received[rsource].back();
merge_received[rsource].pop_back();
if((dbs.m_messages_per_round == -1 && i > 0) || (dbs.m_messages_per_round != -1))
{
par_proc = merge_received[rsource].back();
merge_received[rsource].pop_back();
}
v2 = merge_received[rsource].back();
merge_received[rsource].pop_back();
int con = 0;
if(i > 0)
con = 1;
else if (i == 0 && (dbs.m_corepoint[v1] == 1 || dbs.m_member[v1] == 0))
{
dbs.m_member[v1] = 1;
con = 1;
}
if(con == 1)
{
root1 = v1;
// this will find the boundary vertex or the root if the root is in this processor
while(dbs.m_parents_pr[root1] == rank)
{
if(dbs.m_parents[root1] == root1)
break;
root1 = dbs.m_parents[root1];
}
// compress the local path
while(v1 != root1 && vec_prID[v1] == rank)
{
int tmp = dbs.m_parents[v1];
dbs.m_parents[v1] = root1;
v1 = tmp;
}
if(dbs.m_parents[root1] == v2 && dbs.m_parents_pr[root1] == par_proc)
{
//same_set++;
continue;
}
if(par_proc == rank)
{
if(dbs.m_parents[root1] == dbs.m_parents[v2])
continue;
}
if(dbs.m_parents[root1] == root1 && dbs.m_parents_pr[root1] == rank) // root1 is a local root
{
if(start_pos[rank] + root1 < start_pos[par_proc] + v2)
{
// do union
dbs.m_parents[root1] = v2;
dbs.m_parents_pr[root1] = par_proc;
continue;
}
else
{
// ask the parent of v2
(*p_cur_insert)[par_proc].push_back(root1);
(*p_cur_insert)[par_proc].push_back(dbs.m_parents_pr[root1]);
(*p_cur_insert)[par_proc].push_back(v2);
local_count++;
}
}
else
{
// root1 is not local
if(start_pos[dbs.m_parents_pr[root1]] + root1 < start_pos[par_proc] + v2)
{
// ask the parent of root1
(*p_cur_insert)[dbs.m_parents_pr[root1]].push_back(v2);
(*p_cur_insert)[dbs.m_parents_pr[root1]].push_back(par_proc);
(*p_cur_insert)[dbs.m_parents_pr[root1]].push_back(dbs.m_parents[root1]);
local_count++;
}
else
{
// ask the parent of v2
(*p_cur_insert)[par_proc].push_back(dbs.m_parents[root1]);
(*p_cur_insert)[par_proc].push_back(dbs.m_parents_pr[root1]);
(*p_cur_insert)[par_proc].push_back(v2);
local_count++;
}
}
}
}
merge_received[rsource].clear();
}
else
{
cout << "rank " << rank << " SOMETHING IS WRONG" << endl;
}
}
if(scount > 0)
MPI_Waitall(scount, &d_req_send[0], &d_stat_send[0]);
tag += 2; // change the tag value although not important
local_continue_to_run = 0;
local_count = 0;
for(tid = 0; tid < nproc; tid++)
{
local_count += (*p_cur_insert)[tid].size()/3;
if((*p_cur_insert)[tid].size() > 0)
local_continue_to_run = 1;
}
local_count = local_count / nproc;
global_count = 0;
global_continue_to_run = 0;
MPI_Allreduce(&local_continue_to_run, &global_continue_to_run, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if(global_continue_to_run == 0)
break;
i++;
}
stop = MPI_Wtime();
if(rank == proc_of_interest) cout << "Merging took " << stop - start << endl;
pswap = NULL;
p_cur_insert = NULL;
p_cur_send = NULL;
for(tid = 0; tid < nproc; tid++)
{
merge_received[tid].clear();
merge_send1[tid].clear();
merge_send2[tid].clear();
}
merge_received.clear();
merge_send1.clear();
merge_send2.clear();
ind = NULL;
ind_outer = NULL;
vec_prID.clear();
ne.clear();
ne_outer.clear();
parser.clear();
init_ex.clear();
init.clear();
}
};
| 29.079035 | 207 | 0.543988 | [
"vector"
] |
3d6b2391fb8edaa61ac3a0219f44199bf9ef7b53 | 6,178 | cpp | C++ | worldeditor/src/managers/toolwindowmanager/qtoolwindowmanagerwrapper.cpp | weblate/thunder | e9b741b7f23e18cea79cee964c8a62ed9248fbf2 | [
"Apache-2.0"
] | 1 | 2022-03-20T16:13:53.000Z | 2022-03-20T16:13:53.000Z | worldeditor/src/managers/toolwindowmanager/qtoolwindowmanagerwrapper.cpp | weblate/thunder | e9b741b7f23e18cea79cee964c8a62ed9248fbf2 | [
"Apache-2.0"
] | null | null | null | worldeditor/src/managers/toolwindowmanager/qtoolwindowmanagerwrapper.cpp | weblate/thunder | e9b741b7f23e18cea79cee964c8a62ed9248fbf2 | [
"Apache-2.0"
] | null | null | null | /****************************************************************************
**
** Copyright (C) 2014 Pavel Strakhov <ri@idzaaus.org>
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in all
** copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QBoxLayout>
#include <qevent.h>
#include <qapplication.h>
#include <qsplitter.h>
#include "qtoolwindowmanager.h"
#include "qabstracttoolwindowmanagerarea.h"
#include "private/qtoolwindowmanager_p.h"
#include "private/qtoolwindowmanagerwrapper_p.h"
QToolWindowManagerWrapper::QToolWindowManagerWrapper(QToolWindowManager *manager) :
QWidget(manager),
m_manager(manager)
{
setWindowFlags(windowFlags() | Qt::Window);
setWindowTitle(QLatin1String(" "));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
QToolWindowManagerPrivate * const manager_d = m_manager->d_func();
manager_d->m_wrappers << this;
}
QToolWindowManagerWrapper::~QToolWindowManagerWrapper()
{
QToolWindowManagerPrivate * const manager_d = m_manager->d_func();
manager_d->m_wrappers.removeOne(this);
}
void QToolWindowManagerWrapper::closeEvent(QCloseEvent *)
{
QList<QWidget*> toolWindows;
foreach (QAbstractToolWindowManagerArea *tabWidget, findChildren<QAbstractToolWindowManagerArea *>())
toolWindows << tabWidget->toolWindows();
m_manager->moveToolWindows(toolWindows, QToolWindowManager::NoArea);
}
QVariantMap QToolWindowManagerWrapper::saveState() const
{
if (layout()->count() > 1) {
qWarning("too many children for wrapper");
return QVariantMap();
}
if (isWindow() && layout()->count() == 0) {
qWarning("empty top level wrapper");
return QVariantMap();
}
QVariantMap result;
result[QLatin1String("geometry")] = saveGeometry();
QSplitter *splitter = findChild<QSplitter*>();
QToolWindowManagerPrivate * const manager_d = m_manager->d_func();
if (splitter) {
result[QLatin1String("splitter")] = manager_d->saveSplitterState(splitter);
} else {
QAbstractToolWindowManagerArea *area = findChild<QAbstractToolWindowManagerArea *>();
if (area) {
result[QLatin1String("area")] = manager_d->saveAreaState(area);
} else if (layout()->count() > 0) {
qWarning("unknown child");
return QVariantMap();
}
}
return result;
}
void QToolWindowManagerWrapper::restoreState(const QVariantMap &data)
{
restoreGeometry(data[QLatin1String("geometry")].toByteArray());
if (layout()->count() > 0) {
for(int i = 0; i < layout()->count(); i++) {
QSplitter *invalidSplitter = qobject_cast<QSplitter *>(layout()->itemAt(i)->widget());
if(invalidSplitter) {
invalidSplitter->hide();
invalidSplitter->setParent(nullptr);
invalidSplitter->deleteLater();
}
}
}
QToolWindowManagerPrivate *const manager_d = m_manager->d_func();
if (data.contains(QLatin1String("splitter"))) {
layout()->addWidget(manager_d->restoreSplitterState(data[QLatin1String("splitter")].toMap()));
} else if (data.contains(QLatin1String("area"))) {
layout()->addWidget(manager_d->restoreAreaState(data[QLatin1String("area")].toMap()));
}
}
| 42.315068 | 105 | 0.69877 | [
"geometry"
] |
3d6c55ad32d2537cd0d4a6b50cedf176c65d306e | 3,150 | hpp | C++ | bithorded/server/server.hpp | zidz/bithorde | dbaa67eb0ddfa7d28e5325d87428c1b0225d598b | [
"Apache-2.0"
] | null | null | null | bithorded/server/server.hpp | zidz/bithorde | dbaa67eb0ddfa7d28e5325d87428c1b0225d598b | [
"Apache-2.0"
] | null | null | null | bithorded/server/server.hpp | zidz/bithorde | dbaa67eb0ddfa7d28e5325d87428c1b0225d598b | [
"Apache-2.0"
] | null | null | null | /*
Copyright 2012 Ulrik Mikaelsson <ulrik.mikaelsson@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef BITHORDED_SERVER_H
#define BITHORDED_SERVER_H
#include <list>
#include <memory>
#include <vector>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/local/stream_protocol.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/smart_ptr/scoped_ptr.hpp>
#include "../cache/manager.hpp"
#include "../http_server/server.hpp"
#include "../lib/management.hpp"
#include "../lib/grandcentraldispatch.hpp"
#include "../router/router.hpp"
#include "../source/store.hpp"
#include "bithorde.pb.h"
#include "client.hpp"
namespace bithorded {
struct Config;
class BindError : public std::runtime_error {
public:
bithorde::Status status;
explicit BindError(bithorde::Status status);
};
class ConnectionList : public WeakMap<std::string, bithorded::Client>, public management::DescriptiveDirectory {
virtual void inspect(management::InfoList& target) const;
virtual void describe(management::Info& target) const;
};
class Server : public GrandCentralDispatch, public management::Directory
{
Config &_cfg;
TimerService::Ptr _timerSvc;
boost::asio::ip::tcp::acceptor _tcpListener;
boost::asio::local::stream_protocol::acceptor _localListener;
ConnectionList _connections;
std::vector< std::unique_ptr<bithorded::source::Store> > _assetStores;
router::Router _router;
cache::CacheManager _cache;
std::unique_ptr<http::server::server> _httpInterface;
public:
Server(boost::asio::io_service& ioSvc, Config& cfg);
std::string name() { return _cfg.nodeName; }
const Config::Client& getClientConfig(const std::string& name);
UpstreamRequestBinding::Ptr async_linkAsset(const boost::filesystem::path& filePath);
UpstreamRequestBinding::Ptr async_findAsset(const bithorde::BindRead& req);
UpstreamRequestBinding::Ptr prepareUpload(uint64_t size);
void hookup(boost::shared_ptr< boost::asio::ip::tcp::socket >& socket, const Config::Client& client);
virtual void inspect(management::InfoList& target) const;
private:
void clientConnected(const bithorded::Client::Ptr& client);
void clientAuthenticated(const bithorded::Client::WeakPtr& client);
void clientDisconnected(bithorded::Client::Ptr& client);
void waitForTCPConnection();
void waitForLocalConnection();
void onTCPConnected(boost::shared_ptr< boost::asio::ip::tcp::socket >& socket, const boost::system::error_code& ec);
void onLocalConnected(boost::shared_ptr< boost::asio::local::stream_protocol::socket >& socket, const boost::system::error_code& ec);
};
}
#endif // BITHORDED_SERVER_H
| 33.157895 | 134 | 0.762222 | [
"vector"
] |
3d773f345264ac895692afb23a589c8802733c1f | 34,414 | hpp | C++ | ThirdParty-mod/java2cpp/android/telephony/TelephonyManager.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | 1 | 2019-04-03T01:53:28.000Z | 2019-04-03T01:53:28.000Z | ThirdParty-mod/java2cpp/android/telephony/TelephonyManager.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | null | null | null | ThirdParty-mod/java2cpp/android/telephony/TelephonyManager.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | null | null | null | /*================================================================================
code generated by: java2cpp
author: Zoran Angelov, mailto://baldzar@gmail.com
class: android.telephony.TelephonyManager
================================================================================*/
#ifndef J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ANDROID_TELEPHONY_TELEPHONYMANAGER_HPP_DECL
#define J2CPP_ANDROID_TELEPHONY_TELEPHONYMANAGER_HPP_DECL
namespace j2cpp { namespace java { namespace lang { class Object; } } }
namespace j2cpp { namespace java { namespace lang { class String; } } }
namespace j2cpp { namespace java { namespace util { class List; } } }
namespace j2cpp { namespace android { namespace telephony { class PhoneStateListener; } } }
namespace j2cpp { namespace android { namespace telephony { class CellLocation; } } }
#include <android/telephony/CellLocation.hpp>
#include <android/telephony/PhoneStateListener.hpp>
#include <java/lang/Object.hpp>
#include <java/lang/String.hpp>
#include <java/util/List.hpp>
namespace j2cpp {
namespace android { namespace telephony {
class TelephonyManager;
class TelephonyManager
: public object<TelephonyManager>
{
public:
J2CPP_DECLARE_CLASS
J2CPP_DECLARE_METHOD(0)
J2CPP_DECLARE_METHOD(1)
J2CPP_DECLARE_METHOD(2)
J2CPP_DECLARE_METHOD(3)
J2CPP_DECLARE_METHOD(4)
J2CPP_DECLARE_METHOD(5)
J2CPP_DECLARE_METHOD(6)
J2CPP_DECLARE_METHOD(7)
J2CPP_DECLARE_METHOD(8)
J2CPP_DECLARE_METHOD(9)
J2CPP_DECLARE_METHOD(10)
J2CPP_DECLARE_METHOD(11)
J2CPP_DECLARE_METHOD(12)
J2CPP_DECLARE_METHOD(13)
J2CPP_DECLARE_METHOD(14)
J2CPP_DECLARE_METHOD(15)
J2CPP_DECLARE_METHOD(16)
J2CPP_DECLARE_METHOD(17)
J2CPP_DECLARE_METHOD(18)
J2CPP_DECLARE_METHOD(19)
J2CPP_DECLARE_METHOD(20)
J2CPP_DECLARE_METHOD(21)
J2CPP_DECLARE_METHOD(22)
J2CPP_DECLARE_METHOD(23)
J2CPP_DECLARE_METHOD(24)
J2CPP_DECLARE_METHOD(25)
J2CPP_DECLARE_FIELD(0)
J2CPP_DECLARE_FIELD(1)
J2CPP_DECLARE_FIELD(2)
J2CPP_DECLARE_FIELD(3)
J2CPP_DECLARE_FIELD(4)
J2CPP_DECLARE_FIELD(5)
J2CPP_DECLARE_FIELD(6)
J2CPP_DECLARE_FIELD(7)
J2CPP_DECLARE_FIELD(8)
J2CPP_DECLARE_FIELD(9)
J2CPP_DECLARE_FIELD(10)
J2CPP_DECLARE_FIELD(11)
J2CPP_DECLARE_FIELD(12)
J2CPP_DECLARE_FIELD(13)
J2CPP_DECLARE_FIELD(14)
J2CPP_DECLARE_FIELD(15)
J2CPP_DECLARE_FIELD(16)
J2CPP_DECLARE_FIELD(17)
J2CPP_DECLARE_FIELD(18)
J2CPP_DECLARE_FIELD(19)
J2CPP_DECLARE_FIELD(20)
J2CPP_DECLARE_FIELD(21)
J2CPP_DECLARE_FIELD(22)
J2CPP_DECLARE_FIELD(23)
J2CPP_DECLARE_FIELD(24)
J2CPP_DECLARE_FIELD(25)
J2CPP_DECLARE_FIELD(26)
J2CPP_DECLARE_FIELD(27)
J2CPP_DECLARE_FIELD(28)
J2CPP_DECLARE_FIELD(29)
J2CPP_DECLARE_FIELD(30)
J2CPP_DECLARE_FIELD(31)
J2CPP_DECLARE_FIELD(32)
J2CPP_DECLARE_FIELD(33)
J2CPP_DECLARE_FIELD(34)
J2CPP_DECLARE_FIELD(35)
J2CPP_DECLARE_FIELD(36)
J2CPP_DECLARE_FIELD(37)
explicit TelephonyManager(jobject jobj)
: object<TelephonyManager>(jobj)
{
}
operator local_ref<java::lang::Object>() const;
local_ref< java::lang::String > getDeviceSoftwareVersion();
local_ref< java::lang::String > getDeviceId();
local_ref< android::telephony::CellLocation > getCellLocation();
local_ref< java::util::List > getNeighboringCellInfo();
jint getPhoneType();
local_ref< java::lang::String > getNetworkOperatorName();
local_ref< java::lang::String > getNetworkOperator();
jboolean isNetworkRoaming();
local_ref< java::lang::String > getNetworkCountryIso();
jint getNetworkType();
jboolean hasIccCard();
jint getSimState();
local_ref< java::lang::String > getSimOperator();
local_ref< java::lang::String > getSimOperatorName();
local_ref< java::lang::String > getSimCountryIso();
local_ref< java::lang::String > getSimSerialNumber();
local_ref< java::lang::String > getSubscriberId();
local_ref< java::lang::String > getLine1Number();
local_ref< java::lang::String > getVoiceMailNumber();
local_ref< java::lang::String > getVoiceMailAlphaTag();
jint getCallState();
jint getDataActivity();
jint getDataState();
void listen(local_ref< android::telephony::PhoneStateListener > const&, jint);
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(0), J2CPP_FIELD_SIGNATURE(0), local_ref< java::lang::String > > ACTION_PHONE_STATE_CHANGED;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(1), J2CPP_FIELD_SIGNATURE(1), local_ref< java::lang::String > > EXTRA_STATE;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(2), J2CPP_FIELD_SIGNATURE(2), local_ref< java::lang::String > > EXTRA_STATE_IDLE;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(3), J2CPP_FIELD_SIGNATURE(3), local_ref< java::lang::String > > EXTRA_STATE_RINGING;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(4), J2CPP_FIELD_SIGNATURE(4), local_ref< java::lang::String > > EXTRA_STATE_OFFHOOK;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(5), J2CPP_FIELD_SIGNATURE(5), local_ref< java::lang::String > > EXTRA_INCOMING_NUMBER;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(6), J2CPP_FIELD_SIGNATURE(6), jint > PHONE_TYPE_NONE;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(7), J2CPP_FIELD_SIGNATURE(7), jint > PHONE_TYPE_GSM;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(8), J2CPP_FIELD_SIGNATURE(8), jint > PHONE_TYPE_CDMA;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(9), J2CPP_FIELD_SIGNATURE(9), jint > NETWORK_TYPE_UNKNOWN;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(10), J2CPP_FIELD_SIGNATURE(10), jint > NETWORK_TYPE_GPRS;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(11), J2CPP_FIELD_SIGNATURE(11), jint > NETWORK_TYPE_EDGE;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(12), J2CPP_FIELD_SIGNATURE(12), jint > NETWORK_TYPE_UMTS;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(13), J2CPP_FIELD_SIGNATURE(13), jint > NETWORK_TYPE_CDMA;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(14), J2CPP_FIELD_SIGNATURE(14), jint > NETWORK_TYPE_EVDO_0;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(15), J2CPP_FIELD_SIGNATURE(15), jint > NETWORK_TYPE_EVDO_A;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(16), J2CPP_FIELD_SIGNATURE(16), jint > NETWORK_TYPE_1xRTT;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(17), J2CPP_FIELD_SIGNATURE(17), jint > NETWORK_TYPE_HSDPA;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(18), J2CPP_FIELD_SIGNATURE(18), jint > NETWORK_TYPE_HSUPA;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(19), J2CPP_FIELD_SIGNATURE(19), jint > NETWORK_TYPE_HSPA;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(20), J2CPP_FIELD_SIGNATURE(20), jint > SIM_STATE_UNKNOWN;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(21), J2CPP_FIELD_SIGNATURE(21), jint > SIM_STATE_ABSENT;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(22), J2CPP_FIELD_SIGNATURE(22), jint > SIM_STATE_PIN_REQUIRED;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(23), J2CPP_FIELD_SIGNATURE(23), jint > SIM_STATE_PUK_REQUIRED;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(24), J2CPP_FIELD_SIGNATURE(24), jint > SIM_STATE_NETWORK_LOCKED;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(25), J2CPP_FIELD_SIGNATURE(25), jint > SIM_STATE_READY;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(26), J2CPP_FIELD_SIGNATURE(26), jint > CALL_STATE_IDLE;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(27), J2CPP_FIELD_SIGNATURE(27), jint > CALL_STATE_RINGING;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(28), J2CPP_FIELD_SIGNATURE(28), jint > CALL_STATE_OFFHOOK;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(29), J2CPP_FIELD_SIGNATURE(29), jint > DATA_ACTIVITY_NONE;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(30), J2CPP_FIELD_SIGNATURE(30), jint > DATA_ACTIVITY_IN;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(31), J2CPP_FIELD_SIGNATURE(31), jint > DATA_ACTIVITY_OUT;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(32), J2CPP_FIELD_SIGNATURE(32), jint > DATA_ACTIVITY_INOUT;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(33), J2CPP_FIELD_SIGNATURE(33), jint > DATA_ACTIVITY_DORMANT;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(34), J2CPP_FIELD_SIGNATURE(34), jint > DATA_DISCONNECTED;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(35), J2CPP_FIELD_SIGNATURE(35), jint > DATA_CONNECTING;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(36), J2CPP_FIELD_SIGNATURE(36), jint > DATA_CONNECTED;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(37), J2CPP_FIELD_SIGNATURE(37), jint > DATA_SUSPENDED;
}; //class TelephonyManager
} //namespace telephony
} //namespace android
} //namespace j2cpp
#endif //J2CPP_ANDROID_TELEPHONY_TELEPHONYMANAGER_HPP_DECL
#else //J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ANDROID_TELEPHONY_TELEPHONYMANAGER_HPP_IMPL
#define J2CPP_ANDROID_TELEPHONY_TELEPHONYMANAGER_HPP_IMPL
namespace j2cpp {
android::telephony::TelephonyManager::operator local_ref<java::lang::Object>() const
{
return local_ref<java::lang::Object>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getDeviceSoftwareVersion()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(1),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(1),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getDeviceId()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(2),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(2),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< android::telephony::CellLocation > android::telephony::TelephonyManager::getCellLocation()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(3),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(3),
local_ref< android::telephony::CellLocation >
>(get_jobject());
}
local_ref< java::util::List > android::telephony::TelephonyManager::getNeighboringCellInfo()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(4),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(4),
local_ref< java::util::List >
>(get_jobject());
}
jint android::telephony::TelephonyManager::getPhoneType()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(5),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(5),
jint
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getNetworkOperatorName()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(6),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(6),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getNetworkOperator()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(7),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(7),
local_ref< java::lang::String >
>(get_jobject());
}
jboolean android::telephony::TelephonyManager::isNetworkRoaming()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(8),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(8),
jboolean
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getNetworkCountryIso()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(9),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(9),
local_ref< java::lang::String >
>(get_jobject());
}
jint android::telephony::TelephonyManager::getNetworkType()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(10),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(10),
jint
>(get_jobject());
}
jboolean android::telephony::TelephonyManager::hasIccCard()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(11),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(11),
jboolean
>(get_jobject());
}
jint android::telephony::TelephonyManager::getSimState()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(12),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(12),
jint
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getSimOperator()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(13),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(13),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getSimOperatorName()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(14),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(14),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getSimCountryIso()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(15),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(15),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getSimSerialNumber()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(16),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(16),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getSubscriberId()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(17),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(17),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getLine1Number()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(18),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(18),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getVoiceMailNumber()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(19),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(19),
local_ref< java::lang::String >
>(get_jobject());
}
local_ref< java::lang::String > android::telephony::TelephonyManager::getVoiceMailAlphaTag()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(20),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(20),
local_ref< java::lang::String >
>(get_jobject());
}
jint android::telephony::TelephonyManager::getCallState()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(21),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(21),
jint
>(get_jobject());
}
jint android::telephony::TelephonyManager::getDataActivity()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(22),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(22),
jint
>(get_jobject());
}
jint android::telephony::TelephonyManager::getDataState()
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(23),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(23),
jint
>(get_jobject());
}
void android::telephony::TelephonyManager::listen(local_ref< android::telephony::PhoneStateListener > const &a0, jint a1)
{
return call_method<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_METHOD_NAME(24),
android::telephony::TelephonyManager::J2CPP_METHOD_SIGNATURE(24),
void
>(get_jobject(), a0, a1);
}
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(0),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(0),
local_ref< java::lang::String >
> android::telephony::TelephonyManager::ACTION_PHONE_STATE_CHANGED;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(1),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(1),
local_ref< java::lang::String >
> android::telephony::TelephonyManager::EXTRA_STATE;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(2),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(2),
local_ref< java::lang::String >
> android::telephony::TelephonyManager::EXTRA_STATE_IDLE;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(3),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(3),
local_ref< java::lang::String >
> android::telephony::TelephonyManager::EXTRA_STATE_RINGING;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(4),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(4),
local_ref< java::lang::String >
> android::telephony::TelephonyManager::EXTRA_STATE_OFFHOOK;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(5),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(5),
local_ref< java::lang::String >
> android::telephony::TelephonyManager::EXTRA_INCOMING_NUMBER;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(6),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(6),
jint
> android::telephony::TelephonyManager::PHONE_TYPE_NONE;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(7),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(7),
jint
> android::telephony::TelephonyManager::PHONE_TYPE_GSM;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(8),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(8),
jint
> android::telephony::TelephonyManager::PHONE_TYPE_CDMA;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(9),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(9),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_UNKNOWN;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(10),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(10),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_GPRS;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(11),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(11),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_EDGE;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(12),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(12),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_UMTS;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(13),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(13),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_CDMA;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(14),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(14),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_EVDO_0;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(15),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(15),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_EVDO_A;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(16),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(16),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_1xRTT;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(17),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(17),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_HSDPA;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(18),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(18),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_HSUPA;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(19),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(19),
jint
> android::telephony::TelephonyManager::NETWORK_TYPE_HSPA;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(20),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(20),
jint
> android::telephony::TelephonyManager::SIM_STATE_UNKNOWN;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(21),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(21),
jint
> android::telephony::TelephonyManager::SIM_STATE_ABSENT;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(22),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(22),
jint
> android::telephony::TelephonyManager::SIM_STATE_PIN_REQUIRED;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(23),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(23),
jint
> android::telephony::TelephonyManager::SIM_STATE_PUK_REQUIRED;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(24),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(24),
jint
> android::telephony::TelephonyManager::SIM_STATE_NETWORK_LOCKED;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(25),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(25),
jint
> android::telephony::TelephonyManager::SIM_STATE_READY;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(26),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(26),
jint
> android::telephony::TelephonyManager::CALL_STATE_IDLE;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(27),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(27),
jint
> android::telephony::TelephonyManager::CALL_STATE_RINGING;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(28),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(28),
jint
> android::telephony::TelephonyManager::CALL_STATE_OFFHOOK;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(29),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(29),
jint
> android::telephony::TelephonyManager::DATA_ACTIVITY_NONE;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(30),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(30),
jint
> android::telephony::TelephonyManager::DATA_ACTIVITY_IN;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(31),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(31),
jint
> android::telephony::TelephonyManager::DATA_ACTIVITY_OUT;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(32),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(32),
jint
> android::telephony::TelephonyManager::DATA_ACTIVITY_INOUT;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(33),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(33),
jint
> android::telephony::TelephonyManager::DATA_ACTIVITY_DORMANT;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(34),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(34),
jint
> android::telephony::TelephonyManager::DATA_DISCONNECTED;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(35),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(35),
jint
> android::telephony::TelephonyManager::DATA_CONNECTING;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(36),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(36),
jint
> android::telephony::TelephonyManager::DATA_CONNECTED;
static_field<
android::telephony::TelephonyManager::J2CPP_CLASS_NAME,
android::telephony::TelephonyManager::J2CPP_FIELD_NAME(37),
android::telephony::TelephonyManager::J2CPP_FIELD_SIGNATURE(37),
jint
> android::telephony::TelephonyManager::DATA_SUSPENDED;
J2CPP_DEFINE_CLASS(android::telephony::TelephonyManager,"android/telephony/TelephonyManager")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,0,"<init>","()V")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,1,"getDeviceSoftwareVersion","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,2,"getDeviceId","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,3,"getCellLocation","()Landroid/telephony/CellLocation;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,4,"getNeighboringCellInfo","()Ljava/util/List;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,5,"getPhoneType","()I")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,6,"getNetworkOperatorName","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,7,"getNetworkOperator","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,8,"isNetworkRoaming","()Z")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,9,"getNetworkCountryIso","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,10,"getNetworkType","()I")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,11,"hasIccCard","()Z")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,12,"getSimState","()I")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,13,"getSimOperator","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,14,"getSimOperatorName","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,15,"getSimCountryIso","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,16,"getSimSerialNumber","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,17,"getSubscriberId","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,18,"getLine1Number","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,19,"getVoiceMailNumber","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,20,"getVoiceMailAlphaTag","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,21,"getCallState","()I")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,22,"getDataActivity","()I")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,23,"getDataState","()I")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,24,"listen","(Landroid/telephony/PhoneStateListener;I)V")
J2CPP_DEFINE_METHOD(android::telephony::TelephonyManager,25,"<clinit>","()V")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,0,"ACTION_PHONE_STATE_CHANGED","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,1,"EXTRA_STATE","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,2,"EXTRA_STATE_IDLE","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,3,"EXTRA_STATE_RINGING","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,4,"EXTRA_STATE_OFFHOOK","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,5,"EXTRA_INCOMING_NUMBER","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,6,"PHONE_TYPE_NONE","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,7,"PHONE_TYPE_GSM","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,8,"PHONE_TYPE_CDMA","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,9,"NETWORK_TYPE_UNKNOWN","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,10,"NETWORK_TYPE_GPRS","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,11,"NETWORK_TYPE_EDGE","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,12,"NETWORK_TYPE_UMTS","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,13,"NETWORK_TYPE_CDMA","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,14,"NETWORK_TYPE_EVDO_0","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,15,"NETWORK_TYPE_EVDO_A","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,16,"NETWORK_TYPE_1xRTT","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,17,"NETWORK_TYPE_HSDPA","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,18,"NETWORK_TYPE_HSUPA","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,19,"NETWORK_TYPE_HSPA","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,20,"SIM_STATE_UNKNOWN","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,21,"SIM_STATE_ABSENT","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,22,"SIM_STATE_PIN_REQUIRED","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,23,"SIM_STATE_PUK_REQUIRED","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,24,"SIM_STATE_NETWORK_LOCKED","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,25,"SIM_STATE_READY","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,26,"CALL_STATE_IDLE","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,27,"CALL_STATE_RINGING","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,28,"CALL_STATE_OFFHOOK","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,29,"DATA_ACTIVITY_NONE","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,30,"DATA_ACTIVITY_IN","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,31,"DATA_ACTIVITY_OUT","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,32,"DATA_ACTIVITY_INOUT","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,33,"DATA_ACTIVITY_DORMANT","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,34,"DATA_DISCONNECTED","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,35,"DATA_CONNECTING","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,36,"DATA_CONNECTED","I")
J2CPP_DEFINE_FIELD(android::telephony::TelephonyManager,37,"DATA_SUSPENDED","I")
} //namespace j2cpp
#endif //J2CPP_ANDROID_TELEPHONY_TELEPHONYMANAGER_HPP_IMPL
#endif //J2CPP_INCLUDE_IMPLEMENTATION
| 44.120513 | 150 | 0.784826 | [
"object"
] |
3d778ff2242d05e23a336fd75073b7945eb979fc | 120,443 | cpp | C++ | 01_Develop/libXMFFmpeg/Source/libswscale/swscale.cpp | mcodegeeks/OpenKODE-Framework | d4382d781da7f488a0e7667362a89e8e389468dd | [
"MIT"
] | 2 | 2017-08-03T07:15:00.000Z | 2018-06-18T10:32:53.000Z | 01_Develop/libXMFFmpeg/Source/libswscale/swscale.cpp | mcodegeeks/OpenKODE-Framework | d4382d781da7f488a0e7667362a89e8e389468dd | [
"MIT"
] | null | null | null | 01_Develop/libXMFFmpeg/Source/libswscale/swscale.cpp | mcodegeeks/OpenKODE-Framework | d4382d781da7f488a0e7667362a89e8e389468dd | [
"MIT"
] | 2 | 2019-03-04T22:57:42.000Z | 2020-03-06T01:32:26.000Z | /*
* Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "swscale_internal.h"
#include "rgb2rgb.h"
#include "XMFFmpeg/libavutil/avassert.h"
#include "XMFFmpeg/libavutil/intreadwrite.h"
#include "XMFFmpeg/libavutil/cpu.h"
#include "XMFFmpeg/libavutil/avutil.h"
#include "XMFFmpeg/libavutil/mathematics.h"
#include "XMFFmpeg/libavutil/bswap.h"
#include "XMFFmpeg/libavutil/pixdesc.h"
#define RGB2YUV_SHIFT 15
#define BY ( (int)(0.114*219/255*(1<<RGB2YUV_SHIFT)+0.5))
#define BV (-(int)(0.081*224/255*(1<<RGB2YUV_SHIFT)+0.5))
#define BU ( (int)(0.500*224/255*(1<<RGB2YUV_SHIFT)+0.5))
#define GY ( (int)(0.587*219/255*(1<<RGB2YUV_SHIFT)+0.5))
#define GV (-(int)(0.419*224/255*(1<<RGB2YUV_SHIFT)+0.5))
#define GU (-(int)(0.331*224/255*(1<<RGB2YUV_SHIFT)+0.5))
#define RY ( (int)(0.299*219/255*(1<<RGB2YUV_SHIFT)+0.5))
#define RV ( (int)(0.500*224/255*(1<<RGB2YUV_SHIFT)+0.5))
#define RU (-(int)(0.169*224/255*(1<<RGB2YUV_SHIFT)+0.5))
/*
NOTES
Special versions: fast Y 1:1 scaling (no interpolation in y direction)
TODO
more intelligent misalignment avoidance for the horizontal scaler
write special vertical cubic upscale version
optimize C code (YV12 / minmax)
add support for packed pixel YUV input & output
add support for Y8 output
optimize BGR24 & BGR32
add BGR4 output support
write special BGR->BGR scaler
*/
DECLARE_ALIGNED(8, static const uint8_t, dither_2x2_4)[2][8]={
{ 1, 3, 1, 3, 1, 3, 1, 3, },
{ 2, 0, 2, 0, 2, 0, 2, 0, },
};
DECLARE_ALIGNED(8, static const uint8_t, dither_2x2_8)[2][8]={
{ 6, 2, 6, 2, 6, 2, 6, 2, },
{ 0, 4, 0, 4, 0, 4, 0, 4, },
};
DECLARE_ALIGNED(8, extern const uint8_t, dither_4x4_16)[4][8]={
{ 8, 4, 11, 7, 8, 4, 11, 7, },
{ 2, 14, 1, 13, 2, 14, 1, 13, },
{ 10, 6, 9, 5, 10, 6, 9, 5, },
{ 0, 12, 3, 15, 0, 12, 3, 15, },
};
DECLARE_ALIGNED(8, extern const uint8_t, dither_8x8_32)[8][8]={
{ 17, 9, 23, 15, 16, 8, 22, 14, },
{ 5, 29, 3, 27, 4, 28, 2, 26, },
{ 21, 13, 19, 11, 20, 12, 18, 10, },
{ 0, 24, 6, 30, 1, 25, 7, 31, },
{ 16, 8, 22, 14, 17, 9, 23, 15, },
{ 4, 28, 2, 26, 5, 29, 3, 27, },
{ 20, 12, 18, 10, 21, 13, 19, 11, },
{ 1, 25, 7, 31, 0, 24, 6, 30, },
};
DECLARE_ALIGNED(8, extern const uint8_t, dither_8x8_73)[8][8]={
{ 0, 55, 14, 68, 3, 58, 17, 72, },
{ 37, 18, 50, 32, 40, 22, 54, 35, },
{ 9, 64, 5, 59, 13, 67, 8, 63, },
{ 46, 27, 41, 23, 49, 31, 44, 26, },
{ 2, 57, 16, 71, 1, 56, 15, 70, },
{ 39, 21, 52, 34, 38, 19, 51, 33, },
{ 11, 66, 7, 62, 10, 65, 6, 60, },
{ 48, 30, 43, 25, 47, 29, 42, 24, },
};
#if 1
DECLARE_ALIGNED(8, extern const uint8_t, dither_8x8_220)[8][8]={
{117, 62, 158, 103, 113, 58, 155, 100, },
{ 34, 199, 21, 186, 31, 196, 17, 182, },
{144, 89, 131, 76, 141, 86, 127, 72, },
{ 0, 165, 41, 206, 10, 175, 52, 217, },
{110, 55, 151, 96, 120, 65, 162, 107, },
{ 28, 193, 14, 179, 38, 203, 24, 189, },
{138, 83, 124, 69, 148, 93, 134, 79, },
{ 7, 172, 48, 213, 3, 168, 45, 210, },
};
#elif 1
// tries to correct a gamma of 1.5
DECLARE_ALIGNED(8, extern const uint8_t, dither_8x8_220)[8][8]={
{ 0, 143, 18, 200, 2, 156, 25, 215, },
{ 78, 28, 125, 64, 89, 36, 138, 74, },
{ 10, 180, 3, 161, 16, 195, 8, 175, },
{109, 51, 93, 38, 121, 60, 105, 47, },
{ 1, 152, 23, 210, 0, 147, 20, 205, },
{ 85, 33, 134, 71, 81, 30, 130, 67, },
{ 14, 190, 6, 171, 12, 185, 5, 166, },
{117, 57, 101, 44, 113, 54, 97, 41, },
};
#elif 1
// tries to correct a gamma of 2.0
DECLARE_ALIGNED(8, extern const uint8_t, dither_8x8_220)[8][8]={
{ 0, 124, 8, 193, 0, 140, 12, 213, },
{ 55, 14, 104, 42, 66, 19, 119, 52, },
{ 3, 168, 1, 145, 6, 187, 3, 162, },
{ 86, 31, 70, 21, 99, 39, 82, 28, },
{ 0, 134, 11, 206, 0, 129, 9, 200, },
{ 62, 17, 114, 48, 58, 16, 109, 45, },
{ 5, 181, 2, 157, 4, 175, 1, 151, },
{ 95, 36, 78, 26, 90, 34, 74, 24, },
};
#else
// tries to correct a gamma of 2.5
DECLARE_ALIGNED(8, extern const uint8_t, dither_8x8_220)[8][8]={
{ 0, 107, 3, 187, 0, 125, 6, 212, },
{ 39, 7, 86, 28, 49, 11, 102, 36, },
{ 1, 158, 0, 131, 3, 180, 1, 151, },
{ 68, 19, 52, 12, 81, 25, 64, 17, },
{ 0, 119, 5, 203, 0, 113, 4, 195, },
{ 45, 9, 96, 33, 42, 8, 91, 30, },
{ 2, 172, 1, 144, 2, 165, 0, 137, },
{ 77, 23, 60, 15, 72, 21, 56, 14, },
};
#endif
DECLARE_ALIGNED(8, extern const uint8_t, dither_8x8_128)[8][8] = {
{ 36, 68, 60, 92, 34, 66, 58, 90,},
{ 100, 4,124, 28, 98, 2,122, 26,},
{ 52, 84, 44, 76, 50, 82, 42, 74,},
{ 116, 20,108, 12,114, 18,106, 10,},
{ 32, 64, 56, 88, 38, 70, 62, 94,},
{ 96, 0,120, 24,102, 6,126, 30,},
{ 48, 80, 40, 72, 54, 86, 46, 78,},
{ 112, 16,104, 8,118, 22,110, 14,},
};
DECLARE_ALIGNED(8, extern const uint8_t, ff_sws_pb_64)[8] =
{ 64, 64, 64, 64, 64, 64, 64, 64 };
DECLARE_ALIGNED(8, extern const uint8_t, dithers)[8][8][8]={
{
{ 0, 1, 0, 1, 0, 1, 0, 1,},
{ 1, 0, 1, 0, 1, 0, 1, 0,},
{ 0, 1, 0, 1, 0, 1, 0, 1,},
{ 1, 0, 1, 0, 1, 0, 1, 0,},
{ 0, 1, 0, 1, 0, 1, 0, 1,},
{ 1, 0, 1, 0, 1, 0, 1, 0,},
{ 0, 1, 0, 1, 0, 1, 0, 1,},
{ 1, 0, 1, 0, 1, 0, 1, 0,},
},{
{ 1, 2, 1, 2, 1, 2, 1, 2,},
{ 3, 0, 3, 0, 3, 0, 3, 0,},
{ 1, 2, 1, 2, 1, 2, 1, 2,},
{ 3, 0, 3, 0, 3, 0, 3, 0,},
{ 1, 2, 1, 2, 1, 2, 1, 2,},
{ 3, 0, 3, 0, 3, 0, 3, 0,},
{ 1, 2, 1, 2, 1, 2, 1, 2,},
{ 3, 0, 3, 0, 3, 0, 3, 0,},
},{
{ 2, 4, 3, 5, 2, 4, 3, 5,},
{ 6, 0, 7, 1, 6, 0, 7, 1,},
{ 3, 5, 2, 4, 3, 5, 2, 4,},
{ 7, 1, 6, 0, 7, 1, 6, 0,},
{ 2, 4, 3, 5, 2, 4, 3, 5,},
{ 6, 0, 7, 1, 6, 0, 7, 1,},
{ 3, 5, 2, 4, 3, 5, 2, 4,},
{ 7, 1, 6, 0, 7, 1, 6, 0,},
},{
{ 4, 8, 7, 11, 4, 8, 7, 11,},
{ 12, 0, 15, 3, 12, 0, 15, 3,},
{ 6, 10, 5, 9, 6, 10, 5, 9,},
{ 14, 2, 13, 1, 14, 2, 13, 1,},
{ 4, 8, 7, 11, 4, 8, 7, 11,},
{ 12, 0, 15, 3, 12, 0, 15, 3,},
{ 6, 10, 5, 9, 6, 10, 5, 9,},
{ 14, 2, 13, 1, 14, 2, 13, 1,},
},{
{ 9, 17, 15, 23, 8, 16, 14, 22,},
{ 25, 1, 31, 7, 24, 0, 30, 6,},
{ 13, 21, 11, 19, 12, 20, 10, 18,},
{ 29, 5, 27, 3, 28, 4, 26, 2,},
{ 8, 16, 14, 22, 9, 17, 15, 23,},
{ 24, 0, 30, 6, 25, 1, 31, 7,},
{ 12, 20, 10, 18, 13, 21, 11, 19,},
{ 28, 4, 26, 2, 29, 5, 27, 3,},
},{
{ 18, 34, 30, 46, 17, 33, 29, 45,},
{ 50, 2, 62, 14, 49, 1, 61, 13,},
{ 26, 42, 22, 38, 25, 41, 21, 37,},
{ 58, 10, 54, 6, 57, 9, 53, 5,},
{ 16, 32, 28, 44, 19, 35, 31, 47,},
{ 48, 0, 60, 12, 51, 3, 63, 15,},
{ 24, 40, 20, 36, 27, 43, 23, 39,},
{ 56, 8, 52, 4, 59, 11, 55, 7,},
},{
{ 18, 34, 30, 46, 17, 33, 29, 45,},
{ 50, 2, 62, 14, 49, 1, 61, 13,},
{ 26, 42, 22, 38, 25, 41, 21, 37,},
{ 58, 10, 54, 6, 57, 9, 53, 5,},
{ 16, 32, 28, 44, 19, 35, 31, 47,},
{ 48, 0, 60, 12, 51, 3, 63, 15,},
{ 24, 40, 20, 36, 27, 43, 23, 39,},
{ 56, 8, 52, 4, 59, 11, 55, 7,},
},{
{ 36, 68, 60, 92, 34, 66, 58, 90,},
{ 100, 4,124, 28, 98, 2,122, 26,},
{ 52, 84, 44, 76, 50, 82, 42, 74,},
{ 116, 20,108, 12,114, 18,106, 10,},
{ 32, 64, 56, 88, 38, 70, 62, 94,},
{ 96, 0,120, 24,102, 6,126, 30,},
{ 48, 80, 40, 72, 54, 86, 46, 78,},
{ 112, 16,104, 8,118, 22,110, 14,},
}};
static const uint8_t flat64[8]={64,64,64,64,64,64,64,64};
const uint16_t dither_scale[15][16]={
{ 2, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,},
{ 2, 3, 7, 7, 13, 13, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,},
{ 3, 3, 4, 15, 15, 29, 57, 57, 57, 113, 113, 113, 113, 113, 113, 113,},
{ 3, 4, 4, 5, 31, 31, 61, 121, 241, 241, 241, 241, 481, 481, 481, 481,},
{ 3, 4, 5, 5, 6, 63, 63, 125, 249, 497, 993, 993, 993, 993, 993, 1985,},
{ 3, 5, 6, 6, 6, 7, 127, 127, 253, 505, 1009, 2017, 4033, 4033, 4033, 4033,},
{ 3, 5, 6, 7, 7, 7, 8, 255, 255, 509, 1017, 2033, 4065, 8129,16257,16257,},
{ 3, 5, 6, 8, 8, 8, 8, 9, 511, 511, 1021, 2041, 4081, 8161,16321,32641,},
{ 3, 5, 7, 8, 9, 9, 9, 9, 10, 1023, 1023, 2045, 4089, 8177,16353,32705,},
{ 3, 5, 7, 8, 10, 10, 10, 10, 10, 11, 2047, 2047, 4093, 8185,16369,32737,},
{ 3, 5, 7, 8, 10, 11, 11, 11, 11, 11, 12, 4095, 4095, 8189,16377,32753,},
{ 3, 5, 7, 9, 10, 12, 12, 12, 12, 12, 12, 13, 8191, 8191,16381,32761,},
{ 3, 5, 7, 9, 10, 12, 13, 13, 13, 13, 13, 13, 14,16383,16383,32765,},
{ 3, 5, 7, 9, 10, 12, 14, 14, 14, 14, 14, 14, 14, 15,32767,32767,},
{ 3, 5, 7, 9, 11, 12, 14, 15, 15, 15, 15, 15, 15, 15, 16,65535,},
};
#define output_pixel(pos, val, bias, signedness) \
if (big_endian) { \
AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
} else { \
AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
}
static av_always_inline void
yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW,
int big_endian, int output_bits)
{
int i;
int shift = 3;
av_assert0(output_bits == 16);
for (i = 0; i < dstW; i++) {
int val = src[i] + (1 << (shift - 1));
output_pixel(&dest[i], val, 0, uint);
}
}
static av_always_inline void
yuv2planeX_16_c_template(const int16_t *filter, int filterSize,
const int32_t **src, uint16_t *dest, int dstW,
int big_endian, int output_bits)
{
int i;
int shift = 15;
av_assert0(output_bits == 16);
for (i = 0; i < dstW; i++) {
int val = 1 << (shift - 1);
int j;
/* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline
* filters (or anything with negative coeffs, the range can be slightly
* wider in both directions. To account for this overflow, we subtract
* a constant so it always fits in the signed range (assuming a
* reasonable filterSize), and re-add that at the end. */
val -= 0x40000000;
for (j = 0; j < filterSize; j++)
val += src[j][i] * filter[j];
output_pixel(&dest[i], val, 0x8000, int);
}
}
#undef output_pixel
#define output_pixel(pos, val) \
if (big_endian) { \
AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
} else { \
AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
}
static av_always_inline void
yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW,
int big_endian, int output_bits)
{
int i;
int shift = 15 - output_bits;
for (i = 0; i < dstW; i++) {
int val = src[i] + (1 << (shift - 1));
output_pixel(&dest[i], val);
}
}
static av_always_inline void
yuv2planeX_10_c_template(const int16_t *filter, int filterSize,
const int16_t **src, uint16_t *dest, int dstW,
int big_endian, int output_bits)
{
int i;
int shift = 11 + 16 - output_bits;
for (i = 0; i < dstW; i++) {
int val = 1 << (shift - 1);
int j;
for (j = 0; j < filterSize; j++)
val += src[j][i] * filter[j];
output_pixel(&dest[i], val);
}
}
#undef output_pixel
#define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
uint8_t *dest, int dstW, \
const uint8_t *dither, int offset)\
{ \
yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
(uint16_t *) dest, dstW, is_be, bits); \
}\
static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
const int16_t **src, uint8_t *dest, int dstW, \
const uint8_t *dither, int offset)\
{ \
yuv2planeX_## template_size ## _c_template(filter, \
filterSize, (const typeX_t **) src, \
(uint16_t *) dest, dstW, is_be, bits); \
}
yuv2NBPS( 9, BE, 1, 10, int16_t)
yuv2NBPS( 9, LE, 0, 10, int16_t)
yuv2NBPS(10, BE, 1, 10, int16_t)
yuv2NBPS(10, LE, 0, 10, int16_t)
yuv2NBPS(16, BE, 1, 16, int32_t)
yuv2NBPS(16, LE, 0, 16, int32_t)
static void yuv2planeX_8_c(const int16_t *filter, int filterSize,
const int16_t **src, uint8_t *dest, int dstW,
const uint8_t *dither, int offset)
{
int i;
for (i=0; i<dstW; i++) {
int val = dither[(i + offset) & 7] << 12;
int j;
for (j=0; j<filterSize; j++)
val += src[j][i] * filter[j];
dest[i]= av_clip_uint8(val>>19);
}
}
static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW,
const uint8_t *dither, int offset)
{
int i;
for (i=0; i<dstW; i++) {
int val = (src[i] + dither[(i + offset) & 7]) >> 7;
dest[i]= av_clip_uint8(val);
}
}
static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize,
const int16_t **chrUSrc, const int16_t **chrVSrc,
uint8_t *dest, int chrDstW)
{
enum PixelFormat dstFormat = c->dstFormat;
const uint8_t *chrDither = c->chrDither8;
int i;
if (dstFormat == PIX_FMT_NV12)
for (i=0; i<chrDstW; i++) {
int u = chrDither[i & 7] << 12;
int v = chrDither[(i + 3) & 7] << 12;
int j;
for (j=0; j<chrFilterSize; j++) {
u += chrUSrc[j][i] * chrFilter[j];
v += chrVSrc[j][i] * chrFilter[j];
}
dest[2*i]= av_clip_uint8(u>>19);
dest[2*i+1]= av_clip_uint8(v>>19);
}
else
for (i=0; i<chrDstW; i++) {
int u = chrDither[i & 7] << 12;
int v = chrDither[(i + 3) & 7] << 12;
int j;
for (j=0; j<chrFilterSize; j++) {
u += chrUSrc[j][i] * chrFilter[j];
v += chrVSrc[j][i] * chrFilter[j];
}
dest[2*i]= av_clip_uint8(v>>19);
dest[2*i+1]= av_clip_uint8(u>>19);
}
}
#define output_pixel(pos, val) \
if (target == PIX_FMT_GRAY16BE) { \
AV_WB16(pos, val); \
} else { \
AV_WL16(pos, val); \
}
static av_always_inline void
yuv2gray16_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int32_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int32_t **chrUSrc,
const int32_t **chrVSrc, int chrFilterSize,
const int32_t **alpSrc, uint16_t *dest, int dstW,
int y, enum PixelFormat target)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
int j;
int Y1 = (1 << 14) - 0x40000000;
int Y2 = (1 << 14) - 0x40000000;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i * 2] * lumFilter[j];
Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
}
Y1 >>= 15;
Y2 >>= 15;
Y1 = av_clip_int16(Y1);
Y2 = av_clip_int16(Y2);
output_pixel(&dest[i * 2 + 0], 0x8000 + Y1);
output_pixel(&dest[i * 2 + 1], 0x8000 + Y2);
}
}
static av_always_inline void
yuv2gray16_2_c_template(SwsContext *c, const int32_t *buf[2],
const int32_t *ubuf[2], const int32_t *vbuf[2],
const int32_t *abuf[2], uint16_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target)
{
int yalpha1 = 4095 - yalpha;
int i;
const int32_t *buf0 = buf[0], *buf1 = buf[1];
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2 ] * yalpha1 + buf1[i * 2 ] * yalpha) >> 15;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 15;
output_pixel(&dest[i * 2 + 0], Y1);
output_pixel(&dest[i * 2 + 1], Y2);
}
}
static av_always_inline void
yuv2gray16_1_c_template(SwsContext *c, const int32_t *buf0,
const int32_t *ubuf[2], const int32_t *vbuf[2],
const int32_t *abuf0, uint16_t *dest, int dstW,
int uvalpha, int y, enum PixelFormat target)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2 ]+4)>>3;
int Y2 = (buf0[i * 2 + 1]+4)>>3;
output_pixel(&dest[i * 2 + 0], Y1);
output_pixel(&dest[i * 2 + 1], Y2);
}
}
#undef output_pixel
#define YUV2PACKED16WRAPPER(name, base, ext, fmt) \
static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
const int16_t **_lumSrc, int lumFilterSize, \
const int16_t *chrFilter, const int16_t **_chrUSrc, \
const int16_t **_chrVSrc, int chrFilterSize, \
const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
int y) \
{ \
const int32_t **lumSrc = (const int32_t **) _lumSrc, \
**chrUSrc = (const int32_t **) _chrUSrc, \
**chrVSrc = (const int32_t **) _chrVSrc, \
**alpSrc = (const int32_t **) _alpSrc; \
uint16_t *dest = (uint16_t *) _dest; \
name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
alpSrc, dest, dstW, y, fmt); \
} \
\
static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \
const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
int yalpha, int uvalpha, int y) \
{ \
const int32_t **buf = (const int32_t **) _buf, \
**ubuf = (const int32_t **) _ubuf, \
**vbuf = (const int32_t **) _vbuf, \
**abuf = (const int32_t **) _abuf; \
uint16_t *dest = (uint16_t *) _dest; \
name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
dest, dstW, yalpha, uvalpha, y, fmt); \
} \
\
static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \
const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
const int16_t *_abuf0, uint8_t *_dest, int dstW, \
int uvalpha, int y) \
{ \
const int32_t *buf0 = (const int32_t *) _buf0, \
**ubuf = (const int32_t **) _ubuf, \
**vbuf = (const int32_t **) _vbuf, \
*abuf0 = (const int32_t *) _abuf0; \
uint16_t *dest = (uint16_t *) _dest; \
name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
dstW, uvalpha, y, fmt); \
}
YUV2PACKED16WRAPPER(yuv2gray16,, LE, PIX_FMT_GRAY16LE)
YUV2PACKED16WRAPPER(yuv2gray16,, BE, PIX_FMT_GRAY16BE)
#define output_pixel(pos, acc) \
if (target == PIX_FMT_MONOBLACK) { \
pos = acc; \
} else { \
pos = ~acc; \
}
static av_always_inline void
yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest, int dstW,
int y, enum PixelFormat target)
{
const uint8_t * const d128=dither_8x8_220[y&7];
uint8_t *g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM];
int i;
unsigned acc = 0;
for (i = 0; i < dstW - 1; i += 2) {
int j;
int Y1 = 1 << 18;
int Y2 = 1 << 18;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i] * lumFilter[j];
Y2 += lumSrc[j][i+1] * lumFilter[j];
}
Y1 >>= 19;
Y2 >>= 19;
if ((Y1 | Y2) & 0x100) {
Y1 = av_clip_uint8(Y1);
Y2 = av_clip_uint8(Y2);
}
acc += acc + g[Y1 + d128[(i + 0) & 7]];
acc += acc + g[Y2 + d128[(i + 1) & 7]];
if ((i & 7) == 6) {
output_pixel(*dest++, acc);
}
}
}
static av_always_inline void
yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2],
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf[2], uint8_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target)
{
const int16_t *buf0 = buf[0], *buf1 = buf[1];
const uint8_t * const d128 = dither_8x8_220[y & 7];
uint8_t *g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM];
int yalpha1 = 4095 - yalpha;
int i;
for (i = 0; i < dstW - 7; i += 8) {
int acc = g[((buf0[i ] * yalpha1 + buf1[i ] * yalpha) >> 19) + d128[0]];
acc += acc + g[((buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19) + d128[1]];
acc += acc + g[((buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19) + d128[2]];
acc += acc + g[((buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19) + d128[3]];
acc += acc + g[((buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19) + d128[4]];
acc += acc + g[((buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19) + d128[5]];
acc += acc + g[((buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19) + d128[6]];
acc += acc + g[((buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19) + d128[7]];
output_pixel(*dest++, acc);
}
}
static av_always_inline void
yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0,
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf0, uint8_t *dest, int dstW,
int uvalpha, int y, enum PixelFormat target)
{
const uint8_t * const d128 = dither_8x8_220[y & 7];
uint8_t *g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM];
int i;
for (i = 0; i < dstW - 7; i += 8) {
int acc = g[(buf0[i ] >> 7) + d128[0]];
acc += acc + g[(buf0[i + 1] >> 7) + d128[1]];
acc += acc + g[(buf0[i + 2] >> 7) + d128[2]];
acc += acc + g[(buf0[i + 3] >> 7) + d128[3]];
acc += acc + g[(buf0[i + 4] >> 7) + d128[4]];
acc += acc + g[(buf0[i + 5] >> 7) + d128[5]];
acc += acc + g[(buf0[i + 6] >> 7) + d128[6]];
acc += acc + g[(buf0[i + 7] >> 7) + d128[7]];
output_pixel(*dest++, acc);
}
}
#undef output_pixel
#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
const int16_t **lumSrc, int lumFilterSize, \
const int16_t *chrFilter, const int16_t **chrUSrc, \
const int16_t **chrVSrc, int chrFilterSize, \
const int16_t **alpSrc, uint8_t *dest, int dstW, \
int y) \
{ \
name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
alpSrc, dest, dstW, y, fmt); \
} \
\
static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
const int16_t *ubuf[2], const int16_t *vbuf[2], \
const int16_t *abuf[2], uint8_t *dest, int dstW, \
int yalpha, int uvalpha, int y) \
{ \
name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
dest, dstW, yalpha, uvalpha, y, fmt); \
} \
\
static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
const int16_t *ubuf[2], const int16_t *vbuf[2], \
const int16_t *abuf0, uint8_t *dest, int dstW, \
int uvalpha, int y) \
{ \
name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
abuf0, dest, dstW, uvalpha, \
y, fmt); \
}
YUV2PACKEDWRAPPER(yuv2mono,, white, PIX_FMT_MONOWHITE)
YUV2PACKEDWRAPPER(yuv2mono,, black, PIX_FMT_MONOBLACK)
#define output_pixels(pos, Y1, U, Y2, V) \
if (target == PIX_FMT_YUYV422) { \
dest[pos + 0] = Y1; \
dest[pos + 1] = U; \
dest[pos + 2] = Y2; \
dest[pos + 3] = V; \
} else { \
dest[pos + 0] = U; \
dest[pos + 1] = Y1; \
dest[pos + 2] = V; \
dest[pos + 3] = Y2; \
}
static av_always_inline void
yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest, int dstW,
int y, enum PixelFormat target)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
int j;
int Y1 = 1 << 18;
int Y2 = 1 << 18;
int U = 1 << 18;
int V = 1 << 18;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i * 2] * lumFilter[j];
Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
}
for (j = 0; j < chrFilterSize; j++) {
U += chrUSrc[j][i] * chrFilter[j];
V += chrVSrc[j][i] * chrFilter[j];
}
Y1 >>= 19;
Y2 >>= 19;
U >>= 19;
V >>= 19;
if ((Y1 | Y2 | U | V) & 0x100) {
Y1 = av_clip_uint8(Y1);
Y2 = av_clip_uint8(Y2);
U = av_clip_uint8(U);
V = av_clip_uint8(V);
}
output_pixels(4*i, Y1, U, Y2, V);
}
}
static av_always_inline void
yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf[2], uint8_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target)
{
const int16_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int yalpha1 = 4095 - yalpha;
int uvalpha1 = 4095 - uvalpha;
int i;
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
output_pixels(i * 4, Y1, U, Y2, V);
}
}
static av_always_inline void
yuv2422_1_c_template(SwsContext *c, const int16_t *buf0,
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf0, uint8_t *dest, int dstW,
int uvalpha, int y, enum PixelFormat target)
{
const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int i;
if (uvalpha < 2048) {
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = buf0[i * 2] >> 7;
int Y2 = buf0[i * 2 + 1] >> 7;
int U = ubuf1[i] >> 7;
int V = vbuf1[i] >> 7;
output_pixels(i * 4, Y1, U, Y2, V);
}
} else {
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = buf0[i * 2] >> 7;
int Y2 = buf0[i * 2 + 1] >> 7;
int U = (ubuf0[i] + ubuf1[i]) >> 8;
int V = (vbuf0[i] + vbuf1[i]) >> 8;
output_pixels(i * 4, Y1, U, Y2, V);
}
}
}
#undef output_pixels
YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, PIX_FMT_YUYV422)
YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, PIX_FMT_UYVY422)
#define R_B ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? R : B)
#define B_R ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? B : R)
#define output_pixel(pos, val) \
if (isBE(target)) { \
AV_WB16(pos, val); \
} else { \
AV_WL16(pos, val); \
}
static av_always_inline void
yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int32_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int32_t **chrUSrc,
const int32_t **chrVSrc, int chrFilterSize,
const int32_t **alpSrc, uint16_t *dest, int dstW,
int y, enum PixelFormat target)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
int j;
int Y1 = -0x40000000;
int Y2 = -0x40000000;
int U = -128 << 23; // 19
int V = -128 << 23;
int R, G, B;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i * 2] * lumFilter[j];
Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
}
for (j = 0; j < chrFilterSize; j++) {
U += chrUSrc[j][i] * chrFilter[j];
V += chrVSrc[j][i] * chrFilter[j];
}
// 8bit: 12+15=27; 16-bit: 12+19=31
Y1 >>= 14; // 10
Y1 += 0x10000;
Y2 >>= 14;
Y2 += 0x10000;
U >>= 14;
V >>= 14;
// 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit
Y1 -= c->yuv2rgb_y_offset;
Y2 -= c->yuv2rgb_y_offset;
Y1 *= c->yuv2rgb_y_coeff;
Y2 *= c->yuv2rgb_y_coeff;
Y1 += 1 << 13; // 21
Y2 += 1 << 13;
// 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit
R = V * c->yuv2rgb_v2r_coeff;
G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
B = U * c->yuv2rgb_u2b_coeff;
// 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit
output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
dest += 6;
}
}
static av_always_inline void
yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2],
const int32_t *ubuf[2], const int32_t *vbuf[2],
const int32_t *abuf[2], uint16_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target)
{
const int32_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int yalpha1 = 4095 - yalpha;
int uvalpha1 = 4095 - uvalpha;
int i;
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14;
int R, G, B;
Y1 -= c->yuv2rgb_y_offset;
Y2 -= c->yuv2rgb_y_offset;
Y1 *= c->yuv2rgb_y_coeff;
Y2 *= c->yuv2rgb_y_coeff;
Y1 += 1 << 13;
Y2 += 1 << 13;
R = V * c->yuv2rgb_v2r_coeff;
G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
B = U * c->yuv2rgb_u2b_coeff;
output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
dest += 6;
}
}
static av_always_inline void
yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0,
const int32_t *ubuf[2], const int32_t *vbuf[2],
const int32_t *abuf0, uint16_t *dest, int dstW,
int uvalpha, int y, enum PixelFormat target)
{
const int32_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int i;
if (uvalpha < 2048) {
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2] ) >> 2;
int Y2 = (buf0[i * 2 + 1]) >> 2;
int U = (ubuf0[i] + (-128 << 11)) >> 2;
int V = (vbuf0[i] + (-128 << 11)) >> 2;
int R, G, B;
Y1 -= c->yuv2rgb_y_offset;
Y2 -= c->yuv2rgb_y_offset;
Y1 *= c->yuv2rgb_y_coeff;
Y2 *= c->yuv2rgb_y_coeff;
Y1 += 1 << 13;
Y2 += 1 << 13;
R = V * c->yuv2rgb_v2r_coeff;
G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
B = U * c->yuv2rgb_u2b_coeff;
output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
dest += 6;
}
} else {
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2] ) >> 2;
int Y2 = (buf0[i * 2 + 1]) >> 2;
int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3;
int V = (vbuf0[i] + vbuf1[i] + (-128 << 12)) >> 3;
int R, G, B;
Y1 -= c->yuv2rgb_y_offset;
Y2 -= c->yuv2rgb_y_offset;
Y1 *= c->yuv2rgb_y_coeff;
Y2 *= c->yuv2rgb_y_coeff;
Y1 += 1 << 13;
Y2 += 1 << 13;
R = V * c->yuv2rgb_v2r_coeff;
G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
B = U * c->yuv2rgb_u2b_coeff;
output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
dest += 6;
}
}
}
#undef output_pixel
#undef r_b
#undef b_r
YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE)
YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE)
YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE)
YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE)
/*
* Write out 2 RGB pixels in the target pixel format. This function takes a
* R/G/B LUT as generated by ff_yuv2rgb_c_init_tables(), which takes care of
* things like endianness conversion and shifting. The caller takes care of
* setting the correct offset in these tables from the chroma (U/V) values.
* This function then uses the luminance (Y1/Y2) values to write out the
* correct RGB values into the destination buffer.
*/
static av_always_inline void
yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
unsigned A1, unsigned A2,
const void *_r, const void *_g, const void *_b, int y,
enum PixelFormat target, int hasAlpha)
{
if (target == PIX_FMT_ARGB || target == PIX_FMT_RGBA ||
target == PIX_FMT_ABGR || target == PIX_FMT_BGRA) {
uint32_t *dest = (uint32_t *) _dest;
const uint32_t *r = (const uint32_t *) _r;
const uint32_t *g = (const uint32_t *) _g;
const uint32_t *b = (const uint32_t *) _b;
#if CONFIG_SMALL
int sh = hasAlpha ? ((target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24) : 0;
dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
#else
if (hasAlpha) {
int sh = (target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24;
dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
} else {
dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
}
#endif
} else if (target == PIX_FMT_RGB24 || target == PIX_FMT_BGR24) {
uint8_t *dest = (uint8_t *) _dest;
const uint8_t *r = (const uint8_t *) _r;
const uint8_t *g = (const uint8_t *) _g;
const uint8_t *b = (const uint8_t *) _b;
#define r_b ((target == PIX_FMT_RGB24) ? r : b)
#define b_r ((target == PIX_FMT_RGB24) ? b : r)
dest[i * 6 + 0] = r_b[Y1];
dest[i * 6 + 1] = g[Y1];
dest[i * 6 + 2] = b_r[Y1];
dest[i * 6 + 3] = r_b[Y2];
dest[i * 6 + 4] = g[Y2];
dest[i * 6 + 5] = b_r[Y2];
#undef r_b
#undef b_r
} else if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565 ||
target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555 ||
target == PIX_FMT_RGB444 || target == PIX_FMT_BGR444) {
uint16_t *dest = (uint16_t *) _dest;
const uint16_t *r = (const uint16_t *) _r;
const uint16_t *g = (const uint16_t *) _g;
const uint16_t *b = (const uint16_t *) _b;
int dr1, dg1, db1, dr2, dg2, db2;
if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565) {
dr1 = dither_2x2_8[ y & 1 ][0];
dg1 = dither_2x2_4[ y & 1 ][0];
db1 = dither_2x2_8[(y & 1) ^ 1][0];
dr2 = dither_2x2_8[ y & 1 ][1];
dg2 = dither_2x2_4[ y & 1 ][1];
db2 = dither_2x2_8[(y & 1) ^ 1][1];
} else if (target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555) {
dr1 = dither_2x2_8[ y & 1 ][0];
dg1 = dither_2x2_8[ y & 1 ][1];
db1 = dither_2x2_8[(y & 1) ^ 1][0];
dr2 = dither_2x2_8[ y & 1 ][1];
dg2 = dither_2x2_8[ y & 1 ][0];
db2 = dither_2x2_8[(y & 1) ^ 1][1];
} else {
dr1 = dither_4x4_16[ y & 3 ][0];
dg1 = dither_4x4_16[ y & 3 ][1];
db1 = dither_4x4_16[(y & 3) ^ 3][0];
dr2 = dither_4x4_16[ y & 3 ][1];
dg2 = dither_4x4_16[ y & 3 ][0];
db2 = dither_4x4_16[(y & 3) ^ 3][1];
}
dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
} else /* 8/4-bit */ {
uint8_t *dest = (uint8_t *) _dest;
const uint8_t *r = (const uint8_t *) _r;
const uint8_t *g = (const uint8_t *) _g;
const uint8_t *b = (const uint8_t *) _b;
int dr1, dg1, db1, dr2, dg2, db2;
if (target == PIX_FMT_RGB8 || target == PIX_FMT_BGR8) {
const uint8_t * const d64 = dither_8x8_73[y & 7];
const uint8_t * const d32 = dither_8x8_32[y & 7];
dr1 = dg1 = d32[(i * 2 + 0) & 7];
db1 = d64[(i * 2 + 0) & 7];
dr2 = dg2 = d32[(i * 2 + 1) & 7];
db2 = d64[(i * 2 + 1) & 7];
} else {
const uint8_t * const d64 = dither_8x8_73 [y & 7];
const uint8_t * const d128 = dither_8x8_220[y & 7];
dr1 = db1 = d128[(i * 2 + 0) & 7];
dg1 = d64[(i * 2 + 0) & 7];
dr2 = db2 = d128[(i * 2 + 1) & 7];
dg2 = d64[(i * 2 + 1) & 7];
}
if (target == PIX_FMT_RGB4 || target == PIX_FMT_BGR4) {
dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
} else {
dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
}
}
}
static av_always_inline void
yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest, int dstW,
int y, enum PixelFormat target, int hasAlpha)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
int j;
int Y1 = 1 << 18;
int Y2 = 1 << 18;
int U = 1 << 18;
int V = 1 << 18;
int av_unused A1, A2;
const void *r, *g, *b;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i * 2] * lumFilter[j];
Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
}
for (j = 0; j < chrFilterSize; j++) {
U += chrUSrc[j][i] * chrFilter[j];
V += chrVSrc[j][i] * chrFilter[j];
}
Y1 >>= 19;
Y2 >>= 19;
U >>= 19;
V >>= 19;
if (hasAlpha) {
A1 = 1 << 18;
A2 = 1 << 18;
for (j = 0; j < lumFilterSize; j++) {
A1 += alpSrc[j][i * 2 ] * lumFilter[j];
A2 += alpSrc[j][i * 2 + 1] * lumFilter[j];
}
A1 >>= 19;
A2 >>= 19;
if ((A1 | A2) & 0x100) {
A1 = av_clip_uint8(A1);
A2 = av_clip_uint8(A2);
}
}
r = c->table_rV[V + YUVRGB_TABLE_HEADROOM];
g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]);
b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
r, g, b, y, target, hasAlpha);
}
}
static av_always_inline void
yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2],
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf[2], uint8_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target, int hasAlpha)
{
const int16_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
*abuf0 = hasAlpha ? abuf[0] : NULL,
*abuf1 = hasAlpha ? abuf[1] : NULL;
int yalpha1 = 4095 - yalpha;
int uvalpha1 = 4095 - uvalpha;
int i;
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
int A1, A2;
const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
*g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
*b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
if (hasAlpha) {
A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19;
A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19;
}
yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
r, g, b, y, target, hasAlpha);
}
}
static av_always_inline void
yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0,
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf0, uint8_t *dest, int dstW,
int uvalpha, int y, enum PixelFormat target,
int hasAlpha)
{
const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int i;
if (uvalpha < 2048) {
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = buf0[i * 2] >> 7;
int Y2 = buf0[i * 2 + 1] >> 7;
int U = ubuf1[i] >> 7;
int V = vbuf1[i] >> 7;
int A1, A2;
const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
*g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
*b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
if (hasAlpha) {
A1 = abuf0[i * 2 ] >> 7;
A2 = abuf0[i * 2 + 1] >> 7;
}
yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
r, g, b, y, target, hasAlpha);
}
} else {
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = buf0[i * 2] >> 7;
int Y2 = buf0[i * 2 + 1] >> 7;
int U = (ubuf0[i] + ubuf1[i]) >> 8;
int V = (vbuf0[i] + vbuf1[i]) >> 8;
int A1, A2;
const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
*g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
*b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
if (hasAlpha) {
A1 = abuf0[i * 2 ] >> 7;
A2 = abuf0[i * 2 + 1] >> 7;
}
yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
r, g, b, y, target, hasAlpha);
}
}
}
#define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
const int16_t **lumSrc, int lumFilterSize, \
const int16_t *chrFilter, const int16_t **chrUSrc, \
const int16_t **chrVSrc, int chrFilterSize, \
const int16_t **alpSrc, uint8_t *dest, int dstW, \
int y) \
{ \
name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
alpSrc, dest, dstW, y, fmt, hasAlpha); \
}
#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
const int16_t *ubuf[2], const int16_t *vbuf[2], \
const int16_t *abuf[2], uint8_t *dest, int dstW, \
int yalpha, int uvalpha, int y) \
{ \
name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
} \
\
static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
const int16_t *ubuf[2], const int16_t *vbuf[2], \
const int16_t *abuf0, uint8_t *dest, int dstW, \
int uvalpha, int y) \
{ \
name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
dstW, uvalpha, y, fmt, hasAlpha); \
}
#if CONFIG_SMALL
YUV2RGBWRAPPER(yuv2rgb,, 32_1, PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
YUV2RGBWRAPPER(yuv2rgb,, 32, PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
#else
#if CONFIG_SWSCALE_ALPHA
YUV2RGBWRAPPER(yuv2rgb,, a32_1, PIX_FMT_RGB32_1, 1)
YUV2RGBWRAPPER(yuv2rgb,, a32, PIX_FMT_RGB32, 1)
#endif
YUV2RGBWRAPPER(yuv2rgb,, x32_1, PIX_FMT_RGB32_1, 0)
YUV2RGBWRAPPER(yuv2rgb,, x32, PIX_FMT_RGB32, 0)
#endif
YUV2RGBWRAPPER(yuv2, rgb, rgb24, PIX_FMT_RGB24, 0)
YUV2RGBWRAPPER(yuv2, rgb, bgr24, PIX_FMT_BGR24, 0)
YUV2RGBWRAPPER(yuv2rgb,, 16, PIX_FMT_RGB565, 0)
YUV2RGBWRAPPER(yuv2rgb,, 15, PIX_FMT_RGB555, 0)
YUV2RGBWRAPPER(yuv2rgb,, 12, PIX_FMT_RGB444, 0)
YUV2RGBWRAPPER(yuv2rgb,, 8, PIX_FMT_RGB8, 0)
YUV2RGBWRAPPER(yuv2rgb,, 4, PIX_FMT_RGB4, 0)
YUV2RGBWRAPPER(yuv2rgb,, 4b, PIX_FMT_RGB4_BYTE, 0)
static av_always_inline void
yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest,
int dstW, int y, enum PixelFormat target, int hasAlpha)
{
int i;
int step = (target == PIX_FMT_RGB24 || target == PIX_FMT_BGR24) ? 3 : 4;
for (i = 0; i < dstW; i++) {
int j;
int Y = 1<<9;
int U = (1<<9)-(128 << 19);
int V = (1<<9)-(128 << 19);
int av_unused A;
int R, G, B;
for (j = 0; j < lumFilterSize; j++) {
Y += lumSrc[j][i] * lumFilter[j];
}
for (j = 0; j < chrFilterSize; j++) {
U += chrUSrc[j][i] * chrFilter[j];
V += chrVSrc[j][i] * chrFilter[j];
}
Y >>= 10;
U >>= 10;
V >>= 10;
if (hasAlpha) {
A = 1 << 18;
for (j = 0; j < lumFilterSize; j++) {
A += alpSrc[j][i] * lumFilter[j];
}
A >>= 19;
if (A & 0x100)
A = av_clip_uint8(A);
}
Y -= c->yuv2rgb_y_offset;
Y *= c->yuv2rgb_y_coeff;
Y += 1 << 21;
R = Y + V*c->yuv2rgb_v2r_coeff;
G = Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;
B = Y + U*c->yuv2rgb_u2b_coeff;
if ((R | G | B) & 0xC0000000) {
R = av_clip_uintp2(R, 30);
G = av_clip_uintp2(G, 30);
B = av_clip_uintp2(B, 30);
}
switch(target) {
case PIX_FMT_ARGB:
dest[0] = hasAlpha ? A : 255;
dest[1] = R >> 22;
dest[2] = G >> 22;
dest[3] = B >> 22;
break;
case PIX_FMT_RGB24:
dest[0] = R >> 22;
dest[1] = G >> 22;
dest[2] = B >> 22;
break;
case PIX_FMT_RGBA:
dest[0] = R >> 22;
dest[1] = G >> 22;
dest[2] = B >> 22;
dest[3] = hasAlpha ? A : 255;
break;
case PIX_FMT_ABGR:
dest[0] = hasAlpha ? A : 255;
dest[1] = B >> 22;
dest[2] = G >> 22;
dest[3] = R >> 22;
break;
case PIX_FMT_BGR24:
dest[0] = B >> 22;
dest[1] = G >> 22;
dest[2] = R >> 22;
break;
case PIX_FMT_BGRA:
dest[0] = B >> 22;
dest[1] = G >> 22;
dest[2] = R >> 22;
dest[3] = hasAlpha ? A : 255;
break;
}
dest += step;
}
}
#if CONFIG_SMALL
YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
#else
#if CONFIG_SWSCALE_ALPHA
YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, 1)
YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, 1)
YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, 1)
YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, 1)
#endif
YUV2RGBWRAPPERX(yuv2, rgb_full, bgrx32_full, PIX_FMT_BGRA, 0)
YUV2RGBWRAPPERX(yuv2, rgb_full, xbgr32_full, PIX_FMT_ABGR, 0)
YUV2RGBWRAPPERX(yuv2, rgb_full, rgbx32_full, PIX_FMT_RGBA, 0)
YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, PIX_FMT_ARGB, 0)
#endif
YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, PIX_FMT_BGR24, 0)
YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, PIX_FMT_RGB24, 0)
static av_always_inline void fillPlane(uint8_t* plane, int stride,
int width, int height,
int y, uint8_t val)
{
int i;
uint8_t *ptr = plane + stride*y;
for (i=0; i<height; i++) {
memset(ptr, val, width);
ptr += stride;
}
}
#define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
#define r ((origin == PIX_FMT_BGR48BE || origin == PIX_FMT_BGR48LE) ? b_r : r_b)
#define b ((origin == PIX_FMT_BGR48BE || origin == PIX_FMT_BGR48LE) ? r_b : b_r)
static av_always_inline void
rgb48ToY_c_template(uint16_t *dst, const uint16_t *src, int width,
enum PixelFormat origin)
{
int i;
for (i = 0; i < width; i++) {
unsigned int r_b = input_pixel(&src[i*3+0]);
unsigned int g = input_pixel(&src[i*3+1]);
unsigned int b_r = input_pixel(&src[i*3+2]);
dst[i] = (RY*r + GY*g + BY*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
}
}
static av_always_inline void
rgb48ToUV_c_template(uint16_t *dstU, uint16_t *dstV,
const uint16_t *src1, const uint16_t *src2,
int width, enum PixelFormat origin)
{
int i;
assert(src1==src2);
for (i = 0; i < width; i++) {
int r_b = input_pixel(&src1[i*3+0]);
int g = input_pixel(&src1[i*3+1]);
int b_r = input_pixel(&src1[i*3+2]);
dstU[i] = (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
dstV[i] = (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
}
}
static av_always_inline void
rgb48ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV,
const uint16_t *src1, const uint16_t *src2,
int width, enum PixelFormat origin)
{
int i;
assert(src1==src2);
for (i = 0; i < width; i++) {
int r_b = (input_pixel(&src1[6 * i + 0]) + input_pixel(&src1[6 * i + 3]) + 1) >> 1;
int g = (input_pixel(&src1[6 * i + 1]) + input_pixel(&src1[6 * i + 4]) + 1) >> 1;
int b_r = (input_pixel(&src1[6 * i + 2]) + input_pixel(&src1[6 * i + 5]) + 1) >> 1;
dstU[i]= (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
dstV[i]= (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
}
}
#undef r
#undef b
#undef input_pixel
#define rgb48funcs(pattern, BE_LE, origin) \
static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
int width, uint32_t *unused) \
{ \
const uint16_t *src = (const uint16_t *) _src; \
uint16_t *dst = (uint16_t *) _dst; \
rgb48ToY_c_template(dst, src, width, origin); \
} \
\
static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
int width, uint32_t *unused) \
{ \
const uint16_t *src1 = (const uint16_t *) _src1, \
*src2 = (const uint16_t *) _src2; \
uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin); \
} \
\
static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
int width, uint32_t *unused) \
{ \
const uint16_t *src1 = (const uint16_t *) _src1, \
*src2 = (const uint16_t *) _src2; \
uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \
}
rgb48funcs(rgb, LE, PIX_FMT_RGB48LE)
rgb48funcs(rgb, BE, PIX_FMT_RGB48BE)
rgb48funcs(bgr, LE, PIX_FMT_BGR48LE)
rgb48funcs(bgr, BE, PIX_FMT_BGR48BE)
#define input_pixel(i) ((origin == PIX_FMT_RGBA || origin == PIX_FMT_BGRA || \
origin == PIX_FMT_ARGB || origin == PIX_FMT_ABGR) ? AV_RN32A(&src[(i)*4]) : \
(isBE(origin) ? AV_RB16(&src[(i)*2]) : AV_RL16(&src[(i)*2])))
static av_always_inline void
rgb16_32ToY_c_template(int16_t *dst, const uint8_t *src,
int width, enum PixelFormat origin,
int shr, int shg, int shb, int shp,
int maskr, int maskg, int maskb,
int rsh, int gsh, int bsh, int S)
{
const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh;
const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
int i;
for (i = 0; i < width; i++) {
int px = input_pixel(i) >> shp;
int b = (px & maskb) >> shb;
int g = (px & maskg) >> shg;
int r = (px & maskr) >> shr;
dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
}
}
static av_always_inline void
rgb16_32ToUV_c_template(int16_t *dstU, int16_t *dstV,
const uint8_t *src, int width,
enum PixelFormat origin,
int shr, int shg, int shb, int shp,
int maskr, int maskg, int maskb,
int rsh, int gsh, int bsh, int S)
{
const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
rv = RV << rsh, gv = GV << gsh, bv = BV << bsh;
const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
int i;
for (i = 0; i < width; i++) {
int px = input_pixel(i) >> shp;
int b = (px & maskb) >> shb;
int g = (px & maskg) >> shg;
int r = (px & maskr) >> shr;
dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
}
}
static av_always_inline void
rgb16_32ToUV_half_c_template(int16_t *dstU, int16_t *dstV,
const uint8_t *src, int width,
enum PixelFormat origin,
int shr, int shg, int shb, int shp,
int maskr, int maskg, int maskb,
int rsh, int gsh, int bsh, int S)
{
const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
maskgx = ~(maskr | maskb);
const unsigned rnd = (256U<<(S)) + (1<<(S-6));
int i;
maskr |= maskr << 1; maskb |= maskb << 1; maskg |= maskg << 1;
for (i = 0; i < width; i++) {
int px0 = input_pixel(2 * i + 0) >> shp;
int px1 = input_pixel(2 * i + 1) >> shp;
int b, r, g = (px0 & maskgx) + (px1 & maskgx);
int rb = px0 + px1 - g;
b = (rb & maskb) >> shb;
if (shp || origin == PIX_FMT_BGR565LE || origin == PIX_FMT_BGR565BE ||
origin == PIX_FMT_RGB565LE || origin == PIX_FMT_RGB565BE) {
g >>= shg;
} else {
g = (g & maskg) >> shg;
}
r = (rb & maskr) >> shr;
dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
}
}
#undef input_pixel
#define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
maskg, maskb, rsh, gsh, bsh, S) \
static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
int width, uint32_t *unused) \
{ \
rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, \
shr, shg, shb, shp, \
maskr, maskg, maskb, rsh, gsh, bsh, S); \
} \
\
static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
int width, uint32_t *unused) \
{ \
rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
shr, shg, shb, shp, \
maskr, maskg, maskb, rsh, gsh, bsh, S); \
} \
\
static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
int width, uint32_t *unused) \
{ \
rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
shr, shg, shb, shp, \
maskr, maskg, maskb, rsh, gsh, bsh, S); \
}
rgb16_32_wrapper(PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT+8)
rgb16_32_wrapper(PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT+8)
rgb16_32_wrapper(PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT+8)
rgb16_32_wrapper(PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT+8)
rgb16_32_wrapper(PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT+8)
rgb16_32_wrapper(PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT+7)
rgb16_32_wrapper(PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT+4)
rgb16_32_wrapper(PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT+8)
rgb16_32_wrapper(PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT+7)
rgb16_32_wrapper(PIX_FMT_RGB444LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT+4)
rgb16_32_wrapper(PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT+8)
rgb16_32_wrapper(PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT+7)
rgb16_32_wrapper(PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT+4)
rgb16_32_wrapper(PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT+8)
rgb16_32_wrapper(PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT+7)
rgb16_32_wrapper(PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT+4)
static void gbr24pToUV_half_c(uint16_t *dstU, uint16_t *dstV,
const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
int width, enum PixelFormat origin)
{
int i;
for (i = 0; i < width; i++) {
unsigned int g = gsrc[2*i] + gsrc[2*i+1];
unsigned int b = bsrc[2*i] + bsrc[2*i+1];
unsigned int r = rsrc[2*i] + rsrc[2*i+1];
dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
}
}
static void abgrToA_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
{
int i;
for (i=0; i<width; i++) {
dst[i]= src[4*i]<<6;
}
}
static void rgbaToA_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
{
int i;
for (i=0; i<width; i++) {
dst[i]= src[4*i+3]<<6;
}
}
static void palToA_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
{
int i;
for (i=0; i<width; i++) {
int d= src[i];
dst[i]= (pal[d] >> 24)<<6;
}
}
static void palToY_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, long width, uint32_t *pal)
{
int i;
for (i=0; i<width; i++) {
int d= src[i];
dst[i]= (pal[d] & 0xFF)<<6;
}
}
static void palToUV_c(uint16_t *dstU, int16_t *dstV,
const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
int width, uint32_t *pal)
{
int i;
assert(src1 == src2);
for (i=0; i<width; i++) {
int p= pal[src1[i]];
dstU[i]= (uint8_t)(p>> 8)<<6;
dstV[i]= (uint8_t)(p>>16)<<6;
}
}
static void monowhite2Y_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
{
int i, j;
for (i=0; i<width/8; i++) {
int d= ~src[i];
for(j=0; j<8; j++)
dst[8*i+j]= ((d>>(7-j))&1)*16383;
}
if(width&7){
int d= ~src[i];
for(j=0; j<(width&7); j++)
dst[8*i+j]= ((d>>(7-j))&1)*16383;
}
}
static void monoblack2Y_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
{
int i, j;
for (i=0; i<width/8; i++) {
int d= src[i];
for(j=0; j<8; j++)
dst[8*i+j]= ((d>>(7-j))&1)*16383;
}
if(width&7){
int d= src[i];
for(j=0; j<(width&7); j++)
dst[8*i+j]= ((d>>(7-j))&1)*16383;
}
}
//FIXME yuy2* can read up to 7 samples too much
static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
uint32_t *unused)
{
int i;
for (i=0; i<width; i++)
dst[i]= src[2*i];
}
static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
const uint8_t *src2, int width, uint32_t *unused)
{
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[4*i + 1];
dstV[i]= src1[4*i + 3];
}
assert(src1 == src2);
}
static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
{
int i;
const uint16_t *src = (const uint16_t *) _src;
uint16_t *dst = (uint16_t *) _dst;
for (i=0; i<width; i++) {
dst[i] = av_bswap16(src[i]);
}
}
static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
const uint8_t *_src2, int width, uint32_t *unused)
{
int i;
const uint16_t *src1 = (const uint16_t *) _src1,
*src2 = (const uint16_t *) _src2;
uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV;
for (i=0; i<width; i++) {
dstU[i] = av_bswap16(src1[i]);
dstV[i] = av_bswap16(src2[i]);
}
}
/* This is almost identical to the previous, end exists only because
* yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses. */
static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
uint32_t *unused)
{
int i;
for (i=0; i<width; i++)
dst[i]= src[2*i+1];
}
static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
const uint8_t *src2, int width, uint32_t *unused)
{
int i;
for (i=0; i<width; i++) {
dstU[i]= src1[4*i + 0];
dstV[i]= src1[4*i + 2];
}
assert(src1 == src2);
}
static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
const uint8_t *src, int width)
{
int i;
for (i = 0; i < width; i++) {
dst1[i] = src[2*i+0];
dst2[i] = src[2*i+1];
}
}
static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
int width, uint32_t *unused)
{
nvXXtoUV_c(dstU, dstV, src1, width);
}
static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
int width, uint32_t *unused)
{
nvXXtoUV_c(dstV, dstU, src1, width);
}
#define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
static void bgr24ToY_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
int width, uint32_t *unused)
{
int i;
for (i=0; i<width; i++) {
int b= src[i*3+0];
int g= src[i*3+1];
int r= src[i*3+2];
dst[i]= ((RY*r + GY*g + BY*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
}
}
static void bgr24ToUV_c(int16_t *dstU, int16_t *dstV, const uint8_t *unused0, const uint8_t *src1,
const uint8_t *src2, int width, uint32_t *unused)
{
int i;
for (i=0; i<width; i++) {
int b= src1[3*i + 0];
int g= src1[3*i + 1];
int r= src1[3*i + 2];
dstU[i]= (RU*r + GU*g + BU*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
dstV[i]= (RV*r + GV*g + BV*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
}
assert(src1 == src2);
}
static void bgr24ToUV_half_c(int16_t *dstU, int16_t *dstV, const uint8_t *unused0, const uint8_t *src1,
const uint8_t *src2, int width, uint32_t *unused)
{
int i;
for (i=0; i<width; i++) {
int b= src1[6*i + 0] + src1[6*i + 3];
int g= src1[6*i + 1] + src1[6*i + 4];
int r= src1[6*i + 2] + src1[6*i + 5];
dstU[i]= (RU*r + GU*g + BU*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
dstV[i]= (RV*r + GV*g + BV*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
}
assert(src1 == src2);
}
static void rgb24ToY_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
uint32_t *unused)
{
int i;
for (i=0; i<width; i++) {
int r= src[i*3+0];
int g= src[i*3+1];
int b= src[i*3+2];
dst[i]= ((RY*r + GY*g + BY*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
}
}
static void rgb24ToUV_c(int16_t *dstU, int16_t *dstV, const uint8_t *unused0, const uint8_t *src1,
const uint8_t *src2, int width, uint32_t *unused)
{
int i;
assert(src1==src2);
for (i=0; i<width; i++) {
int r= src1[3*i + 0];
int g= src1[3*i + 1];
int b= src1[3*i + 2];
dstU[i]= (RU*r + GU*g + BU*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
dstV[i]= (RV*r + GV*g + BV*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
}
}
static void rgb24ToUV_half_c(int16_t *dstU, int16_t *dstV, const uint8_t *unused0, const uint8_t *src1,
const uint8_t *src2, int width, uint32_t *unused)
{
int i;
assert(src1==src2);
for (i=0; i<width; i++) {
int r= src1[6*i + 0] + src1[6*i + 3];
int g= src1[6*i + 1] + src1[6*i + 4];
int b= src1[6*i + 2] + src1[6*i + 5];
dstU[i]= (RU*r + GU*g + BU*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
dstV[i]= (RV*r + GV*g + BV*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
}
}
static void planar_rgb_to_y(uint16_t *dst, const uint8_t *src[4], int width)
{
int i;
for (i = 0; i < width; i++) {
int g = src[0][i];
int b = src[1][i];
int r = src[2][i];
dst[i] = (RY*r + GY*g + BY*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
}
}
static void planar_rgb16le_to_y(uint8_t *_dst, const uint8_t *_src[4], int width)
{
int i;
const uint16_t **src = (const uint16_t **) _src;
uint16_t *dst = (uint16_t *) _dst;
for (i = 0; i < width; i++) {
int g = AV_RL16(src[0] + i);
int b = AV_RL16(src[1] + i);
int r = AV_RL16(src[2] + i);
dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
}
}
static void planar_rgb16be_to_y(uint8_t *_dst, const uint8_t *_src[4], int width)
{
int i;
const uint16_t **src = (const uint16_t **) _src;
uint16_t *dst = (uint16_t *) _dst;
for (i = 0; i < width; i++) {
int g = AV_RB16(src[0] + i);
int b = AV_RB16(src[1] + i);
int r = AV_RB16(src[2] + i);
dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
}
}
static void planar_rgb_to_uv(uint16_t *dstU, uint16_t *dstV, const uint8_t *src[4], int width)
{
int i;
for (i = 0; i < width; i++) {
int g = src[0][i];
int b = src[1][i];
int r = src[2][i];
dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
}
}
static void planar_rgb16le_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src[4], int width)
{
int i;
const uint16_t **src = (const uint16_t **) _src;
uint16_t *dstU = (uint16_t *) _dstU;
uint16_t *dstV = (uint16_t *) _dstV;
for (i = 0; i < width; i++) {
int g = AV_RL16(src[0] + i);
int b = AV_RL16(src[1] + i);
int r = AV_RL16(src[2] + i);
dstU[i] = (RU * r + GU * g + BU * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
dstV[i] = (RV * r + GV * g + BV * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
}
}
static void planar_rgb16be_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src[4], int width)
{
int i;
const uint16_t **src = (const uint16_t **) _src;
uint16_t *dstU = (uint16_t *) _dstU;
uint16_t *dstV = (uint16_t *) _dstV;
for (i = 0; i < width; i++) {
int g = AV_RB16(src[0] + i);
int b = AV_RB16(src[1] + i);
int r = AV_RB16(src[2] + i);
dstU[i] = (RU * r + GU * g + BU * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
dstV[i] = (RV * r + GV * g + BV * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
}
}
static void hScale16To19_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src,
const int16_t *filter,
const int32_t *filterPos, int filterSize)
{
int i;
int32_t *dst = (int32_t *) _dst;
const uint16_t *src = (const uint16_t *) _src;
int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1;
int sh = bits - 4;
if((isAnyRGB(c->srcFormat) || c->srcFormat==PIX_FMT_PAL8) && av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1<15)
sh= 9;
for (i = 0; i < dstW; i++) {
int j;
int srcPos = filterPos[i];
int val = 0;
for (j = 0; j < filterSize; j++) {
val += src[srcPos + j] * filter[filterSize * i + j];
}
// filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit
dst[i] = FFMIN(val >> sh, (1 << 19) - 1);
}
}
static void hScale16To15_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *_src,
const int16_t *filter,
const int32_t *filterPos, int filterSize)
{
int i;
const uint16_t *src = (const uint16_t *) _src;
int sh = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1;
if(sh<15)
sh= isAnyRGB(c->srcFormat) || c->srcFormat==PIX_FMT_PAL8 ? 13 : av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1;
for (i = 0; i < dstW; i++) {
int j;
int srcPos = filterPos[i];
int val = 0;
for (j = 0; j < filterSize; j++) {
val += src[srcPos + j] * filter[filterSize * i + j];
}
// filter=14 bit, input=16 bit, output=30 bit, >> 15 makes 15 bit
dst[i] = FFMIN(val >> sh, (1 << 15) - 1);
}
}
// bilinear / bicubic scaling
static void hScale8To15_c(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src,
const int16_t *filter, const int32_t *filterPos,
int filterSize)
{
int i;
for (i=0; i<dstW; i++) {
int j;
int srcPos= filterPos[i];
int val=0;
for (j=0; j<filterSize; j++) {
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
//filter += hFilterSize;
dst[i] = FFMIN(val>>7, (1<<15)-1); // the cubic equation does overflow ...
//dst[i] = val>>7;
}
}
static void hScale8To19_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *src,
const int16_t *filter, const int32_t *filterPos,
int filterSize)
{
int i;
int32_t *dst = (int32_t *) _dst;
for (i=0; i<dstW; i++) {
int j;
int srcPos= filterPos[i];
int val=0;
for (j=0; j<filterSize; j++) {
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
//filter += hFilterSize;
dst[i] = FFMIN(val>>3, (1<<19)-1); // the cubic equation does overflow ...
//dst[i] = val>>7;
}
}
//FIXME all pal and rgb srcFormats could do this convertion as well
//FIXME all scalers more complex than bilinear could do half of this transform
static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width)
{
int i;
for (i = 0; i < width; i++) {
dstU[i] = (FFMIN(dstU[i],30775)*4663 - 9289992)>>12; //-264
dstV[i] = (FFMIN(dstV[i],30775)*4663 - 9289992)>>12; //-264
}
}
static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width)
{
int i;
for (i = 0; i < width; i++) {
dstU[i] = (dstU[i]*1799 + 4081085)>>11; //1469
dstV[i] = (dstV[i]*1799 + 4081085)>>11; //1469
}
}
static void lumRangeToJpeg_c(int16_t *dst, int width)
{
int i;
for (i = 0; i < width; i++)
dst[i] = (FFMIN(dst[i],30189)*19077 - 39057361)>>14;
}
static void lumRangeFromJpeg_c(int16_t *dst, int width)
{
int i;
for (i = 0; i < width; i++)
dst[i] = (dst[i]*14071 + 33561947)>>14;
}
static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width)
{
int i;
int32_t *dstU = (int32_t *) _dstU;
int32_t *dstV = (int32_t *) _dstV;
for (i = 0; i < width; i++) {
dstU[i] = (FFMIN(dstU[i],30775<<4)*4663 - (9289992<<4))>>12; //-264
dstV[i] = (FFMIN(dstV[i],30775<<4)*4663 - (9289992<<4))>>12; //-264
}
}
static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width)
{
int i;
int32_t *dstU = (int32_t *) _dstU;
int32_t *dstV = (int32_t *) _dstV;
for (i = 0; i < width; i++) {
dstU[i] = (dstU[i]*1799 + (4081085<<4))>>11; //1469
dstV[i] = (dstV[i]*1799 + (4081085<<4))>>11; //1469
}
}
static void lumRangeToJpeg16_c(int16_t *_dst, int width)
{
int i;
int32_t *dst = (int32_t *) _dst;
for (i = 0; i < width; i++)
dst[i] = (FFMIN(dst[i],30189<<4)*4769 - (39057361<<2))>>12;
}
static void lumRangeFromJpeg16_c(int16_t *_dst, int width)
{
int i;
int32_t *dst = (int32_t *) _dst;
for (i = 0; i < width; i++)
dst[i] = (dst[i]*(14071/4) + (33561947<<4)/4)>>12;
}
static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
const uint8_t *src, int srcW, int xInc)
{
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
dst[i] = src[srcW-1]*128;
}
// *** horizontal scale Y line to temp buffer
static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth,
const uint8_t *src_in[4], int srcW, int xInc,
const int16_t *hLumFilter,
const int32_t *hLumFilterPos, int hLumFilterSize,
uint8_t *formatConvBuffer,
uint32_t *pal, int isAlpha)
{
void (*toYV12)(uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
const uint8_t *src = src_in[isAlpha ? 3 : 0];
if (toYV12) {
toYV12(formatConvBuffer, src, src_in[1], src_in[2], srcW, pal);
src= formatConvBuffer;
} else if (c->readLumPlanar && !isAlpha) {
c->readLumPlanar(formatConvBuffer, src_in, srcW);
src = formatConvBuffer;
}
if (!c->hyscale_fast) {
c->hyScale(c, dst, dstWidth, src, hLumFilter, hLumFilterPos, hLumFilterSize);
} else { // fast bilinear upscale / crap downscale
c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
}
if (convertRange)
convertRange(dst, dstWidth);
}
static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst1[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst2[i]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
}
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
dst1[i] = src1[srcW-1]*128;
dst2[i] = src2[srcW-1]*128;
}
}
static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth,
const uint8_t *src_in[4],
int srcW, int xInc, const int16_t *hChrFilter,
const int32_t *hChrFilterPos, int hChrFilterSize,
uint8_t *formatConvBuffer, uint32_t *pal)
{
const uint8_t *src1 = src_in[1], *src2 = src_in[2];
if (c->chrToYV12) {
uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16);
c->chrToYV12(formatConvBuffer, buf2, src_in[0], src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= buf2;
} else if (c->readChrPlanar) {
uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16);
c->readChrPlanar(formatConvBuffer, buf2, src_in, srcW);
src1= formatConvBuffer;
src2= buf2;
}
if (!c->hcscale_fast) {
c->hcScale(c, dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize);
c->hcScale(c, dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize);
} else { // fast bilinear upscale / crap downscale
c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc);
}
if (c->chrConvertRange)
c->chrConvertRange(dst1, dst2, dstWidth);
}
static av_always_inline void
find_c_packed_planar_out_funcs(SwsContext *c,
yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX,
yuv2interleavedX_fn *yuv2nv12cX,
yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2,
yuv2packedX_fn *yuv2packedX)
{
enum PixelFormat dstFormat = c->dstFormat;
if (is16BPS(dstFormat)) {
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
} else if (is9_OR_10BPS(dstFormat)) {
if (av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1 == 8) {
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
} else {
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
}
} else {
*yuv2plane1 = yuv2plane1_8_c;
*yuv2planeX = yuv2planeX_8_c;
if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)
*yuv2nv12cX = yuv2nv12cX_c;
}
if(c->flags & SWS_FULL_CHR_H_INT) {
switch (dstFormat) {
case PIX_FMT_RGBA:
#if CONFIG_SMALL
*yuv2packedX = yuv2rgba32_full_X_c;
#else
#if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) {
*yuv2packedX = yuv2rgba32_full_X_c;
} else
#endif /* CONFIG_SWSCALE_ALPHA */
{
*yuv2packedX = yuv2rgbx32_full_X_c;
}
#endif /* !CONFIG_SMALL */
break;
case PIX_FMT_ARGB:
#if CONFIG_SMALL
*yuv2packedX = yuv2argb32_full_X_c;
#else
#if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) {
*yuv2packedX = yuv2argb32_full_X_c;
} else
#endif /* CONFIG_SWSCALE_ALPHA */
{
*yuv2packedX = yuv2xrgb32_full_X_c;
}
#endif /* !CONFIG_SMALL */
break;
case PIX_FMT_BGRA:
#if CONFIG_SMALL
*yuv2packedX = yuv2bgra32_full_X_c;
#else
#if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) {
*yuv2packedX = yuv2bgra32_full_X_c;
} else
#endif /* CONFIG_SWSCALE_ALPHA */
{
*yuv2packedX = yuv2bgrx32_full_X_c;
}
#endif /* !CONFIG_SMALL */
break;
case PIX_FMT_ABGR:
#if CONFIG_SMALL
*yuv2packedX = yuv2abgr32_full_X_c;
#else
#if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) {
*yuv2packedX = yuv2abgr32_full_X_c;
} else
#endif /* CONFIG_SWSCALE_ALPHA */
{
*yuv2packedX = yuv2xbgr32_full_X_c;
}
#endif /* !CONFIG_SMALL */
break;
case PIX_FMT_RGB24:
*yuv2packedX = yuv2rgb24_full_X_c;
break;
case PIX_FMT_BGR24:
*yuv2packedX = yuv2bgr24_full_X_c;
break;
}
if(!*yuv2packedX)
goto YUV_PACKED;
} else {
YUV_PACKED:
switch (dstFormat) {
case PIX_FMT_RGB48LE:
*yuv2packed1 = yuv2rgb48le_1_c;
*yuv2packed2 = yuv2rgb48le_2_c;
*yuv2packedX = yuv2rgb48le_X_c;
break;
case PIX_FMT_RGB48BE:
*yuv2packed1 = yuv2rgb48be_1_c;
*yuv2packed2 = yuv2rgb48be_2_c;
*yuv2packedX = yuv2rgb48be_X_c;
break;
case PIX_FMT_BGR48LE:
*yuv2packed1 = yuv2bgr48le_1_c;
*yuv2packed2 = yuv2bgr48le_2_c;
*yuv2packedX = yuv2bgr48le_X_c;
break;
case PIX_FMT_BGR48BE:
*yuv2packed1 = yuv2bgr48be_1_c;
*yuv2packed2 = yuv2bgr48be_2_c;
*yuv2packedX = yuv2bgr48be_X_c;
break;
case PIX_FMT_RGB32:
case PIX_FMT_BGR32:
#if CONFIG_SMALL
*yuv2packed1 = yuv2rgb32_1_c;
*yuv2packed2 = yuv2rgb32_2_c;
*yuv2packedX = yuv2rgb32_X_c;
#else
#if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) {
*yuv2packed1 = yuv2rgba32_1_c;
*yuv2packed2 = yuv2rgba32_2_c;
*yuv2packedX = yuv2rgba32_X_c;
} else
#endif /* CONFIG_SWSCALE_ALPHA */
{
*yuv2packed1 = yuv2rgbx32_1_c;
*yuv2packed2 = yuv2rgbx32_2_c;
*yuv2packedX = yuv2rgbx32_X_c;
}
#endif /* !CONFIG_SMALL */
break;
case PIX_FMT_RGB32_1:
case PIX_FMT_BGR32_1:
#if CONFIG_SMALL
*yuv2packed1 = yuv2rgb32_1_1_c;
*yuv2packed2 = yuv2rgb32_1_2_c;
*yuv2packedX = yuv2rgb32_1_X_c;
#else
#if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) {
*yuv2packed1 = yuv2rgba32_1_1_c;
*yuv2packed2 = yuv2rgba32_1_2_c;
*yuv2packedX = yuv2rgba32_1_X_c;
} else
#endif /* CONFIG_SWSCALE_ALPHA */
{
*yuv2packed1 = yuv2rgbx32_1_1_c;
*yuv2packed2 = yuv2rgbx32_1_2_c;
*yuv2packedX = yuv2rgbx32_1_X_c;
}
#endif /* !CONFIG_SMALL */
break;
case PIX_FMT_RGB24:
*yuv2packed1 = yuv2rgb24_1_c;
*yuv2packed2 = yuv2rgb24_2_c;
*yuv2packedX = yuv2rgb24_X_c;
break;
case PIX_FMT_BGR24:
*yuv2packed1 = yuv2bgr24_1_c;
*yuv2packed2 = yuv2bgr24_2_c;
*yuv2packedX = yuv2bgr24_X_c;
break;
case PIX_FMT_RGB565LE:
case PIX_FMT_RGB565BE:
case PIX_FMT_BGR565LE:
case PIX_FMT_BGR565BE:
*yuv2packed1 = yuv2rgb16_1_c;
*yuv2packed2 = yuv2rgb16_2_c;
*yuv2packedX = yuv2rgb16_X_c;
break;
case PIX_FMT_RGB555LE:
case PIX_FMT_RGB555BE:
case PIX_FMT_BGR555LE:
case PIX_FMT_BGR555BE:
*yuv2packed1 = yuv2rgb15_1_c;
*yuv2packed2 = yuv2rgb15_2_c;
*yuv2packedX = yuv2rgb15_X_c;
break;
case PIX_FMT_RGB444LE:
case PIX_FMT_RGB444BE:
case PIX_FMT_BGR444LE:
case PIX_FMT_BGR444BE:
*yuv2packed1 = yuv2rgb12_1_c;
*yuv2packed2 = yuv2rgb12_2_c;
*yuv2packedX = yuv2rgb12_X_c;
break;
case PIX_FMT_RGB8:
case PIX_FMT_BGR8:
*yuv2packed1 = yuv2rgb8_1_c;
*yuv2packed2 = yuv2rgb8_2_c;
*yuv2packedX = yuv2rgb8_X_c;
break;
case PIX_FMT_RGB4:
case PIX_FMT_BGR4:
*yuv2packed1 = yuv2rgb4_1_c;
*yuv2packed2 = yuv2rgb4_2_c;
*yuv2packedX = yuv2rgb4_X_c;
break;
case PIX_FMT_RGB4_BYTE:
case PIX_FMT_BGR4_BYTE:
*yuv2packed1 = yuv2rgb4b_1_c;
*yuv2packed2 = yuv2rgb4b_2_c;
*yuv2packedX = yuv2rgb4b_X_c;
break;
}
}
switch (dstFormat) {
case PIX_FMT_GRAY16BE:
*yuv2packed1 = yuv2gray16BE_1_c;
*yuv2packed2 = yuv2gray16BE_2_c;
*yuv2packedX = yuv2gray16BE_X_c;
break;
case PIX_FMT_GRAY16LE:
*yuv2packed1 = yuv2gray16LE_1_c;
*yuv2packed2 = yuv2gray16LE_2_c;
*yuv2packedX = yuv2gray16LE_X_c;
break;
case PIX_FMT_MONOWHITE:
*yuv2packed1 = yuv2monowhite_1_c;
*yuv2packed2 = yuv2monowhite_2_c;
*yuv2packedX = yuv2monowhite_X_c;
break;
case PIX_FMT_MONOBLACK:
*yuv2packed1 = yuv2monoblack_1_c;
*yuv2packed2 = yuv2monoblack_2_c;
*yuv2packedX = yuv2monoblack_X_c;
break;
case PIX_FMT_YUYV422:
*yuv2packed1 = yuv2yuyv422_1_c;
*yuv2packed2 = yuv2yuyv422_2_c;
*yuv2packedX = yuv2yuyv422_X_c;
break;
case PIX_FMT_UYVY422:
*yuv2packed1 = yuv2uyvy422_1_c;
*yuv2packed2 = yuv2uyvy422_2_c;
*yuv2packedX = yuv2uyvy422_X_c;
break;
}
}
#define DEBUG_SWSCALE_BUFFERS 0
#define DEBUG_BUFFERS(...) if (DEBUG_SWSCALE_BUFFERS) av_log(c, AV_LOG_DEBUG, __VA_ARGS__)
static int swScale(SwsContext *c, const uint8_t* src[],
int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
/* load a few things into local vars to make the code more readable? and faster */
const int srcW= c->srcW;
const int dstW= c->dstW;
const int dstH= c->dstH;
const int chrDstW= c->chrDstW;
const int chrSrcW= c->chrSrcW;
const int lumXInc= c->lumXInc;
const int chrXInc= c->chrXInc;
const enum PixelFormat dstFormat= c->dstFormat;
const int flags= c->flags;
int32_t *vLumFilterPos= c->vLumFilterPos;
int32_t *vChrFilterPos= c->vChrFilterPos;
int32_t *hLumFilterPos= c->hLumFilterPos;
int32_t *hChrFilterPos= c->hChrFilterPos;
int16_t *hLumFilter= c->hLumFilter;
int16_t *hChrFilter= c->hChrFilter;
int32_t *lumMmxFilter= c->lumMmxFilter;
int32_t *chrMmxFilter= c->chrMmxFilter;
int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
const int vLumFilterSize= c->vLumFilterSize;
const int vChrFilterSize= c->vChrFilterSize;
const int hLumFilterSize= c->hLumFilterSize;
const int hChrFilterSize= c->hChrFilterSize;
int16_t **lumPixBuf= c->lumPixBuf;
int16_t **chrUPixBuf= c->chrUPixBuf;
int16_t **chrVPixBuf= c->chrVPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
uint8_t *formatConvBuffer= c->formatConvBuffer;
const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
int lastDstY;
uint32_t *pal=c->pal_yuv;
int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat);
yuv2planar1_fn yuv2plane1 = c->yuv2plane1;
yuv2planarX_fn yuv2planeX = c->yuv2planeX;
yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX;
yuv2packed1_fn yuv2packed1 = c->yuv2packed1;
yuv2packed2_fn yuv2packed2 = c->yuv2packed2;
yuv2packedX_fn yuv2packedX = c->yuv2packedX;
/* vars which will change and which we need to store back in the context */
int dstY= c->dstY;
int lumBufIndex= c->lumBufIndex;
int chrBufIndex= c->chrBufIndex;
int lastInLumBuf= c->lastInLumBuf;
int lastInChrBuf= c->lastInChrBuf;
if (isPacked(c->srcFormat)) {
src[0]=
src[1]=
src[2]=
src[3]= src[0];
srcStride[0]=
srcStride[1]=
srcStride[2]=
srcStride[3]= srcStride[0];
}
srcStride[1]<<= c->vChrDrop;
srcStride[2]<<= c->vChrDrop;
DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],
dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);
DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
srcSliceY, srcSliceH, dstY, dstH);
DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
if (dstStride[0]%16 !=0 || dstStride[1]%16 !=0 || dstStride[2]%16 !=0 || dstStride[3]%16 != 0) {
static int warnedAlready=0; //FIXME move this into the context perhaps
if (flags & SWS_PRINT_INFO && !warnedAlready) {
av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
warnedAlready=1;
}
}
if ((int)dst[0]%16 || (int)dst[1]%16 || (int)dst[2]%16 || (int)src[0]%16 || (int)src[1]%16 || (int)src[2]%16
|| dstStride[0]%16 || dstStride[1]%16 || dstStride[2]%16 || dstStride[3]%16
|| srcStride[0]%16 || srcStride[1]%16 || srcStride[2]%16 || srcStride[3]%16
) {
static int warnedAlready=0;
int cpu_flags = av_get_cpu_flags();
if (HAVE_MMX2 && (cpu_flags & AV_CPU_FLAG_SSE2) && !warnedAlready){
av_log(c, AV_LOG_WARNING, "Warning: data is not aligned! This can lead to a speedloss\n");
warnedAlready=1;
}
}
/* Note the user might start scaling the picture in the middle so this
will not get executed. This is not really intended but works
currently, so people might do it. */
if (srcSliceY ==0) {
lumBufIndex=-1;
chrBufIndex=-1;
dstY=0;
lastInLumBuf= -1;
lastInChrBuf= -1;
}
if (!should_dither) {
c->chrDither8 = c->lumDither8 = ff_sws_pb_64;
}
lastDstY= dstY;
for (;dstY < dstH; dstY++) {
const int chrDstY= dstY>>c->chrDstVSubSample;
uint8_t *dest[4] = {
dst[0] + dstStride[0] * dstY,
dst[1] + dstStride[1] * chrDstY,
dst[2] + dstStride[2] * chrDstY,
(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL,
};
int use_mmx_vfilter= c->use_mmx_vfilter;
const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)];
const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input
int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; // Last line needed as input
int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input
int enough_lines;
//handle holes (FAST_BILINEAR & weird filters)
if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;
if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;
assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
DEBUG_BUFFERS("dstY: %d\n", dstY);
DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
firstLumSrcY, lastLumSrcY, lastInLumBuf);
DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
firstChrSrcY, lastChrSrcY, lastInChrBuf);
// Do we have enough lines in this slice to output the dstY line
enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);
if (!enough_lines) {
lastLumSrcY = srcSliceY + srcSliceH - 1;
lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
lastLumSrcY, lastChrSrcY);
}
//Do horizontal scaling
while(lastInLumBuf < lastLumSrcY) {
const uint8_t *src1[4] = {
src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0],
src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1],
src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2],
src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3],
};
lumBufIndex++;
assert(lumBufIndex < 2*vLumBufSize);
assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
assert(lastInLumBuf + 1 - srcSliceY >= 0);
hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 0);
if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src1, srcW,
lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,
formatConvBuffer,
pal, 1);
lastInLumBuf++;
DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
lumBufIndex, lastInLumBuf);
}
while(lastInChrBuf < lastChrSrcY) {
const uint8_t *src1[4] = {
src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0],
src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1],
src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2],
src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3],
};
chrBufIndex++;
assert(chrBufIndex < 2*vChrBufSize);
assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
//FIXME replace parameters through context struct (some at least)
if (c->needs_hcscale)
hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],
chrDstW, src1, chrSrcW, chrXInc,
hChrFilter, hChrFilterPos, hChrFilterSize,
formatConvBuffer, pal);
lastInChrBuf++;
DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
chrBufIndex, lastInChrBuf);
}
//wrap buf index around to stay inside the ring buffer
if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize;
if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize;
if (!enough_lines)
break; //we can't output a dstY line so let's try with the next slice
#if HAVE_MMX
updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf);
#endif
if (should_dither) {
c->chrDither8 = dither_8x8_128[chrDstY & 7];
c->lumDither8 = dither_8x8_128[dstY & 7];
}
if (dstY >= dstH-2) {
// hmm looks like we can't use MMX here without overwriting this array's tail
find_c_packed_planar_out_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX,
&yuv2packed1, &yuv2packed2, &yuv2packedX);
use_mmx_vfilter= 0;
}
{
const int16_t **lumSrcPtr= (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr= (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **chrVSrcPtr= (const int16_t **)(void*) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
int16_t *vLumFilter= c->vLumFilter;
int16_t *vChrFilter= c->vChrFilter;
if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like
const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
vLumFilter += dstY * vLumFilterSize;
vChrFilter += chrDstY * vChrFilterSize;
av_assert0(use_mmx_vfilter != (
yuv2planeX == yuv2planeX_10BE_c
|| yuv2planeX == yuv2planeX_10LE_c
|| yuv2planeX == yuv2planeX_9BE_c
|| yuv2planeX == yuv2planeX_9LE_c
|| yuv2planeX == yuv2planeX_16BE_c
|| yuv2planeX == yuv2planeX_16LE_c
|| yuv2planeX == yuv2planeX_8_c) || !ARCH_X86);
if(use_mmx_vfilter){
vLumFilter= (int16_t *)c->lumMmxFilter;
vChrFilter= (int16_t *)c->chrMmxFilter;
}
if (vLumFilterSize == 1) {
yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0);
} else {
yuv2planeX(vLumFilter, vLumFilterSize,
lumSrcPtr, dest[0], dstW, c->lumDither8, 0);
}
if (!((dstY&chrSkipMask) || isGray(dstFormat))) {
if (yuv2nv12cX) {
yuv2nv12cX(c, vChrFilter, vChrFilterSize, chrUSrcPtr, chrVSrcPtr, dest[1], chrDstW);
} else if (vChrFilterSize == 1) {
yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0);
yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3);
} else {
yuv2planeX(vChrFilter, vChrFilterSize,
chrUSrcPtr, dest[1], chrDstW, c->chrDither8, 0);
yuv2planeX(vChrFilter, vChrFilterSize,
chrVSrcPtr, dest[2], chrDstW, c->chrDither8, use_mmx_vfilter ? (c->uv_offx2 >> 1) : 3);
}
}
if (CONFIG_SWSCALE_ALPHA && alpPixBuf){
if(use_mmx_vfilter){
vLumFilter= (int16_t *)c->alpMmxFilter;
}
if (vLumFilterSize == 1) {
yuv2plane1(alpSrcPtr[0], dest[3], dstW, c->lumDither8, 0);
} else {
yuv2planeX(vLumFilter, vLumFilterSize,
alpSrcPtr, dest[3], dstW, c->lumDither8, 0);
}
}
} else {
assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2);
assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2);
if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB
int chrAlpha = vChrFilter[2 * dstY + 1];
yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
alpPixBuf ? *alpSrcPtr : NULL,
dest[0], dstW, chrAlpha, dstY);
} else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB
int lumAlpha = vLumFilter[2 * dstY + 1];
int chrAlpha = vChrFilter[2 * dstY + 1];
lumMmxFilter[2] =
lumMmxFilter[3] = vLumFilter[2 * dstY ] * 0x10001;
chrMmxFilter[2] =
chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001;
yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
alpPixBuf ? alpSrcPtr : NULL,
dest[0], dstW, lumAlpha, chrAlpha, dstY);
} else { //general RGB
yuv2packedX(c, vLumFilter + dstY * vLumFilterSize,
lumSrcPtr, vLumFilterSize,
vChrFilter + dstY * vChrFilterSize,
chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
alpSrcPtr, dest[0], dstW, dstY);
}
}
}
}
if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)
fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);
#if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile("sfence":::"memory");
#endif
emms_c();
/* store changed local vars back in the context */
c->dstY= dstY;
c->lumBufIndex= lumBufIndex;
c->chrBufIndex= chrBufIndex;
c->lastInLumBuf= lastInLumBuf;
c->lastInChrBuf= lastInChrBuf;
return dstY - lastDstY;
}
static av_cold void sws_init_swScale_c(SwsContext *c)
{
typedef void (*_chrToYV12)(uint8_t *,uint8_t *,const uint8_t *,const uint8_t *,const uint8_t *,int,uint32_t *);
typedef void (*_readChrPlanar)(uint8_t *,uint8_t *,const uint8_t *[],int);
typedef void (*_readLumPlanar)(uint8_t *,const uint8_t *[],int);
typedef void (*_lumToYV12)(uint8_t *,const uint8_t *,const uint8_t *,const uint8_t *,int,uint32_t *);
typedef void (*_alpToYV12)(uint8_t *,const uint8_t *,const uint8_t *,const uint8_t *,int,uint32_t *);
enum PixelFormat srcFormat = c->srcFormat;
find_c_packed_planar_out_funcs(c, &c->yuv2plane1, &c->yuv2planeX,
&c->yuv2nv12cX, &c->yuv2packed1, &c->yuv2packed2,
&c->yuv2packedX);
c->chrToYV12 = NULL;
switch(srcFormat) {
case PIX_FMT_YUYV422 : c->chrToYV12 = (_chrToYV12)yuy2ToUV_c; break;
case PIX_FMT_UYVY422 : c->chrToYV12 = (_chrToYV12)uyvyToUV_c; break;
case PIX_FMT_NV12 : c->chrToYV12 = (_chrToYV12)nv12ToUV_c; break;
case PIX_FMT_NV21 : c->chrToYV12 = (_chrToYV12)nv21ToUV_c; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->chrToYV12 = (_chrToYV12)palToUV_c; break;
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readChrPlanar = (_readChrPlanar)planar_rgb16le_to_uv; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readChrPlanar = (_readChrPlanar)planar_rgb16be_to_uv; break;
case PIX_FMT_GBRP: c->readChrPlanar = (_readChrPlanar)planar_rgb_to_uv; break;
#if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE: c->chrToYV12 = (_chrToYV12)bswap16UV_c; break;
#else
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE: c->chrToYV12 = (_chrToYV12)bswap16UV_c; break;
#endif
}
if (c->chrSrcHSubSample) {
switch(srcFormat) {
case PIX_FMT_RGB48BE : c->chrToYV12 = (_chrToYV12)rgb48BEToUV_half_c; break;
case PIX_FMT_RGB48LE : c->chrToYV12 = (_chrToYV12)rgb48LEToUV_half_c; break;
case PIX_FMT_BGR48BE : c->chrToYV12 = (_chrToYV12)bgr48BEToUV_half_c; break;
case PIX_FMT_BGR48LE : c->chrToYV12 = (_chrToYV12)bgr48LEToUV_half_c; break;
case PIX_FMT_RGB32 : c->chrToYV12 = (_chrToYV12)bgr32ToUV_half_c; break;
case PIX_FMT_RGB32_1 : c->chrToYV12 = (_chrToYV12)bgr321ToUV_half_c; break;
case PIX_FMT_BGR24 : c->chrToYV12 = (_chrToYV12)bgr24ToUV_half_c; break;
case PIX_FMT_BGR565LE: c->chrToYV12 = (_chrToYV12)bgr16leToUV_half_c; break;
case PIX_FMT_BGR565BE: c->chrToYV12 = (_chrToYV12)bgr16beToUV_half_c; break;
case PIX_FMT_BGR555LE: c->chrToYV12 = (_chrToYV12)bgr15leToUV_half_c; break;
case PIX_FMT_BGR555BE: c->chrToYV12 = (_chrToYV12)bgr15beToUV_half_c; break;
case PIX_FMT_BGR444LE: c->chrToYV12 = (_chrToYV12)bgr12leToUV_half_c; break;
case PIX_FMT_BGR444BE: c->chrToYV12 = (_chrToYV12)bgr12beToUV_half_c; break;
case PIX_FMT_BGR32 : c->chrToYV12 = (_chrToYV12)rgb32ToUV_half_c; break;
case PIX_FMT_BGR32_1 : c->chrToYV12 = (_chrToYV12)rgb321ToUV_half_c; break;
case PIX_FMT_RGB24 : c->chrToYV12 = (_chrToYV12)rgb24ToUV_half_c; break;
case PIX_FMT_RGB565LE: c->chrToYV12 = (_chrToYV12)rgb16leToUV_half_c; break;
case PIX_FMT_RGB565BE: c->chrToYV12 = (_chrToYV12)rgb16beToUV_half_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = (_chrToYV12)rgb15leToUV_half_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = (_chrToYV12)rgb15beToUV_half_c; break;
case PIX_FMT_GBR24P : c->chrToYV12 = (_chrToYV12)gbr24pToUV_half_c; break;
case PIX_FMT_RGB444LE: c->chrToYV12 = (_chrToYV12)rgb12leToUV_half_c; break;
case PIX_FMT_RGB444BE: c->chrToYV12 = (_chrToYV12)rgb12beToUV_half_c; break;
}
} else {
switch(srcFormat) {
case PIX_FMT_RGB48BE : c->chrToYV12 = (_chrToYV12)rgb48BEToUV_c; break;
case PIX_FMT_RGB48LE : c->chrToYV12 = (_chrToYV12)rgb48LEToUV_c; break;
case PIX_FMT_BGR48BE : c->chrToYV12 = (_chrToYV12)bgr48BEToUV_c; break;
case PIX_FMT_BGR48LE : c->chrToYV12 = (_chrToYV12)bgr48LEToUV_c; break;
case PIX_FMT_RGB32 : c->chrToYV12 = (_chrToYV12)bgr32ToUV_c; break;
case PIX_FMT_RGB32_1 : c->chrToYV12 = (_chrToYV12)bgr321ToUV_c; break;
case PIX_FMT_BGR24 : c->chrToYV12 = (_chrToYV12)bgr24ToUV_c; break;
case PIX_FMT_BGR565LE: c->chrToYV12 = (_chrToYV12)bgr16leToUV_c; break;
case PIX_FMT_BGR565BE: c->chrToYV12 = (_chrToYV12)bgr16beToUV_c; break;
case PIX_FMT_BGR555LE: c->chrToYV12 = (_chrToYV12)bgr15leToUV_c; break;
case PIX_FMT_BGR555BE: c->chrToYV12 = (_chrToYV12)bgr15beToUV_c; break;
case PIX_FMT_BGR444LE: c->chrToYV12 = (_chrToYV12)bgr12leToUV_c; break;
case PIX_FMT_BGR444BE: c->chrToYV12 = (_chrToYV12)bgr12beToUV_c; break;
case PIX_FMT_BGR32 : c->chrToYV12 = (_chrToYV12)rgb32ToUV_c; break;
case PIX_FMT_BGR32_1 : c->chrToYV12 = (_chrToYV12)rgb321ToUV_c; break;
case PIX_FMT_RGB24 : c->chrToYV12 = (_chrToYV12)rgb24ToUV_c; break;
case PIX_FMT_RGB565LE: c->chrToYV12 = (_chrToYV12)rgb16leToUV_c; break;
case PIX_FMT_RGB565BE: c->chrToYV12 = (_chrToYV12)rgb16beToUV_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = (_chrToYV12)rgb15leToUV_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = (_chrToYV12)rgb15beToUV_c; break;
case PIX_FMT_RGB444LE: c->chrToYV12 = (_chrToYV12)rgb12leToUV_c; break;
case PIX_FMT_RGB444BE: c->chrToYV12 = (_chrToYV12)rgb12beToUV_c; break;
}
}
c->lumToYV12 = NULL;
c->alpToYV12 = NULL;
switch (srcFormat) {
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readLumPlanar = (_readLumPlanar)planar_rgb16le_to_y; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readLumPlanar = (_readLumPlanar)planar_rgb16be_to_y; break;
case PIX_FMT_GBRP: c->readLumPlanar = (_readLumPlanar)planar_rgb_to_y; break;
#if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE:
case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break;
#else
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE:
case PIX_FMT_GRAY16BE : c->lumToYV12 = (_lumToYV12)bswap16Y_c; break;
#endif
case PIX_FMT_YUYV422 :
case PIX_FMT_Y400A : c->lumToYV12 = (_lumToYV12)yuy2ToY_c; break;
case PIX_FMT_UYVY422 : c->lumToYV12 = (_lumToYV12)uyvyToY_c; break;
case PIX_FMT_BGR24 : c->lumToYV12 = (_lumToYV12)bgr24ToY_c; break;
case PIX_FMT_BGR565LE : c->lumToYV12 = (_lumToYV12)bgr16leToY_c; break;
case PIX_FMT_BGR565BE : c->lumToYV12 = (_lumToYV12)bgr16beToY_c; break;
case PIX_FMT_BGR555LE : c->lumToYV12 = (_lumToYV12)bgr15leToY_c; break;
case PIX_FMT_BGR555BE : c->lumToYV12 = (_lumToYV12)bgr15beToY_c; break;
case PIX_FMT_BGR444LE : c->lumToYV12 = (_lumToYV12)bgr12leToY_c; break;
case PIX_FMT_BGR444BE : c->lumToYV12 = (_lumToYV12)bgr12beToY_c; break;
case PIX_FMT_RGB24 : c->lumToYV12 = (_lumToYV12)rgb24ToY_c; break;
case PIX_FMT_RGB565LE : c->lumToYV12 = (_lumToYV12)rgb16leToY_c; break;
case PIX_FMT_RGB565BE : c->lumToYV12 = (_lumToYV12)rgb16beToY_c; break;
case PIX_FMT_RGB555LE : c->lumToYV12 = (_lumToYV12)rgb15leToY_c; break;
case PIX_FMT_RGB555BE : c->lumToYV12 = (_lumToYV12)rgb15beToY_c; break;
case PIX_FMT_RGB444LE : c->lumToYV12 = (_lumToYV12)rgb12leToY_c; break;
case PIX_FMT_RGB444BE : c->lumToYV12 = (_lumToYV12)rgb12beToY_c; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->lumToYV12 = (_lumToYV12)palToY_c; break;
case PIX_FMT_MONOBLACK: c->lumToYV12 = (_lumToYV12)monoblack2Y_c; break;
case PIX_FMT_MONOWHITE: c->lumToYV12 = (_lumToYV12)monowhite2Y_c; break;
case PIX_FMT_RGB32 : c->lumToYV12 = (_lumToYV12)bgr32ToY_c; break;
case PIX_FMT_RGB32_1: c->lumToYV12 = (_lumToYV12)bgr321ToY_c; break;
case PIX_FMT_BGR32 : c->lumToYV12 = (_lumToYV12)rgb32ToY_c; break;
case PIX_FMT_BGR32_1: c->lumToYV12 = (_lumToYV12)rgb321ToY_c; break;
case PIX_FMT_RGB48BE: c->lumToYV12 = (_lumToYV12)rgb48BEToY_c; break;
case PIX_FMT_RGB48LE: c->lumToYV12 = (_lumToYV12)rgb48LEToY_c; break;
case PIX_FMT_BGR48BE: c->lumToYV12 = (_lumToYV12)bgr48BEToY_c; break;
case PIX_FMT_BGR48LE: c->lumToYV12 = (_lumToYV12)bgr48LEToY_c; break;
}
if (c->alpPixBuf) {
switch (srcFormat) {
case PIX_FMT_BGRA:
case PIX_FMT_RGBA: c->alpToYV12 = (_alpToYV12)rgbaToA_c; break;
case PIX_FMT_ABGR:
case PIX_FMT_ARGB: c->alpToYV12 = (_alpToYV12)abgrToA_c; break;
case PIX_FMT_Y400A: c->alpToYV12 = (_alpToYV12)uyvyToY_c; break;
case PIX_FMT_PAL8 : c->alpToYV12 = (_alpToYV12)palToA_c; break;
}
}
if (c->srcBpc == 8) {
if (c->dstBpc <= 10) {
c->hyScale = c->hcScale = hScale8To15_c;
if (c->flags & SWS_FAST_BILINEAR) {
c->hyscale_fast = hyscale_fast_c;
c->hcscale_fast = hcscale_fast_c;
}
} else {
c->hyScale = c->hcScale = hScale8To19_c;
}
} else {
c->hyScale = c->hcScale = c->dstBpc > 10 ? hScale16To19_c : hScale16To15_c;
}
if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
if (c->dstBpc <= 10) {
if (c->srcRange) {
c->lumConvertRange = lumRangeFromJpeg_c;
c->chrConvertRange = chrRangeFromJpeg_c;
} else {
c->lumConvertRange = lumRangeToJpeg_c;
c->chrConvertRange = chrRangeToJpeg_c;
}
} else {
if (c->srcRange) {
c->lumConvertRange = lumRangeFromJpeg16_c;
c->chrConvertRange = chrRangeFromJpeg16_c;
} else {
c->lumConvertRange = lumRangeToJpeg16_c;
c->chrConvertRange = chrRangeToJpeg16_c;
}
}
}
if (!(isGray(srcFormat) || isGray(c->dstFormat) ||
srcFormat == PIX_FMT_MONOBLACK || srcFormat == PIX_FMT_MONOWHITE))
c->needs_hcscale = 1;
}
SwsFunc ff_getSwsFunc(SwsContext *c)
{
sws_init_swScale_c(c);
#if (HAVE_MMX)
ff_sws_init_swScale_mmx(c);
#endif
#if (HAVE_ALTIVEC)
ff_sws_init_swScale_altivec(c);
#endif
return swScale;
}
| 39.411976 | 178 | 0.533306 | [
"transform"
] |
3d77cb4b778707612b86d327c2242ab3c7a635a9 | 260 | hpp | C++ | gearoenix/render/texture/gx-rnd-txt-wrap.hpp | Hossein-Noroozpour/gearoenix | c8fa8b8946c03c013dad568d6d7a97d81097c051 | [
"BSD-Source-Code"
] | 35 | 2018-01-07T02:34:38.000Z | 2022-02-09T05:19:03.000Z | gearoenix/render/texture/gx-rnd-txt-wrap.hpp | Hossein-Noroozpour/gearoenix | c8fa8b8946c03c013dad568d6d7a97d81097c051 | [
"BSD-Source-Code"
] | 111 | 2017-09-20T09:12:36.000Z | 2020-12-27T12:52:03.000Z | gearoenix/render/texture/gx-rnd-txt-wrap.hpp | Hossein-Noroozpour/gearoenix | c8fa8b8946c03c013dad568d6d7a97d81097c051 | [
"BSD-Source-Code"
] | 5 | 2020-02-11T11:17:37.000Z | 2021-01-08T17:55:43.000Z | #ifndef GEAROENIX_RENDER_TEXTURE_WRAP_HPP
#define GEAROENIX_RENDER_TEXTURE_WRAP_HPP
#include "../../core/gx-cr-types.hpp"
namespace gearoenix::render::texture {
enum struct Wrap : core::TypeId {
ClampToEdge = 1,
Mirror = 2,
Repeat = 3,
};
}
#endif
| 21.666667 | 41 | 0.719231 | [
"render"
] |
3d7e4040dec621e22620d78d4c799b96f79bc2bb | 7,077 | hh | C++ | libsrc/pylith/problems/Problem.hh | aivazis/pylith | 4261a0ba637b4a32494ee05d9fef9861f2c5f443 | [
"MIT"
] | null | null | null | libsrc/pylith/problems/Problem.hh | aivazis/pylith | 4261a0ba637b4a32494ee05d9fef9861f2c5f443 | [
"MIT"
] | null | null | null | libsrc/pylith/problems/Problem.hh | aivazis/pylith | 4261a0ba637b4a32494ee05d9fef9861f2c5f443 | [
"MIT"
] | null | null | null | // -*- C++ -*-
//
// ======================================================================
//
// Brad T. Aagaard, U.S. Geological Survey
// Charles A. Williams, GNS Science
// Matthew G. Knepley, University at Buffalo
//
// This code was developed as part of the Computational Infrastructure
// for Geodynamics (http://geodynamics.org).
//
// Copyright (c) 2010-2021 University of California, Davis
//
// See LICENSE.md for license information.
//
// ======================================================================
//
/**
* @file libsrc/problems/Problem.hh
*
* @brief C++ object that manages the solution of a problem.formulating the equations.
*
* We cast the problem in terms of F(t,s,\dot{s}) = G(t,s), s(t0) = s0.
*
* In PETSc time stepping (TS) notation, G is the RHS, and F is the I
* function (which we call the LHS).
*/
#if !defined(pylith_problems_problem_hh)
#define pylith_problems_problem_hh
#include "problemsfwd.hh" // forward declarations
#include "pylith/utils/PyreComponent.hh" // ISA PyreComponent
#include "pylith/feassemble/feassemblefwd.hh" // HOLDSA Integrator, Constraint, Observers
#include "pylith/materials/materialsfwd.hh" // HOLDSA Material
#include "pylith/bc/bcfwd.hh" // HOLDSA BoundaryCondition
#include "pylith/faults/faultsfwd.hh" // HOLDSA FaultCohesive
#include "spatialdata/spatialdb/spatialdbfwd.hh" // HASA GravityField
#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field
#include "spatialdata/units/unitsfwd.hh" // HASA Nondimensional
#include "pylith/utils/petscfwd.h" // USES PetscVec, PetscMat
#include "pylith/problems/Physics.hh" // USES Problem::Formulation
#include "pylith/utils/array.hh" // HASA std::vector
class pylith::problems::Problem : public pylith::utils::PyreComponent {
friend class TestProblem; // unit testing
// PUBLIC ENUM /////////////////////////////////////////////////////////////////////////////////////////////////////
public:
enum SolverTypeEnum {
LINEAR, // Linear solver.
NONLINEAR, // Nonlinear solver.
}; // SolverType
// PUBLIC METHODS //////////////////////////////////////////////////////////////////////////////////////////////////
public:
/// Constructor
Problem(void);
/// Destructor
virtual ~Problem(void);
/// Deallocate PETSc and local data structures.
void deallocate(void);
/** Set formulation for equations.
*
* @param[in] value Formulation type.
*/
void setFormulation(const pylith::problems::Physics::FormulationEnum value);
/** Get formulation for equations.
*
* @returns Formulation type.
*/
pylith::problems::Physics::FormulationEnum getFormulation(void) const;
/** Set solver type.
*
* @param[in] value Solver type.
*/
void setSolverType(const SolverTypeEnum value);
/** Get solver type.
*
* @returns Solver type.
*/
SolverTypeEnum getSolverType(void) const;
/** Set manager of scales used to nondimensionalize problem.
*
* @param[in] dim Nondimensionalizer.
*/
void setNormalizer(const spatialdata::units::Nondimensional& dim);
/** Set gravity field.
*
* @param[in] g Gravity field.
*/
void setGravityField(spatialdata::spatialdb::GravityField* const g);
/** Register observer to receive notifications.
*
* Observers are used for output.
*
* @param[in] observer Observer to receive notifications.
*/
void registerObserver(pylith::problems::ObserverSoln* observer);
/** Remove observer from receiving notifications.
*
* @param[in] observer Observer to remove.
*/
void removeObserver(pylith::problems::ObserverSoln* observer);
/** Set solution field.
*
* @param[in] field Solution field.
*/
void setSolution(pylith::topology::Field* field);
/** Get solution field.
*
* @returns Solution field.
*/
const pylith::topology::Field* getSolution(void) const;
/** Set materials.
*
* @param[in] materials Array of materials.
* @param[in] numMaterials Number of materials.
*/
void setMaterials(pylith::materials::Material* materials[],
const int numMaterials);
/** Set boundary conditions.
*
* @param[in] bc Array of boundary conditions.
* @param[in] numBC Number of boundary conditions.
*/
void setBoundaryConditions(pylith::bc::BoundaryCondition* bc[],
const int numBC);
/** Set interior interface conditions.
*
* @param[in] interfaces Array of interior interfaces.
* @param[in] numInterfaces Number of interior interfaces.
*/
void setInterfaces(pylith::faults::FaultCohesive* faults[],
const int numFaults);
/** Do minimal initialization.
*
* @param mesh Finite-element mesh.
*/
virtual
void preinitialize(const pylith::topology::Mesh& mesh);
/// Verify configuration.
virtual
void verifyConfiguration(void) const;
/// Initialize problem.
virtual
void initialize(void);
// PROTECTED MEMBERS ///////////////////////////////////////////////////////////////////////////////////////////////
protected:
pylith::problems::IntegrationData* _integrationData; /// > Data needed to integrate PDE.
spatialdata::units::Nondimensional* _normalizer; ///< Nondimensionalization of scales.
spatialdata::spatialdb::GravityField* _gravityField; ///< Gravity field.
std::vector<pylith::materials::Material*> _materials; ///< Array of materials.
std::vector<pylith::bc::BoundaryCondition*> _bc; ///< Array of boundary conditions.
std::vector<pylith::faults::FaultCohesive*> _interfaces; ///< Array of interior interfaces.
std::vector<pylith::feassemble::Integrator*> _integrators; ///< Array of integrators.
std::vector<pylith::feassemble::Constraint*> _constraints; ///< Array of constraints.
pylith::problems::ObserversSoln* _observers; ///< Subscribers of solution updates.
pylith::problems::Physics::FormulationEnum _formulation; ///< Formulation for equations.
SolverTypeEnum _solverType; ///< Problem (solver) type.
// PRIVATE METHODS /////////////////////////////////////////////////////////////////////////////////////////////////
private:
/// Check material and interface ids.
void _checkMaterialIds(void) const;
/// Create array of integrators from materials, interfaces, and boundary conditions.
void _createIntegrators(void);
/// Create array of constraints from materials, interfaces, and boundary conditions.
void _createConstraints(void);
/// Setup solution subfields and discretization.
void _setupSolution(void);
// NOT IMPLEMENTED /////////////////////////////////////////////////////////////////////////////////////////////////
private:
Problem(const Problem&); ///< Not implemented
const Problem& operator=(const Problem&); ///< Not implemented
}; // Problem
#endif // pylith_problems_problem_hh
// End of file
| 32.168182 | 120 | 0.614102 | [
"mesh",
"object",
"vector"
] |
3d800083d4084e930b20d75bfc5d7f56f763abbd | 2,630 | cpp | C++ | code/fused_ops/csrc/softmax_dropout/interface.cpp | PKU-DAIR/2021_CCF_BDCI_LargeBERT_Rank1st | 6382433cda69c655f03c3cc284dc076407f18dc9 | [
"Apache-2.0"
] | 4 | 2022-01-21T01:51:29.000Z | 2022-03-29T11:56:42.000Z | code/fused_ops/csrc/softmax_dropout/interface.cpp | PKU-DAIR/2021_CCF_BDCI_LargeBERT_Rank1st | 6382433cda69c655f03c3cc284dc076407f18dc9 | [
"Apache-2.0"
] | null | null | null | code/fused_ops/csrc/softmax_dropout/interface.cpp | PKU-DAIR/2021_CCF_BDCI_LargeBERT_Rank1st | 6382433cda69c655f03c3cc284dc076407f18dc9 | [
"Apache-2.0"
] | null | null | null | #include <torch/extension.h>
#include <ATen/Generator.h>
#include <ATen/CUDAGeneratorImpl.h>
#include <vector>
std::vector<c10::optional<torch::Tensor>> fwd_cuda(
bool is_training,
const torch::Tensor &input,
float dropout_prob,
c10::optional<at::Generator> gen_
);
torch::Tensor bwd_cuda(
torch::Tensor &output_grads,
const torch::Tensor &softmax_results,
const c10::optional<torch::Tensor> &dropout_mask,
float dropout_prob
);
// C++ interface
#define CHECK_CUDA(x) AT_ASSERTM(x.is_cuda(), #x " must be a CUDA tensor")
#define CHECK_CONTIGUOUS(x) AT_ASSERTM(x.is_contiguous(), #x " must be contiguous")
#define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)
std::vector<c10::optional<torch::Tensor>> fwd(
bool is_training,
const torch::Tensor &input,
float dropout_prob,
c10::optional<at::Generator> gen_
) {
CHECK_INPUT(input);
AT_ASSERTM(input.dim() == 3, "expected 3D tensor");
AT_ASSERTM(input.scalar_type() == at::ScalarType::Half ||
input.scalar_type() == at::ScalarType::BFloat16 ||
input.scalar_type() == at::ScalarType::Float, "Only HALF/BFloat16/Float is supported");
return fwd_cuda(is_training, input, dropout_prob, gen_);
}
torch::Tensor bwd(
torch::Tensor &output_grads,
const torch::Tensor &softmax_results,
const c10::optional<torch::Tensor> &dropout_mask,
float dropout_prob
) {
CHECK_INPUT(output_grads);
CHECK_INPUT(softmax_results);
if (dropout_mask) {
CHECK_INPUT(dropout_mask.value());
}
AT_ASSERTM(output_grads.dim() == 3, "expected 3D tensor");
AT_ASSERTM(softmax_results.dim() == 3, "expected 3D tensor");
AT_ASSERTM(!dropout_mask || dropout_mask->dim() == 1, "expected 1D tensor");
AT_ASSERTM(output_grads.scalar_type() == at::ScalarType::Half ||
output_grads.scalar_type() == at::ScalarType::BFloat16 ||
output_grads.scalar_type() == at::ScalarType::Float, "Only HALF/BFloat16/Float is supported");
AT_ASSERTM(softmax_results.scalar_type() == at::ScalarType::Half ||
softmax_results.scalar_type() == at::ScalarType::BFloat16 ||
softmax_results.scalar_type() == at::ScalarType::Float, "Only HALF/BFloat16/Float is supported");
AT_ASSERTM(output_grads.scalar_type() == softmax_results.scalar_type(), "the types mismatch");
return bwd_cuda(output_grads, softmax_results, dropout_mask, dropout_prob);
}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("forward", &fwd, "softmax dropout -- Forward.");
m.def("backward", &bwd, "softmax dropout -- Backward.");
} | 38.676471 | 112 | 0.68403 | [
"vector",
"3d"
] |
3d85db10c6c4eb6e3c4452b75f3c1657cdd97672 | 16,630 | hpp | C++ | deps/boost/include/boost/gil/image_processing/threshold.hpp | kindlychung/mediasoup-sfu-cpp | f69d2f48f7edbf4f0c57244280a47bea985f39cf | [
"Apache-2.0"
] | 80 | 2021-09-07T12:44:32.000Z | 2022-03-29T01:22:19.000Z | deps/boost/include/boost/gil/image_processing/threshold.hpp | kindlychung/mediasoup-sfu-cpp | f69d2f48f7edbf4f0c57244280a47bea985f39cf | [
"Apache-2.0"
] | 2 | 2021-12-23T02:49:42.000Z | 2022-02-15T05:28:24.000Z | deps/boost/include/boost/gil/image_processing/threshold.hpp | kindlychung/mediasoup-sfu-cpp | f69d2f48f7edbf4f0c57244280a47bea985f39cf | [
"Apache-2.0"
] | 25 | 2021-09-14T06:24:25.000Z | 2022-03-20T06:55:07.000Z | //
// Copyright 2019 Miral Shah <miralshah2211@gmail.com>
//
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_GIL_IMAGE_PROCESSING_THRESHOLD_HPP
#define BOOST_GIL_IMAGE_PROCESSING_THRESHOLD_HPP
#include <limits>
#include <array>
#include <type_traits>
#include <cstddef>
#include <algorithm>
#include <vector>
#include <cmath>
#include <boost/assert.hpp>
#include <boost/gil/image.hpp>
#include <boost/gil/extension/numeric/kernel.hpp>
#include <boost/gil/extension/numeric/convolve.hpp>
#include <boost/gil/image_processing/numeric.hpp>
namespace boost { namespace gil {
namespace detail {
template
<
typename SourceChannelT,
typename ResultChannelT,
typename SrcView,
typename DstView,
typename Operator
>
void threshold_impl(SrcView const& src_view, DstView const& dst_view, Operator const& threshold_op)
{
gil_function_requires<ImageViewConcept<SrcView>>();
gil_function_requires<MutableImageViewConcept<DstView>>();
static_assert(color_spaces_are_compatible
<
typename color_space_type<SrcView>::type,
typename color_space_type<DstView>::type
>::value, "Source and destination views must have pixels with the same color space");
//iterate over the image checking each pixel value for the threshold
for (std::ptrdiff_t y = 0; y < src_view.height(); y++)
{
typename SrcView::x_iterator src_it = src_view.row_begin(y);
typename DstView::x_iterator dst_it = dst_view.row_begin(y);
for (std::ptrdiff_t x = 0; x < src_view.width(); x++)
{
static_transform(src_it[x], dst_it[x], threshold_op);
}
}
}
} //namespace boost::gil::detail
/// \addtogroup ImageProcessing
/// @{
///
/// \brief Direction of image segmentation.
/// The direction specifies which pixels are considered as corresponding to object
/// and which pixels correspond to background.
enum class threshold_direction
{
regular, ///< Consider values greater than threshold value
inverse ///< Consider values less than or equal to threshold value
};
/// \ingroup ImageProcessing
/// \brief Method of optimal threshold value calculation.
enum class threshold_optimal_value
{
otsu ///< \todo TODO
};
/// \ingroup ImageProcessing
/// \brief TODO
enum class threshold_truncate_mode
{
threshold, ///< \todo TODO
zero ///< \todo TODO
};
enum class threshold_adaptive_method
{
mean,
gaussian
};
/// \ingroup ImageProcessing
/// \brief Applies fixed threshold to each pixel of image view.
/// Performs image binarization by thresholding channel value of each
/// pixel of given image view.
/// \param src_view - TODO
/// \param dst_view - TODO
/// \param threshold_value - TODO
/// \param max_value - TODO
/// \param threshold_direction - if regular, values greater than threshold_value are
/// set to max_value else set to 0; if inverse, values greater than threshold_value are
/// set to 0 else set to max_value.
template <typename SrcView, typename DstView>
void threshold_binary(
SrcView const& src_view,
DstView const& dst_view,
typename channel_type<DstView>::type threshold_value,
typename channel_type<DstView>::type max_value,
threshold_direction direction = threshold_direction::regular
)
{
//deciding output channel type and creating functor
using source_channel_t = typename channel_type<SrcView>::type;
using result_channel_t = typename channel_type<DstView>::type;
if (direction == threshold_direction::regular)
{
detail::threshold_impl<source_channel_t, result_channel_t>(src_view, dst_view,
[threshold_value, max_value](source_channel_t px) -> result_channel_t {
return px > threshold_value ? max_value : 0;
});
}
else
{
detail::threshold_impl<source_channel_t, result_channel_t>(src_view, dst_view,
[threshold_value, max_value](source_channel_t px) -> result_channel_t {
return px > threshold_value ? 0 : max_value;
});
}
}
/// \ingroup ImageProcessing
/// \brief Applies fixed threshold to each pixel of image view.
/// Performs image binarization by thresholding channel value of each
/// pixel of given image view.
/// This variant of threshold_binary automatically deduces maximum value for each channel
/// of pixel based on channel type.
/// If direction is regular, values greater than threshold_value will be set to maximum
/// numeric limit of channel else 0.
/// If direction is inverse, values greater than threshold_value will be set to 0 else maximum
/// numeric limit of channel.
template <typename SrcView, typename DstView>
void threshold_binary(
SrcView const& src_view,
DstView const& dst_view,
typename channel_type<DstView>::type threshold_value,
threshold_direction direction = threshold_direction::regular
)
{
//deciding output channel type and creating functor
using result_channel_t = typename channel_type<DstView>::type;
result_channel_t max_value = (std::numeric_limits<result_channel_t>::max)();
threshold_binary(src_view, dst_view, threshold_value, max_value, direction);
}
/// \ingroup ImageProcessing
/// \brief Applies truncating threshold to each pixel of image view.
/// Takes an image view and performs truncating threshold operation on each chennel.
/// If mode is threshold and direction is regular:
/// values greater than threshold_value will be set to threshold_value else no change
/// If mode is threshold and direction is inverse:
/// values less than or equal to threshold_value will be set to threshold_value else no change
/// If mode is zero and direction is regular:
/// values less than or equal to threshold_value will be set to 0 else no change
/// If mode is zero and direction is inverse:
/// values more than threshold_value will be set to 0 else no change
template <typename SrcView, typename DstView>
void threshold_truncate(
SrcView const& src_view,
DstView const& dst_view,
typename channel_type<DstView>::type threshold_value,
threshold_truncate_mode mode = threshold_truncate_mode::threshold,
threshold_direction direction = threshold_direction::regular
)
{
//deciding output channel type and creating functor
using source_channel_t = typename channel_type<SrcView>::type;
using result_channel_t = typename channel_type<DstView>::type;
std::function<result_channel_t(source_channel_t)> threshold_logic;
if (mode == threshold_truncate_mode::threshold)
{
if (direction == threshold_direction::regular)
{
detail::threshold_impl<source_channel_t, result_channel_t>(src_view, dst_view,
[threshold_value](source_channel_t px) -> result_channel_t {
return px > threshold_value ? threshold_value : px;
});
}
else
{
detail::threshold_impl<source_channel_t, result_channel_t>(src_view, dst_view,
[threshold_value](source_channel_t px) -> result_channel_t {
return px > threshold_value ? px : threshold_value;
});
}
}
else
{
if (direction == threshold_direction::regular)
{
detail::threshold_impl<source_channel_t, result_channel_t>(src_view, dst_view,
[threshold_value](source_channel_t px) -> result_channel_t {
return px > threshold_value ? px : 0;
});
}
else
{
detail::threshold_impl<source_channel_t, result_channel_t>(src_view, dst_view,
[threshold_value](source_channel_t px) -> result_channel_t {
return px > threshold_value ? 0 : px;
});
}
}
}
namespace detail{
template <typename SrcView, typename DstView>
void otsu_impl(SrcView const& src_view, DstView const& dst_view, threshold_direction direction)
{
//deciding output channel type and creating functor
using source_channel_t = typename channel_type<SrcView>::type;
std::array<std::size_t, 256> histogram{};
//initial value of min is set to maximum possible value to compare histogram data
//initial value of max is set to minimum possible value to compare histogram data
auto min = (std::numeric_limits<source_channel_t>::max)(),
max = (std::numeric_limits<source_channel_t>::min)();
if (sizeof(source_channel_t) > 1 || std::is_signed<source_channel_t>::value)
{
//iterate over the image to find the min and max pixel values
for (std::ptrdiff_t y = 0; y < src_view.height(); y++)
{
typename SrcView::x_iterator src_it = src_view.row_begin(y);
for (std::ptrdiff_t x = 0; x < src_view.width(); x++)
{
if (src_it[x] < min) min = src_it[x];
if (src_it[x] > min) min = src_it[x];
}
}
//making histogram
for (std::ptrdiff_t y = 0; y < src_view.height(); y++)
{
typename SrcView::x_iterator src_it = src_view.row_begin(y);
for (std::ptrdiff_t x = 0; x < src_view.width(); x++)
{
histogram[((src_it[x] - min) * 255) / (max - min)]++;
}
}
}
else
{
//making histogram
for (std::ptrdiff_t y = 0; y < src_view.height(); y++)
{
typename SrcView::x_iterator src_it = src_view.row_begin(y);
for (std::ptrdiff_t x = 0; x < src_view.width(); x++)
{
histogram[src_it[x]]++;
}
}
}
//histData = histogram data
//sum = total (background + foreground)
//sumB = sum background
//wB = weight background
//wf = weight foreground
//varMax = tracking the maximum known value of between class variance
//mB = mu background
//mF = mu foreground
//varBeetween = between class variance
//http://www.labbookpages.co.uk/software/imgProc/otsuThreshold.html
//https://www.ipol.im/pub/art/2016/158/
std::ptrdiff_t total_pixel = src_view.height() * src_view.width();
std::ptrdiff_t sum_total = 0, sum_back = 0;
std::size_t weight_back = 0, weight_fore = 0, threshold = 0;
double var_max = 0, mean_back, mean_fore, var_intra_class;
for (std::size_t t = 0; t < 256; t++)
{
sum_total += t * histogram[t];
}
for (int t = 0; t < 256; t++)
{
weight_back += histogram[t]; // Weight Background
if (weight_back == 0) continue;
weight_fore = total_pixel - weight_back; // Weight Foreground
if (weight_fore == 0) break;
sum_back += t * histogram[t];
mean_back = sum_back / weight_back; // Mean Background
mean_fore = (sum_total - sum_back) / weight_fore; // Mean Foreground
// Calculate Between Class Variance
var_intra_class = weight_back * weight_fore * (mean_back - mean_fore) * (mean_back - mean_fore);
// Check if new maximum found
if (var_intra_class > var_max) {
var_max = var_intra_class;
threshold = t;
}
}
if (sizeof(source_channel_t) > 1 && std::is_unsigned<source_channel_t>::value)
{
threshold_binary(src_view, dst_view, (threshold * (max - min) / 255) + min, direction);
}
else {
threshold_binary(src_view, dst_view, threshold, direction);
}
}
} //namespace detail
template <typename SrcView, typename DstView>
void threshold_optimal
(
SrcView const& src_view,
DstView const& dst_view,
threshold_optimal_value mode = threshold_optimal_value::otsu,
threshold_direction direction = threshold_direction::regular
)
{
if (mode == threshold_optimal_value::otsu)
{
for (std::size_t i = 0; i < src_view.num_channels(); i++)
{
detail::otsu_impl
(nth_channel_view(src_view, i), nth_channel_view(dst_view, i), direction);
}
}
}
namespace detail {
template
<
typename SourceChannelT,
typename ResultChannelT,
typename SrcView,
typename DstView,
typename Operator
>
void adaptive_impl
(
SrcView const& src_view,
SrcView const& convolved_view,
DstView const& dst_view,
Operator const& threshold_op
)
{
//template argument validation
gil_function_requires<ImageViewConcept<SrcView>>();
gil_function_requires<MutableImageViewConcept<DstView>>();
static_assert(color_spaces_are_compatible
<
typename color_space_type<SrcView>::type,
typename color_space_type<DstView>::type
>::value, "Source and destination views must have pixels with the same color space");
//iterate over the image checking each pixel value for the threshold
for (std::ptrdiff_t y = 0; y < src_view.height(); y++)
{
typename SrcView::x_iterator src_it = src_view.row_begin(y);
typename SrcView::x_iterator convolved_it = convolved_view.row_begin(y);
typename DstView::x_iterator dst_it = dst_view.row_begin(y);
for (std::ptrdiff_t x = 0; x < src_view.width(); x++)
{
static_transform(src_it[x], convolved_it[x], dst_it[x], threshold_op);
}
}
}
} //namespace boost::gil::detail
template <typename SrcView, typename DstView>
void threshold_adaptive
(
SrcView const& src_view,
DstView const& dst_view,
typename channel_type<DstView>::type max_value,
std::size_t kernel_size,
threshold_adaptive_method method = threshold_adaptive_method::mean,
threshold_direction direction = threshold_direction::regular,
typename channel_type<DstView>::type constant = 0
)
{
BOOST_ASSERT_MSG((kernel_size % 2 != 0), "Kernel size must be an odd number");
typedef typename channel_type<SrcView>::type source_channel_t;
typedef typename channel_type<DstView>::type result_channel_t;
image<typename SrcView::value_type> temp_img(src_view.width(), src_view.height());
typename image<typename SrcView::value_type>::view_t temp_view = view(temp_img);
SrcView temp_conv(temp_view);
if (method == threshold_adaptive_method::mean)
{
std::vector<float> mean_kernel_values(kernel_size, 1.0f/kernel_size);
kernel_1d<float> kernel(mean_kernel_values.begin(), kernel_size, kernel_size/2);
detail::convolve_1d
<
pixel<float, typename SrcView::value_type::layout_t>
>(src_view, kernel, temp_view);
}
else if (method == threshold_adaptive_method::gaussian)
{
detail::kernel_2d<float> kernel = generate_gaussian_kernel(kernel_size, 1.0);
convolve_2d(src_view, kernel, temp_view);
}
if (direction == threshold_direction::regular)
{
detail::adaptive_impl<source_channel_t, result_channel_t>(src_view, temp_conv, dst_view,
[max_value, constant](source_channel_t px, source_channel_t threshold) -> result_channel_t
{ return px > (threshold - constant) ? max_value : 0; });
}
else
{
detail::adaptive_impl<source_channel_t, result_channel_t>(src_view, temp_conv, dst_view,
[max_value, constant](source_channel_t px, source_channel_t threshold) -> result_channel_t
{ return px > (threshold - constant) ? 0 : max_value; });
}
}
template <typename SrcView, typename DstView>
void threshold_adaptive
(
SrcView const& src_view,
DstView const& dst_view,
std::size_t kernel_size,
threshold_adaptive_method method = threshold_adaptive_method::mean,
threshold_direction direction = threshold_direction::regular,
int constant = 0
)
{
//deciding output channel type and creating functor
typedef typename channel_type<DstView>::type result_channel_t;
result_channel_t max_value = (std::numeric_limits<result_channel_t>::max)();
threshold_adaptive(src_view, dst_view, max_value, kernel_size, method, direction, constant);
}
/// @}
}} //namespace boost::gil
#endif //BOOST_GIL_IMAGE_PROCESSING_THRESHOLD_HPP
| 35.763441 | 105 | 0.658629 | [
"object",
"vector"
] |
3d8d94ce4f7f6d20484ccd6225b7ef774026fac9 | 6,678 | cpp | C++ | taylor.cpp | zaimoni/Iskandria | b056d2ba359b814db02aab42eba8d5f7f5ca7a1a | [
"BSL-1.0"
] | 2 | 2019-11-23T12:35:49.000Z | 2022-02-10T08:27:54.000Z | taylor.cpp | zaimoni/Iskandria | b056d2ba359b814db02aab42eba8d5f7f5ca7a1a | [
"BSL-1.0"
] | 8 | 2019-11-15T08:13:48.000Z | 2020-04-29T00:35:42.000Z | taylor.cpp | zaimoni/Iskandria | b056d2ba359b814db02aab42eba8d5f7f5ca7a1a | [
"BSL-1.0"
] | null | null | null | // taylor.cpp
#include "taylor.hpp"
#include "cyclic_fn.hpp"
// want:
// function object x -> (-1)^x
// function object x -> f(x/2) if even, 0 if odd
// function object x -> x-1
// cos is then x -> -1^(x/2) when even, 0 if odd
// sin is then x -> -1^((x-1)/2) when odd, 0 when even
// so gateway function is a Kronecker delta on an x_0 mod 2
// if that survives, call f((x-x_0)/2): f: x -> (-1)^x o g: x -> (x - x_0)/2
namespace zaimoni {
namespace math {
namespace linear {
template<intmax_t a_1_numerator, intmax_t a_1_denominator, intmax_t a_0> struct map;
template<intmax_t a_1_divisor>
struct map<1, a_1_divisor, 0>
{
template<class DomainRange> static DomainRange eval(const DomainRange& x) {return x/int_as<a_1_divisor,DomainRange>();} // XXX want integer math for integer types, but overprecise overrides for boost::numeric::interval
};
template<intmax_t a_0>
struct map<1,1, a_0>
{
template<class DomainRange> static DomainRange eval(const DomainRange& x) {return x+int_as<a_0,DomainRange>();}
};
// division by zero shall not compile
template<intmax_t a_1_numerator, intmax_t a_0> struct map<a_1_numerator, 0, a_0>;
// this probably wants overprecision support rather than just lossy arithmetic support
template<intmax_t a_1_numerator, intmax_t a_1_denominator, intmax_t a_0>
struct map
{
template<class DomainRange> static DomainRange eval(const DomainRange& x) {return int_as<a_1_numerator,DomainRange>()*x/int_as<a_1_denominator,DomainRange>()+int_as<a_0,DomainRange>();}
};
} // namespace linear
// figure out where this goes later
static const zaimoni::math::mod_n::cyclic_fn_enumerated<2,signed char>& alternator()
{
static const signed char tmp[2] = {1,-1};
static zaimoni::math::mod_n::cyclic_fn_enumerated<2,signed char> ret(tmp);
return ret;
}
// unsigned_fn<0>::template kronecker_delta<Z_<2> >(n) * alternator o linear::map<1,2,0>::template eval<uintmax_t>(n)
// unsigned_fn<1>::template kronecker_delta<Z_<2> >(n) * alternator o linear::map<1,2,0>::template eval<uintmax_t> o linear_map<1,1,-1>::template eval<uintmax_t>
const TaylorSeries<int>& cos()
{
// it would be *VERY* nice to calculate the function properties from the function generating the coefficients
static TaylorSeries<int> ret(product(std::function<int (uintmax_t)>(unsigned_fn<0>::template kronecker_delta<Z_<2> >),
compose(std::function<int (uintmax_t)>(alternator()),
std::function<uintmax_t (uintmax_t)>(linear::map<1,2,0>::template eval<uintmax_t>))),
fn_algebraic_properties::ALTERNATING | fn_algebraic_properties::EVEN);
return ret;
}
const TaylorSeries<int>& sin()
{
static TaylorSeries<int> ret(product(std::function<int (uintmax_t)>(unsigned_fn<1>::template kronecker_delta<Z_<2> >),
compose(compose(std::function<int (uintmax_t)>(alternator()),
std::function<uintmax_t (uintmax_t)>(linear::map<1,2,0>::template eval<uintmax_t>)),
std::function<uintmax_t (uintmax_t)>(linear::map<1,1,-1>::template eval<uintmax_t>))),
fn_algebraic_properties::ALTERNATING | fn_algebraic_properties::ODD);
return ret;
}
const TaylorSeries<int>& exp()
{
static TaylorSeries<int> ret(std::function<int(uintmax_t)>(unsigned_fn<1>::constant<uintmax_t>),
fn_algebraic_properties::NONZERO | fn_algebraic_properties::NONNEGATIVE);
return ret;
}
const TaylorSeries<int>& cosh()
{
static TaylorSeries<int> ret(product(std::function<int(uintmax_t)>(unsigned_fn<0>::template kronecker_delta<Z_<2> >),
compose(std::function<int(uintmax_t)>(unsigned_fn<1>::constant<uintmax_t>),
std::function<uintmax_t(uintmax_t)>(linear::map<1, 2, 0>::template eval<uintmax_t>))),
fn_algebraic_properties::NONZERO | fn_algebraic_properties::NONNEGATIVE | fn_algebraic_properties::EVEN);
return ret;
}
const TaylorSeries<int>& sinh()
{
static TaylorSeries<int> ret(product(std::function<int(uintmax_t)>(unsigned_fn<1>::template kronecker_delta<Z_<2> >),
compose(compose(std::function<int(uintmax_t)>(unsigned_fn<1>::constant<uintmax_t>),
std::function<uintmax_t(uintmax_t)>(linear::map<1, 2, 0>::template eval<uintmax_t>)),
std::function<uintmax_t(uintmax_t)>(linear::map<1, 1, -1>::template eval<uintmax_t>))),
fn_algebraic_properties::ODD);
return ret;
}
} // namespace math
} // namespace zaimoni
#ifdef TEST_APP
// example build line
// If doing INFORM-based debugging
// g++ -std=c++11 -otaylor.exe -DTEST_APP -D__STDC_LIMIT_MACROS taylor.cpp -Llib/host.isk -lz_log_adapter -lz_stdio_log -lz_format_util
#include "test_driver.h"
int main(int argc, char* argv[])
{ // parse options
char buf[100];
STRING_LITERAL_TO_STDOUT("starting main\n");
INFORM(zaimoni::math::cos().a(0));
INFORM(zaimoni::math::cos().a(1));
INFORM(zaimoni::math::cos().a(2));
INFORM(zaimoni::math::cos().a(3));
INFORM(zaimoni::math::cos().a(4));
STRING_LITERAL_TO_STDOUT("cos coefficients a_0..4\n");
INFORM(zaimoni::math::sin().a(0));
INFORM(zaimoni::math::sin().a(1));
INFORM(zaimoni::math::sin().a(2));
INFORM(zaimoni::math::sin().a(3));
INFORM(zaimoni::math::sin().a(4));
STRING_LITERAL_TO_STDOUT("sin coefficients a_0..4\n");
INC_INFORM("sin(0): ");
INFORM(zaimoni::math::sin().eval(zaimoni::math::int_as<0,ISK_INTERVAL<long double> >()));
INC_INFORM("cos(0): ");
INFORM(zaimoni::math::cos().eval(zaimoni::math::int_as<0,ISK_INTERVAL<long double> >()));
INC_INFORM("sin(1): ");
INFORM(zaimoni::math::sin().eval(zaimoni::math::int_as<1,ISK_INTERVAL<long double> >()));
INC_INFORM("cos(1): ");
INFORM(zaimoni::math::cos().eval(zaimoni::math::int_as<1,ISK_INTERVAL<long double> >()));
INC_INFORM("exp(0): ");
INFORM(zaimoni::math::exp().eval(zaimoni::math::int_as<0, ISK_INTERVAL<long double> >()));
INC_INFORM("sinh(0): ");
INFORM(zaimoni::math::sinh().eval(zaimoni::math::int_as<0, ISK_INTERVAL<long double> >()));
INC_INFORM("cosh(0): ");
INFORM(zaimoni::math::cosh().eval(zaimoni::math::int_as<0, ISK_INTERVAL<long double> >()));
INC_INFORM("exp(1): ");
INFORM(zaimoni::math::exp().eval(zaimoni::math::int_as<1, ISK_INTERVAL<long double> >()));
INC_INFORM("sinh(1): ");
INFORM(zaimoni::math::sinh().eval(zaimoni::math::int_as<1, ISK_INTERVAL<long double> >()));
INC_INFORM("cosh(1): ");
INFORM(zaimoni::math::cosh().eval(zaimoni::math::int_as<1, ISK_INTERVAL<long double> >()));
STRING_LITERAL_TO_STDOUT("tests finished\n");
}
#endif
| 40.228916 | 220 | 0.677149 | [
"object"
] |
3d918274694908b8fa0cd88608b3d8be5c93757d | 14,904 | hpp | C++ | include/GlobalNamespace/ILobbyPlayersDataModel.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | include/GlobalNamespace/ILobbyPlayersDataModel.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | include/GlobalNamespace/ILobbyPlayersDataModel.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "beatsaber-hook/shared/utils/byref.hpp"
// Including type: System.Collections.Generic.IReadOnlyDictionary`2
#include "System/Collections/Generic/IReadOnlyDictionary_2.hpp"
#include "beatsaber-hook/shared/utils/typedefs-string.hpp"
// Completed includes
// Begin forward declares
// Forward declaring namespace: GlobalNamespace
namespace GlobalNamespace {
// Forward declaring type: ILobbyPlayerData
class ILobbyPlayerData;
// Forward declaring type: PreviewDifficultyBeatmap
class PreviewDifficultyBeatmap;
// Forward declaring type: GameplayModifiers
class GameplayModifiers;
}
// Forward declaring namespace: System
namespace System {
// Forward declaring type: Action`1<T>
template<typename T>
class Action_1;
}
// Completed forward declares
// Type namespace:
namespace GlobalNamespace {
// Forward declaring type: ILobbyPlayersDataModel
class ILobbyPlayersDataModel;
}
#include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
NEED_NO_BOX(::GlobalNamespace::ILobbyPlayersDataModel);
DEFINE_IL2CPP_ARG_TYPE(::GlobalNamespace::ILobbyPlayersDataModel*, "", "ILobbyPlayersDataModel");
// Type namespace:
namespace GlobalNamespace {
// Size: 0x10
#pragma pack(push, 1)
// Autogenerated type: ILobbyPlayersDataModel
// [TokenAttribute] Offset: FFFFFFFF
class ILobbyPlayersDataModel/*, public ::System::Collections::Generic::IReadOnlyDictionary_2<::StringW, ::GlobalNamespace::ILobbyPlayerData*>*/ {
public:
// Creating interface conversion operator: operator ::System::Collections::Generic::IReadOnlyDictionary_2<::StringW, ::GlobalNamespace::ILobbyPlayerData*>
operator ::System::Collections::Generic::IReadOnlyDictionary_2<::StringW, ::GlobalNamespace::ILobbyPlayerData*>() noexcept {
return *reinterpret_cast<::System::Collections::Generic::IReadOnlyDictionary_2<::StringW, ::GlobalNamespace::ILobbyPlayerData*>*>(this);
}
// public System.String get_localUserId()
// Offset: 0xFFFFFFFFFFFFFFFF
::StringW get_localUserId();
// public System.String get_partyOwnerId()
// Offset: 0xFFFFFFFFFFFFFFFF
::StringW get_partyOwnerId();
// public System.Void add_didChangeEvent(System.Action`1<System.String> value)
// Offset: 0xFFFFFFFFFFFFFFFF
void add_didChangeEvent(::System::Action_1<::StringW>* value);
// public System.Void remove_didChangeEvent(System.Action`1<System.String> value)
// Offset: 0xFFFFFFFFFFFFFFFF
void remove_didChangeEvent(::System::Action_1<::StringW>* value);
// public System.Void SetLocalPlayerBeatmapLevel(PreviewDifficultyBeatmap beatmapLevel)
// Offset: 0xFFFFFFFFFFFFFFFF
void SetLocalPlayerBeatmapLevel(::GlobalNamespace::PreviewDifficultyBeatmap* beatmapLevel);
// public System.Void ClearLocalPlayerBeatmapLevel()
// Offset: 0xFFFFFFFFFFFFFFFF
void ClearLocalPlayerBeatmapLevel();
// public System.Void SetLocalPlayerGameplayModifiers(GameplayModifiers modifiers)
// Offset: 0xFFFFFFFFFFFFFFFF
void SetLocalPlayerGameplayModifiers(::GlobalNamespace::GameplayModifiers* modifiers);
// public System.Void ClearLocalPlayerGameplayModifiers()
// Offset: 0xFFFFFFFFFFFFFFFF
void ClearLocalPlayerGameplayModifiers();
// public System.Void SetLocalPlayerIsActive(System.Boolean isActive)
// Offset: 0xFFFFFFFFFFFFFFFF
void SetLocalPlayerIsActive(bool isActive);
// public System.Void SetLocalPlayerIsReady(System.Boolean isReady)
// Offset: 0xFFFFFFFFFFFFFFFF
void SetLocalPlayerIsReady(bool isReady);
// public System.Void SetLocalPlayerIsInLobby(System.Boolean isInLobby)
// Offset: 0xFFFFFFFFFFFFFFFF
void SetLocalPlayerIsInLobby(bool isInLobby);
// public System.Void RequestKickPlayer(System.String kickedUserId)
// Offset: 0xFFFFFFFFFFFFFFFF
void RequestKickPlayer(::StringW kickedUserId);
// public System.Void ClearData()
// Offset: 0xFFFFFFFFFFFFFFFF
void ClearData();
// public System.Void ClearRecommendations()
// Offset: 0xFFFFFFFFFFFFFFFF
void ClearRecommendations();
// public System.Void Activate()
// Offset: 0xFFFFFFFFFFFFFFFF
void Activate();
// public System.Void Deactivate()
// Offset: 0xFFFFFFFFFFFFFFFF
void Deactivate();
}; // ILobbyPlayersDataModel
#pragma pack(pop)
}
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::get_localUserId
// Il2CppName: get_localUserId
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::StringW (GlobalNamespace::ILobbyPlayersDataModel::*)()>(&GlobalNamespace::ILobbyPlayersDataModel::get_localUserId)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "get_localUserId", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::get_partyOwnerId
// Il2CppName: get_partyOwnerId
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::StringW (GlobalNamespace::ILobbyPlayersDataModel::*)()>(&GlobalNamespace::ILobbyPlayersDataModel::get_partyOwnerId)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "get_partyOwnerId", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::add_didChangeEvent
// Il2CppName: add_didChangeEvent
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)(::System::Action_1<::StringW>*)>(&GlobalNamespace::ILobbyPlayersDataModel::add_didChangeEvent)> {
static const MethodInfo* get() {
static auto* value = &::il2cpp_utils::MakeGeneric(::il2cpp_utils::GetClassFromName("System", "Action`1"), ::std::vector<const Il2CppClass*>{::il2cpp_utils::GetClassFromName("System", "String")})->byval_arg;
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "add_didChangeEvent", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::remove_didChangeEvent
// Il2CppName: remove_didChangeEvent
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)(::System::Action_1<::StringW>*)>(&GlobalNamespace::ILobbyPlayersDataModel::remove_didChangeEvent)> {
static const MethodInfo* get() {
static auto* value = &::il2cpp_utils::MakeGeneric(::il2cpp_utils::GetClassFromName("System", "Action`1"), ::std::vector<const Il2CppClass*>{::il2cpp_utils::GetClassFromName("System", "String")})->byval_arg;
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "remove_didChangeEvent", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{value});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerBeatmapLevel
// Il2CppName: SetLocalPlayerBeatmapLevel
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)(::GlobalNamespace::PreviewDifficultyBeatmap*)>(&GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerBeatmapLevel)> {
static const MethodInfo* get() {
static auto* beatmapLevel = &::il2cpp_utils::GetClassFromName("", "PreviewDifficultyBeatmap")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "SetLocalPlayerBeatmapLevel", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{beatmapLevel});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::ClearLocalPlayerBeatmapLevel
// Il2CppName: ClearLocalPlayerBeatmapLevel
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)()>(&GlobalNamespace::ILobbyPlayersDataModel::ClearLocalPlayerBeatmapLevel)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "ClearLocalPlayerBeatmapLevel", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerGameplayModifiers
// Il2CppName: SetLocalPlayerGameplayModifiers
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)(::GlobalNamespace::GameplayModifiers*)>(&GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerGameplayModifiers)> {
static const MethodInfo* get() {
static auto* modifiers = &::il2cpp_utils::GetClassFromName("", "GameplayModifiers")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "SetLocalPlayerGameplayModifiers", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{modifiers});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::ClearLocalPlayerGameplayModifiers
// Il2CppName: ClearLocalPlayerGameplayModifiers
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)()>(&GlobalNamespace::ILobbyPlayersDataModel::ClearLocalPlayerGameplayModifiers)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "ClearLocalPlayerGameplayModifiers", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerIsActive
// Il2CppName: SetLocalPlayerIsActive
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)(bool)>(&GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerIsActive)> {
static const MethodInfo* get() {
static auto* isActive = &::il2cpp_utils::GetClassFromName("System", "Boolean")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "SetLocalPlayerIsActive", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{isActive});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerIsReady
// Il2CppName: SetLocalPlayerIsReady
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)(bool)>(&GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerIsReady)> {
static const MethodInfo* get() {
static auto* isReady = &::il2cpp_utils::GetClassFromName("System", "Boolean")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "SetLocalPlayerIsReady", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{isReady});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerIsInLobby
// Il2CppName: SetLocalPlayerIsInLobby
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)(bool)>(&GlobalNamespace::ILobbyPlayersDataModel::SetLocalPlayerIsInLobby)> {
static const MethodInfo* get() {
static auto* isInLobby = &::il2cpp_utils::GetClassFromName("System", "Boolean")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "SetLocalPlayerIsInLobby", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{isInLobby});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::RequestKickPlayer
// Il2CppName: RequestKickPlayer
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)(::StringW)>(&GlobalNamespace::ILobbyPlayersDataModel::RequestKickPlayer)> {
static const MethodInfo* get() {
static auto* kickedUserId = &::il2cpp_utils::GetClassFromName("System", "String")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "RequestKickPlayer", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{kickedUserId});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::ClearData
// Il2CppName: ClearData
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)()>(&GlobalNamespace::ILobbyPlayersDataModel::ClearData)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "ClearData", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::ClearRecommendations
// Il2CppName: ClearRecommendations
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)()>(&GlobalNamespace::ILobbyPlayersDataModel::ClearRecommendations)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "ClearRecommendations", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::Activate
// Il2CppName: Activate
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)()>(&GlobalNamespace::ILobbyPlayersDataModel::Activate)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "Activate", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: GlobalNamespace::ILobbyPlayersDataModel::Deactivate
// Il2CppName: Deactivate
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::ILobbyPlayersDataModel::*)()>(&GlobalNamespace::ILobbyPlayersDataModel::Deactivate)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::ILobbyPlayersDataModel*), "Deactivate", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
| 63.152542 | 239 | 0.766304 | [
"vector"
] |
3d968c1d803c0fd0700b8aad303183f400541a09 | 14,527 | cpp | C++ | src/libs/configParser/configParser.cpp | kamranshamaei/tarsim | dcb0f28f7b1422ba125c85cd53a1420d69d466eb | [
"Apache-2.0"
] | 22 | 2019-03-01T01:41:53.000Z | 2022-02-28T03:57:40.000Z | src/libs/configParser/configParser.cpp | kamranshamaei/tarsim | dcb0f28f7b1422ba125c85cd53a1420d69d466eb | [
"Apache-2.0"
] | 5 | 2020-01-08T19:21:48.000Z | 2021-07-15T20:39:17.000Z | src/libs/configParser/configParser.cpp | kamranshamaei/tarsim | dcb0f28f7b1422ba125c85cd53a1420d69d466eb | [
"Apache-2.0"
] | 7 | 2019-03-01T02:59:11.000Z | 2022-02-17T14:08:11.000Z | /*
*
* @file: configParser.cpp
*
* @Created on: March 31, 2018
* @Author: Kamran Shamaei
*
*
* @brief -
* <Requirement Doc Reference>
* <Design Doc Reference>
*
* @copyright Copyright [2017-2018] Kamran Shamaei .
* All Rights Reserved.
*
* This file is subject to the terms and conditions defined in
* file 'LICENSE', which is part of this source code package.
*
*/
//INCLUDES
#include "configParser.h"
#include "fileSystem.h"
#include "logClient.h"
namespace tarsim {
// FORWARD DECLARATIONS
// TYPEDEFS AND DEFINES
// ENUMS
// NAMESPACES AND STRUCTS
// CLASS DEFINITION
ConfigParser::ConfigParser(std::string configFolderName)
{
m_configFolderName = configFolderName;
std::string dummyString = "";
if (!FileSystem::splitFilename(
FileSystem::getexepath(), m_winDefaultFileName, dummyString)) {
m_winDefaultFileName = "";
}
m_winDefaultFileName = m_winDefaultFileName + "default/win.txt";
// Load rigid body system configuration data
m_rbs = new RigidBodySystem();
std::string configFileName = configFolderName + "/rbs.txt";
if (!FileSystem::loadProtoFile(configFileName, m_rbs)) {
throw std::invalid_argument("Failed to load the simulator config data");
}
if (m_rbs == nullptr) {
throw std::invalid_argument("Specified file has no rigid body system data");
}
LOG_INFO("Rigid body system data were loaded from file %s\n",
configFileName.c_str());
// Load gui configuration data
m_win = new Window();
configFileName = configFolderName + "/win.txt";
if (!FileSystem::loadProtoFile(configFileName, m_win)) {
LOG_INFO("Failed to load window config data from the specified folder, "
"trying default %s", m_winDefaultFileName.c_str());
if (!FileSystem::loadProtoFile(m_winDefaultFileName, m_win)) {
throw std::invalid_argument("Failed to load the simulator config data");
}
}
if (m_win == nullptr) {
throw std::invalid_argument("Specified file has no window data");
}
LOG_INFO("Window data were loaded from file %s\n",
configFileName.c_str());
if (parseRigidBodySystem() != NO_ERR) {
throw std::invalid_argument("No rigid body specified for current node");
}
if (NO_ERR != findEndEffectorNode()) {
throw std::invalid_argument("Failed to find end effector node");
}
LOG_INFO("Rigid body system was successfully represented as a tree:\n");
printf("Robot %s was processed as a rigid body system:\n", m_rbs->name().c_str());
usleep(10000);
printTree(m_root);
}
ConfigParser::~ConfigParser()
{
delete m_tool;
m_tool = nullptr;
cleanTree();
delete m_rbs;
m_rbs = nullptr;
delete m_win;
m_win = nullptr;
}
Errors ConfigParser::parseRigidBodySystem()
{
if (verifyRigidBodySystem() != NO_ERR) {
LOG_FAILURE("Failed to verify rigid body system\n");
return ERR_INVALID;
}
if (createRigidBodySystemTree() != NO_ERR) {
LOG_FAILURE("Failed to verify rigid body system\n");
return ERR_INVALID;
}
return NO_ERR;
}
Errors ConfigParser::verifyRigidBodySystem()
{
if (verifyBase() != NO_ERR) {
LOG_FAILURE("Failed to verify base rigid body\n");
return ERR_INVALID;
}
if (verifyMates() != NO_ERR) {
LOG_FAILURE("Failed to verify base rigid body\n");
return ERR_INVALID;
}
return NO_ERR;
}
Errors ConfigParser::verifyBase()
{
int rbCounter = 0;
int index = -1;
for (int r = 0; r < m_rbs->rigid_bodies_size(); r++) {
if (m_rbs->rigid_bodies(r).is_fixed()) {
index = r;
rbCounter++;
}
}
if (rbCounter != 1) {
LOG_FAILURE("Multiple rigid bodies (%d) are fixed\n", rbCounter);
return ERR_INVALID;
}
m_root = new Node(
nullptr, m_rbs->rigid_bodies(index), Mate(), true, m_configFolderName, 0.0);
m_mapRbToNode.insert(std::pair<int, Node*>(
m_rbs->rigid_bodies(index).index(), m_root));
return NO_ERR;
}
Errors ConfigParser::verifyMates()
{
for (int i = 0; i < m_rbs->mates_size(); i++) {
// Make sure mate indices exist
if (verifyMate(m_rbs->mates(i))) {
LOG_FAILURE("At least one mate index cannot be verified\n");
return ERR_INVALID;
}
}
return NO_ERR;
}
Errors ConfigParser::verifyMate(const Mate &mate)
{
if (mate.sides_size() != 2) {
LOG_FAILURE("Number of mates sides (%d) must be 2\n", mate.sides_size());
return ERR_INVALID;
}
// Make sure mate's indices are not equal
if (mate.sides(0).rigid_body_index() ==
mate.sides(1).rigid_body_index()) {
LOG_FAILURE("Mate bearing and shaft indices are equal");
return ERR_INVALID;
}
// Check if the rigid body and joint exist
bool doesRigidBodyExist[2] = {false, false};
bool doesJointExist[2] = {false, false};
for (int s = 0; s < 2; s++) {
int rbCounter = 0;
for (int r = 0; r < m_rbs->rigid_bodies_size(); r++) {
if (mate.sides(s).rigid_body_index() == m_rbs->rigid_bodies(r).index()) {
rbCounter++;
int jointCounter = 0;
for (int j = 0; j < m_rbs->rigid_bodies(r).joints_size(); j++) {
if (mate.sides(s).joint_index() == m_rbs->rigid_bodies(r).joints(j).index()) {
jointCounter++;
}
}
if (jointCounter == 1) {
doesJointExist[s] = true;
} else {
LOG_FAILURE("Number of matched joints (%d) must be 1\n",
jointCounter);
}
}
}
if (rbCounter == 1) {
doesRigidBodyExist[s] = true;
} else {
LOG_INFO("Number of matched rigid bodies (%d) must be 1\n",
rbCounter);
}
}
if (!doesRigidBodyExist[0] || !doesJointExist[0] ||
!doesRigidBodyExist[1] || !doesJointExist[1]) {
LOG_FAILURE("Mate bearing and shaft indices are equal");
return ERR_INVALID;
}
return NO_ERR;
}
Errors ConfigParser::createRigidBodySystemTree()
{
readPreviousJointValues();
if (createChildren(m_root, m_root) != NO_ERR) {
LOG_FAILURE("Failed to create the tree");
return ERR_INVALID;
}
return NO_ERR;
}
Errors ConfigParser::readPreviousJointValues()
{
std::ifstream file(m_configFolderName + "/"+ k_previousJointValuesFile);
if (file) {
if (file.is_open()) {
std::string indexStr, valueStr;
while ( getline (file, indexStr, ' ') && getline (file, valueStr)) {
m_mapPreviousJointValues[std::stoi(indexStr)] = std::stod(valueStr);
}
file.close();
}
}
return NO_ERR;
}
Errors ConfigParser::createChildren(
Node* root, Node* currentNode)
{
if ((root == nullptr) || (currentNode == nullptr)) {
LOG_FAILURE("Null pointer received\n");
return ERR_INVALID;
}
for (int i = 0; i < m_rbs->mates_size(); i++) {
// If the mates is not already in the tree (mate <--> tree branch)
if (m_mapMateToNode.count(m_rbs->mates(i).index()) == 0) {
int childIndex = -1;
// If the current node the bearing, then the child is the shaft
if (currentNode->getRigidBody()->index() ==
m_rbs->mates(i).sides(0).rigid_body_index()) {
childIndex = m_rbs->mates(i).sides(1).rigid_body_index();
// Else if the current node is the shaft of the mate, then the child
// is the bearing side
} else if (currentNode->getRigidBody()->index() ==
m_rbs->mates(i).sides(1).rigid_body_index()) {
childIndex = m_rbs->mates(i).sides(0).rigid_body_index();
}
// If the child index was found using the mate sides
if (childIndex >= 0) {
if (isInTree(childIndex, root)) {
LOG_FAILURE("Rigid body %d causes a closed chain\n", childIndex);
return ERR_INVALID;
} else {
double jntValue = 0.0;
if ((m_mapPreviousJointValues.end() !=
m_mapPreviousJointValues.find(
m_rbs->mates(i).index())) &&
(m_rbs->should_start_with_previous_joint_values())) {
jntValue = m_mapPreviousJointValues[m_rbs->mates(i).index()];
} else {
jntValue = m_rbs->mates(i).value();
}
size_t index = 0;
for (size_t j = 0; j < m_rbs->rigid_bodies_size(); j++) {
if (childIndex == (int)m_rbs->rigid_bodies(j).index()) {
index = j;
}
}
// Generate a new child (node)
Node* newNode = new Node(
currentNode,
m_rbs->rigid_bodies(index),
m_rbs->mates(i),
false,
m_configFolderName,
jntValue);
// Add the child rigid body to the map so that we know
// where it is
m_mapRbToNode.insert(std::pair<int, Node*>(
newNode->getRigidBody()->index(), newNode));
// Map the mate so that we know where it is when we want
// to set the value of the mate
m_mapMateToNode.insert(std::pair<int, Node*>(
newNode->getMateToParent()->index(), newNode));
if (createChildren(root, newNode) != NO_ERR) {
LOG_FAILURE("Failed to create children for node %d\n",
newNode->getRigidBody()->index());
return ERR_INVALID;
}
}
}
}
}
return NO_ERR;
}
bool ConfigParser::isInTree(int index, Node* node)
{
if (node->getRigidBody()->index() == index) {
return true;
}
for (unsigned int i = 0; i < node->getChildren().size(); i++) {
return isInTree(index, node->getChildren().at(i));
}
return false;
}
RigidBodySystem* ConfigParser::getRbs()
{
return m_rbs;
}
Window* ConfigParser::getWin()
{
return m_win;
}
Node* ConfigParser::getRoot()
{
return m_root;
}
Node* ConfigParser::getNodeOfRigidBody(int index)
{
std::unique_lock<std::mutex> lock(m_mutexMapNodes);
auto it = m_mapRbToNode.find(index);
if (it == m_mapRbToNode.end()) {
LOG_FAILURE("Rigid body %d does not exist", index);
return nullptr;
}
Node* node = it->second;
return node;
}
Node* ConfigParser::getNodeOfMate(int index)
{
std::unique_lock<std::mutex> lock(m_mutexMapNodes);
auto it = m_mapMateToNode.find(index);
if (it == m_mapMateToNode.end()) {
LOG_FAILURE("Mate %d does not exist", index);
return nullptr;
}
Node* node = it->second;
return node;
}
void ConfigParser::depthPush(std::string c)
{
m_depth.insert(m_depthCounter++, " ");
m_depth.insert(m_depthCounter++, c );
m_depth.insert(m_depthCounter++, " ");
m_depth.insert(m_depthCounter++, " ");
m_depth.erase(m_depthCounter, k_depthMaxLength - m_depthCounter);
}
void ConfigParser::depthPop( )
{
m_depth.erase(m_depthCounter -= 4, k_depthMaxLength - m_depthCounter);
}
void ConfigParser::printTree(Node* node)
{
printf("(%d)\n", node->getRigidBody()->index());
for (unsigned int i = 0; i < node->getChildren().size(); i++) {
printf("%s └─", m_depth.c_str());
if (i + 1 < node->getChildren().size()) {
depthPush("|");
} else {
depthPush(" ");
}
printTree(node->getChildren().at(i));
depthPop();
}
}
Errors ConfigParser::findEndEffectorNode()
{
if (NO_ERR != findEndEffectorNodeHere(m_root)) {
LOG_FAILURE("Failed to add joint values actor to the scene");
return ERR_INVALID;
}
return NO_ERR;
}
Errors ConfigParser::findEndEffectorNodeHere(Node* node)
{
if (node == nullptr) {
LOG_FAILURE("Empty node was received");
return ERR_INVALID;
}
for (unsigned int i = 0; i < node->getRigidBody()->frames_size(); i++) {
if (node->getRigidBody()->frames(i).is_end_effector()) {
m_endEffectorNode = node;
m_endEffectorFrameNumber = i;
return NO_ERR;
}
}
for (unsigned int i = 0; i < node->getChildren().size(); i++) {
if (NO_ERR != findEndEffectorNodeHere(node->getChildren().at(i))) {
LOG_FAILURE("Failed to find end effector");
return ERR_INVALID;
}
}
return NO_ERR;
}
Node* ConfigParser::getEndEffectorNode()
{
return m_endEffectorNode;
}
unsigned int ConfigParser::getEndEffectorFrameNumber()
{
return m_endEffectorFrameNumber;
}
void ConfigParser::cleanTree()
{
if (m_rbs->should_start_with_previous_joint_values()) {
std::ofstream file;
std::string fileName = m_configFolderName + "/"+ k_previousJointValuesFile;
file.open (fileName);
deleteNodes(m_root, file);
file.close();
}
}
void ConfigParser::deleteNodes(Node* node, std::ofstream &file)
{
for (unsigned int i = 0; i < node->getChildren().size(); i++) {
deleteNodes(node->getChildren().at(i), file);
}
if (node != m_root) {
file << node->getMateToParent()->index() << " " << node->getCurrentJointValue() << "\n";
}
delete node;
node = nullptr;
}
Errors ConfigParser::loadTool(const std::string &toolName)
{
std::string toolFileName = m_configFolderName + "/" + toolName;
ExternalObject obj;
if (!FileSystem::loadProtoFile(toolFileName, &obj)) {
LOG_FAILURE("Failed to load the simulator config data from %s",
toolFileName.c_str());
return ERR_INVALID;
}
// Generate a new child (node)
delete m_tool;
m_tool = new Object(obj, m_configFolderName);
return NO_ERR;
}
} // end of namespace tarsim
| 28.262646 | 98 | 0.570111 | [
"object"
] |
3d9fcfc91705285143c4b112ebf8aca806702e6d | 4,621 | hpp | C++ | Executable/TopDownShooter/Extension/Celerity/PipelineBuilder.hpp | KonstantinTomashevich/Emergence | 83b1d52bb62bf619f9402e3081dd9de6b0cb232c | [
"Apache-2.0"
] | 3 | 2021-06-02T05:06:48.000Z | 2022-01-26T09:39:44.000Z | Executable/TopDownShooter/Extension/Celerity/PipelineBuilder.hpp | KonstantinTomashevich/Emergence | 83b1d52bb62bf619f9402e3081dd9de6b0cb232c | [
"Apache-2.0"
] | null | null | null | Executable/TopDownShooter/Extension/Celerity/PipelineBuilder.hpp | KonstantinTomashevich/Emergence | 83b1d52bb62bf619f9402e3081dd9de6b0cb232c | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <unordered_set>
#include <Celerity/Pipeline.hpp>
#include <Celerity/World.hpp>
#include <Flow/TaskRegister.hpp>
#include <Task/Executor.hpp>
namespace Emergence::Celerity
{
class TaskConstructor final
{
public:
TaskConstructor (const TaskConstructor &_other) = delete;
TaskConstructor (TaskConstructor &&_other) noexcept;
~TaskConstructor () noexcept;
void DependOn (const char *_taskOrCheckpoint) noexcept;
void MakeDependencyOf (const char *_taskOrCheckpoint) noexcept;
[[nodiscard]] Warehouse::FetchSingletonQuery FetchSingleton (const StandardLayout::Mapping &_typeMapping);
[[nodiscard]] Warehouse::ModifySingletonQuery ModifySingleton (
const StandardLayout::Mapping &_typeMapping) noexcept;
[[nodiscard]] Warehouse::InsertShortTermQuery InsertShortTerm (
const StandardLayout::Mapping &_typeMapping) noexcept;
[[nodiscard]] Warehouse::FetchSequenceQuery FetchSequence (const StandardLayout::Mapping &_typeMapping) noexcept;
[[nodiscard]] Warehouse::ModifySequenceQuery ModifySequence (const StandardLayout::Mapping &_typeMapping) noexcept;
[[nodiscard]] Warehouse::InsertLongTermQuery InsertLongTerm (const StandardLayout::Mapping &_typeMapping) noexcept;
[[nodiscard]] Warehouse::FetchValueQuery FetchValue (
const StandardLayout::Mapping &_typeMapping, const std::vector<StandardLayout::FieldId> &_keyFields) noexcept;
[[nodiscard]] Warehouse::ModifyValueQuery ModifyValue (
const StandardLayout::Mapping &_typeMapping, const std::vector<StandardLayout::FieldId> &_keyFields) noexcept;
[[nodiscard]] Warehouse::FetchAscendingRangeQuery FetchAscendingRange (const StandardLayout::Mapping &_typeMapping,
StandardLayout::FieldId _keyField) noexcept;
[[nodiscard]] Warehouse::ModifyAscendingRangeQuery ModifyAscendingRange (
const StandardLayout::Mapping &_typeMapping, StandardLayout::FieldId _keyField) noexcept;
[[nodiscard]] Warehouse::FetchDescendingRangeQuery FetchDescendingRange (
const StandardLayout::Mapping &_typeMapping, StandardLayout::FieldId _keyField) noexcept;
[[nodiscard]] Warehouse::ModifyDescendingRangeQuery ModifyDescendingRange (
const StandardLayout::Mapping &_typeMapping, StandardLayout::FieldId _keyField) noexcept;
[[nodiscard]] Warehouse::FetchShapeIntersectionQuery FetchShapeIntersection (
const StandardLayout::Mapping &_typeMapping, const std::vector<Warehouse::Dimension> &_dimensions) noexcept;
[[nodiscard]] Warehouse::ModifyShapeIntersectionQuery ModifyShapeIntersection (
const StandardLayout::Mapping &_typeMapping, const std::vector<Warehouse::Dimension> &_dimensions) noexcept;
[[nodiscard]] Warehouse::FetchRayIntersectionQuery FetchRayIntersection (
const StandardLayout::Mapping &_typeMapping, const std::vector<Warehouse::Dimension> &_dimensions) noexcept;
[[nodiscard]] Warehouse::ModifyRayIntersectionQuery ModifyRayIntersection (
const StandardLayout::Mapping &_typeMapping, const std::vector<Warehouse::Dimension> &_dimensions) noexcept;
void SetExecutor (std::function<void ()> _executor) noexcept;
[[nodiscard]] World *GetWorld () const noexcept;
TaskConstructor &operator= (const TaskConstructor &_other) = delete;
/// Move-assignment is allowed, because it makes construction of several tasks from one function easier.
TaskConstructor &operator= (TaskConstructor &&_other) noexcept;
// TODO: Ability to create one showstarter and one finalizer task per pipeline.
private:
friend class PipelineBuilder;
TaskConstructor (PipelineBuilder *_parent, const char *_name) noexcept;
PipelineBuilder *parent;
Flow::Task task;
};
class PipelineBuilder final
{
public:
explicit PipelineBuilder (World *_targetWorld) noexcept;
PipelineBuilder (const PipelineBuilder &_other) = delete;
PipelineBuilder (PipelineBuilder &&_other) = delete;
~PipelineBuilder () = default;
void Begin () noexcept;
[[nodiscard]] TaskConstructor AddTask (const char *_name) noexcept;
void AddCheckpoint (const char *_name) noexcept;
[[nodiscard]] Pipeline *End (std::size_t _maximumChildThreads) noexcept;
EMERGENCE_DELETE_ASSIGNMENT (PipelineBuilder);
private:
friend class TaskConstructor;
void FinishTaskRegistration (Flow::Task _task) noexcept;
World *world;
Flow::TaskRegister taskRegister;
std::unordered_set<std::string> registeredResources;
};
} // namespace Emergence::Celerity
| 37.877049 | 119 | 0.750271 | [
"vector"
] |
3da2aa3b3737e966aef320e15c95ec17eb839e7e | 3,826 | cpp | C++ | src/subcommand/break_main.cpp | AndreaGuarracino/odgi | f4e2be6c3248c56cd584e217ea9616c48ffd3a2b | [
"MIT"
] | 1 | 2021-04-06T08:41:42.000Z | 2021-04-06T08:41:42.000Z | src/subcommand/break_main.cpp | AndreaGuarracino/odgi | f4e2be6c3248c56cd584e217ea9616c48ffd3a2b | [
"MIT"
] | null | null | null | src/subcommand/break_main.cpp | AndreaGuarracino/odgi | f4e2be6c3248c56cd584e217ea9616c48ffd3a2b | [
"MIT"
] | null | null | null | #include "subcommand.hpp"
#include <iostream>
#include "odgi.hpp"
#include "args.hxx"
#include "algorithms/break_cycles.hpp"
namespace odgi {
using namespace odgi::subcommand;
int main_break(int argc, char** argv) {
// trick argumentparser to do the right thing with the subcommand
for (uint64_t i = 1; i < argc-1; ++i) {
argv[i] = argv[i+1];
}
std::string prog_name = "odgi break";
argv[0] = (char*)prog_name.c_str();
--argc;
args::ArgumentParser parser("break cycles in the graph (drops paths)");
args::HelpFlag help(parser, "help", "display this help summary", {'h', "help"});
args::ValueFlag<std::string> odgi_in_file(parser, "FILE", "load the graph from this file", {'i', "idx"});
args::ValueFlag<std::string> odgi_out_file(parser, "FILE", "store the graph in this file", {'o', "out"});
args::ValueFlag<uint64_t> max_cycle_size(parser, "N", "maximum cycle length to break", {'c', "cycle-max-bp"});
args::ValueFlag<uint64_t> max_search_bp(parser, "N", "maximum number of bp per BFS from any node", {'s', "max-search-bp"});
args::ValueFlag<uint64_t> repeat_up_to(parser, "N", "iterate cycle breaking up to N times, or stop if no new edges are removed", {'u', "repeat-up-to"});
args::Flag show(parser, "show", "print edges we would remove", {'d', "show"});
try {
parser.ParseCLI(argc, argv);
} catch (args::Help) {
std::cout << parser;
return 0;
} catch (args::ParseError e) {
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
if (argc==1) {
std::cout << parser;
return 1;
}
if (!odgi_in_file) {
std::cerr << "[odgi break] error: Please specify an input file from where to load the graph via -i=[FILE], --idx=[FILE]." << std::endl;
return 1;
}
if (!odgi_out_file) {
std::cerr << "[odgi break] error: Please specify an output file to where to store the broken graph via -o=[FILE], --out=[FILE]." << std::endl;
return 1;
}
graph_t graph;
assert(argc > 0);
std::string infile = args::get(odgi_in_file);
if (infile.size()) {
if (infile == "-") {
graph.deserialize(std::cin);
} else {
ifstream f(infile.c_str());
graph.deserialize(f);
f.close();
}
}
uint64_t iter_max = args::get(repeat_up_to) ? args::get(repeat_up_to) : 1;
// break cycles
if (args::get(show)) {
std::vector<edge_t> cycle_edges
= algorithms::edges_inducing_cycles(graph,
args::get(max_cycle_size),
args::get(max_search_bp));
for (auto& e : cycle_edges) {
std::cout << graph.get_id(e.first) << (graph.get_is_reverse(e.first)?"-":"+")
<< " -> "
<< graph.get_id(e.second) << (graph.get_is_reverse(e.second)?"-":"+")
<< std::endl;
}
} else {
uint64_t removed_edges
= algorithms::break_cycles(graph,
args::get(max_cycle_size),
args::get(max_search_bp),
iter_max);
if (removed_edges > 0) {
graph.clear_paths();
}
}
std::string outfile = args::get(odgi_out_file);
if (outfile.size()) {
if (outfile == "-") {
graph.serialize(std::cout);
} else {
ofstream f(outfile.c_str());
graph.serialize(f);
f.close();
}
}
return 0;
}
static Subcommand odgi_break("break", "break cycles in the graph",
PIPELINE, 3, main_break);
}
| 34.160714 | 156 | 0.531626 | [
"vector"
] |
3db44cc9aecd663f96f42cc847afc6f09748ed40 | 7,588 | cc | C++ | src/iosource/PktSrc.cc | markh15/zeek | b41cb78f8d6e205d49e175aef2d2279918809cf7 | [
"Apache-2.0"
] | null | null | null | src/iosource/PktSrc.cc | markh15/zeek | b41cb78f8d6e205d49e175aef2d2279918809cf7 | [
"Apache-2.0"
] | null | null | null | src/iosource/PktSrc.cc | markh15/zeek | b41cb78f8d6e205d49e175aef2d2279918809cf7 | [
"Apache-2.0"
] | null | null | null | // See the file "COPYING" in the main distribution directory for copyright.
#include "zeek-config.h"
#include "PktSrc.h"
#include <sys/stat.h>
#include "util.h"
#include "Hash.h"
#include "Net.h"
#include "Sessions.h"
#include "broker/Manager.h"
#include "iosource/Manager.h"
#include "BPF_Program.h"
#include "pcap/pcap.bif.h"
using namespace iosource;
PktSrc::Properties::Properties()
{
selectable_fd = -1;
link_type = -1;
netmask = NETMASK_UNKNOWN;
is_live = false;
}
PktSrc::PktSrc()
{
have_packet = false;
errbuf = "";
SetClosed(true);
next_sync_point = 0;
first_timestamp = 0.0;
current_pseudo = 0.0;
first_wallclock = current_wallclock = 0;
}
PktSrc::~PktSrc()
{
for ( auto code : filters )
delete code;
}
const std::string& PktSrc::Path() const
{
static std::string not_open("not open");
return IsOpen() ? props.path : not_open;
}
const char* PktSrc::ErrorMsg() const
{
return errbuf.size() ? errbuf.c_str() : nullptr;
}
int PktSrc::LinkType() const
{
return IsOpen() ? props.link_type : -1;
}
uint32_t PktSrc::Netmask() const
{
return IsOpen() ? props.netmask : NETMASK_UNKNOWN;
}
bool PktSrc::IsError() const
{
return ! errbuf.empty();
}
bool PktSrc::IsLive() const
{
return props.is_live;
}
double PktSrc::CurrentPacketTimestamp()
{
return current_pseudo;
}
double PktSrc::CurrentPacketWallClock()
{
// We stop time when we are suspended.
if ( net_is_processing_suspended() )
current_wallclock = current_time(true);
return current_wallclock;
}
void PktSrc::Opened(const Properties& arg_props)
{
if ( zeek::Packet::GetLinkHeaderSize(arg_props.link_type) < 0 )
{
char buf[512];
snprintf(buf, sizeof(buf),
"unknown data link type 0x%x", arg_props.link_type);
Error(buf);
Close();
return;
}
props = arg_props;
SetClosed(false);
if ( ! PrecompileFilter(0, "") || ! SetFilter(0) )
{
Close();
return;
}
if ( props.is_live )
{
Info(fmt("listening on %s\n", props.path.c_str()));
// We only register the file descriptor if we're in live
// mode because libpcap's file descriptor for trace files
// isn't a reliable way to know whether we actually have
// data to read.
if ( props.selectable_fd != -1 )
if ( ! iosource_mgr->RegisterFd(props.selectable_fd, this) )
zeek::reporter->FatalError("Failed to register pktsrc fd with iosource_mgr");
}
DBG_LOG(zeek::DBG_PKTIO, "Opened source %s", props.path.c_str());
}
void PktSrc::Closed()
{
SetClosed(true);
if ( props.is_live && props.selectable_fd != -1 )
iosource_mgr->UnregisterFd(props.selectable_fd, this);
DBG_LOG(zeek::DBG_PKTIO, "Closed source %s", props.path.c_str());
}
void PktSrc::Error(const std::string& msg)
{
// We don't report this immediately, Bro will ask us for the error
// once it notices we aren't open.
errbuf = msg;
DBG_LOG(zeek::DBG_PKTIO, "Error with source %s: %s",
IsOpen() ? props.path.c_str() : "<not open>",
msg.c_str());
}
void PktSrc::Info(const std::string& msg)
{
zeek::reporter->Info("%s", msg.c_str());
}
void PktSrc::Weird(const std::string& msg, const zeek::Packet* p)
{
zeek::sessions->Weird(msg.c_str(), p, nullptr);
}
void PktSrc::InternalError(const std::string& msg)
{
zeek::reporter->InternalError("%s", msg.c_str());
}
void PktSrc::ContinueAfterSuspend()
{
current_wallclock = current_time(true);
}
double PktSrc::CheckPseudoTime()
{
if ( ! IsOpen() )
return 0;
if ( ! ExtractNextPacketInternal() )
return 0;
double pseudo_time = current_packet.time - first_timestamp;
double ct = (current_time(true) - first_wallclock) * pseudo_realtime;
return pseudo_time <= ct ? bro_start_time + pseudo_time : 0;
}
void PktSrc::InitSource()
{
Open();
}
void PktSrc::Done()
{
if ( IsOpen() )
Close();
}
void PktSrc::Process()
{
if ( ! IsOpen() )
return;
if ( ! ExtractNextPacketInternal() )
return;
if ( current_packet.Layer2Valid() )
{
if ( pseudo_realtime )
{
current_pseudo = CheckPseudoTime();
net_packet_dispatch(current_pseudo, ¤t_packet, this);
if ( ! first_wallclock )
first_wallclock = current_time(true);
}
else
net_packet_dispatch(current_packet.time, ¤t_packet, this);
}
have_packet = false;
DoneWithPacket();
}
const char* PktSrc::Tag()
{
return "PktSrc";
}
bool PktSrc::ExtractNextPacketInternal()
{
if ( have_packet )
return true;
have_packet = false;
// Don't return any packets if processing is suspended (except for the
// very first packet which we need to set up times).
if ( net_is_processing_suspended() && first_timestamp )
return false;
if ( pseudo_realtime )
current_wallclock = current_time(true);
if ( ExtractNextPacket(¤t_packet) )
{
if ( current_packet.time < 0 )
{
Weird("negative_packet_timestamp", ¤t_packet);
return false;
}
if ( ! first_timestamp )
first_timestamp = current_packet.time;
have_packet = true;
return true;
}
if ( pseudo_realtime && ! IsOpen() )
{
if ( broker_mgr->Active() )
iosource_mgr->Terminate();
}
return false;
}
bool PktSrc::PrecompileBPFFilter(int index, const std::string& filter)
{
if ( index < 0 )
return false;
char errbuf[PCAP_ERRBUF_SIZE];
// Compile filter.
auto* code = new zeek::detail::BPF_Program();
if ( ! code->Compile(zeek::BifConst::Pcap::snaplen, LinkType(), filter.c_str(), Netmask(), errbuf, sizeof(errbuf)) )
{
std::string msg = fmt("cannot compile BPF filter \"%s\"", filter.c_str());
if ( *errbuf )
msg += ": " + std::string(errbuf);
Error(msg);
delete code;
return false;
}
// Store it in vector.
if ( index >= static_cast<int>(filters.size()) )
filters.resize(index + 1);
if ( auto old = filters[index] )
delete old;
filters[index] = code;
return true;
}
zeek::detail::BPF_Program* PktSrc::GetBPFFilter(int index)
{
if ( index < 0 )
return nullptr;
return (static_cast<int>(filters.size()) > index ? filters[index] : nullptr);
}
bool PktSrc::ApplyBPFFilter(int index, const struct pcap_pkthdr *hdr, const u_char *pkt)
{
zeek::detail::BPF_Program* code = GetBPFFilter(index);
if ( ! code )
{
Error(fmt("BPF filter %d not compiled", index));
Close();
return false;
}
if ( code->MatchesAnything() )
return true;
return pcap_offline_filter(code->GetProgram(), hdr, pkt);
}
bool PktSrc::GetCurrentPacket(const zeek::Packet** pkt)
{
if ( ! have_packet )
return false;
*pkt = ¤t_packet;
return true;
}
double PktSrc::GetNextTimeout()
{
// If there's no file descriptor for the source, which is the case for some interfaces like
// myricom, we can't rely on the polling mechanism to wait for data to be available. As gross
// as it is, just spin with a short timeout here so that it will continually poll the
// interface. The old IOSource code had a 20 microsecond timeout between calls to select()
// so just use that.
if ( props.selectable_fd == -1 )
return 0.00002;
// If we're live we want poll to do what it has to with the file descriptor. If we're not live
// but we're not in pseudo-realtime mode, let the loop just spin as fast as it can. If we're
// in pseudo-realtime mode, find the next time that a packet is ready and have poll block until
// then.
if ( IsLive() || net_is_processing_suspended() )
return -1;
else if ( ! pseudo_realtime )
return 0;
if ( ! have_packet )
ExtractNextPacketInternal();
double pseudo_time = current_packet.time - first_timestamp;
double ct = (current_time(true) - first_wallclock) * pseudo_realtime;
return std::max(0.0, pseudo_time - ct);
}
| 21.13649 | 117 | 0.680416 | [
"vector"
] |
3dc03cf65e0c5da75938ed3be9c33682d38f2b1f | 617 | hpp | C++ | GraphPathfinding/GraphAdapter.hpp | KonstantinTomashevich/gamedev-utils | e210616667a621391898ea3aaf773cf5d07275b9 | [
"MIT"
] | 1 | 2021-02-04T18:35:59.000Z | 2021-02-04T18:35:59.000Z | GraphPathfinding/GraphAdapter.hpp | KonstantinTomashevich/gamedev-utils | e210616667a621391898ea3aaf773cf5d07275b9 | [
"MIT"
] | null | null | null | GraphPathfinding/GraphAdapter.hpp | KonstantinTomashevich/gamedev-utils | e210616667a621391898ea3aaf773cf5d07275b9 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
struct VertexOutcomingConnection
{
int target;
float weight;
};
struct GraphEdge
{
int inVertex;
int outVertex;
float weight;
};
template <class T>
class SimpleIterator
{
public:
virtual void Increment () = 0;
virtual T Get () = 0;
virtual bool Valid () = 0;
};
class GraphAdapter
{
public:
virtual SimpleIterator <VertexOutcomingConnection> *GetOutcomingConnections (int vertex) const = 0;
virtual float HeuristicDistance (int beginVertex, int endVertex) const = 0;
virtual void GetEdges (std::vector <GraphEdge> &output) const = 0;
};
| 18.147059 | 103 | 0.6953 | [
"vector"
] |
3dc2404f7e3550da67190750ed9215c74edad30a | 82,040 | hpp | C++ | src/config/configuration_manager.hpp | sandeepcvmware/concord | 51108446dbcfa41f823d2d368bc658a44b6931f2 | [
"Apache-2.0"
] | null | null | null | src/config/configuration_manager.hpp | sandeepcvmware/concord | 51108446dbcfa41f823d2d368bc658a44b6931f2 | [
"Apache-2.0"
] | null | null | null | src/config/configuration_manager.hpp | sandeepcvmware/concord | 51108446dbcfa41f823d2d368bc658a44b6931f2 | [
"Apache-2.0"
] | null | null | null | // Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Definitions used by configuration management system.
// The most central component of this system is the ConcordConfiguration class,
// which provides a framework for defining and managing configuration
// information. Also included in this file are:
// - ConfigurationPath: a struct for specifying paths to specific configuration
// parameters within a ConcordConfiguration, accounting for the fact that
// parameters may belong to arbitrarilly nested instantiable "scopes" such as
// per-node or per-replica parameters.
// - ParameterSelection: a utility class provided to facilitate turning an
// arbitrary function for picking ConfigurationParameters into an iterable set.
// - YAMLConfigurationInput and YAMLConfigurationOutput: Provide functionality
// to input/output the contents of a ConcordConfiguration in YAML.
// - specifyConfiguration and related functions: specifyConfiguration fills out
// a ConcordConfiguration object with the configuration we are currently using;
// it is intended as the authoritative source of truth on what Concord's
// configuration currently looks like and the place to begin if you need to add
// to or modify Concord's configuration. In addition to specifyConfiguration,
// several more functions are declared (following the declaration of
// specifyConfiguration) which encode knwoledge of the current Concord
// configuration and its properties; these functions are intended to make code
// dependent on the configuration more robust and less fragile by pulling out
// logic that requires knowledge about the current configuration and collecting
// it in one place.
#ifndef CONFIG_CONFIGURATION_MANAGER_HPP
#define CONFIG_CONFIGURATION_MANAGER_HPP
#include <fstream>
#include <iostream>
#include <map>
#include <unordered_set>
#include <cryptopp/dll.h>
#include <log4cplus/configurator.h>
#include <log4cplus/loggingmacros.h>
#include <boost/program_options.hpp>
#include <csignal>
#include <fstream>
#include <iostream>
#include "yaml-cpp/yaml.h"
#include "ThresholdSignaturesTypes.h"
namespace concord {
namespace config {
// Exception type for any exceptions thrown by the configuration system that do
// not fit into standard exception types such as std::invalid_argument. More
// specific types of configuration-specific exceptions should be subtypes of
// this exception class and, generally configuration system implementations
// should strongly prefer throwing exceptions of those subtypes of this class
// over constructing exceptions of this class directly.
class ConfigurationException : public std::exception {
public:
explicit ConfigurationException(const std::string& what) : message(what) {}
virtual const char* what() const noexcept override { return message.c_str(); }
private:
std::string message;
};
// Exception type possibly thrown by iterators over configuration structures in
// the event an iterator has become invalid. The primary cause of such an
// iterator invalidation is modification of the underlying object that the
// iterator does not handle.
class InvalidIteratorException : public ConfigurationException {
public:
explicit InvalidIteratorException(const std::string& what)
: ConfigurationException(what), message(what) {}
virtual const char* what() const noexcept override { return message.c_str(); }
private:
std::string message;
};
// Exception type thrown by ConcordConfiguration on attempts to make definitions
// within the configuration it manages that conflict with existing definitions,
// for example, declaration of a configuration parameter with a name that is
// already in use.
class ConfigurationRedefinitionException : public ConfigurationException {
public:
explicit ConfigurationRedefinitionException(const std::string& what)
: ConfigurationException(what), message(what) {}
virtual const char* what() const noexcept override { return message.c_str(); }
private:
std::string message;
};
// Exception type thrown by ConcordConfiguration when a request requires or
// references something that does not exist or cannot be found. For example,
// this includes attempts to read the value for a configuration parameter that
// does not currently have a value loaded.
class ConfigurationResourceNotFoundException : public ConfigurationException {
public:
explicit ConfigurationResourceNotFoundException(const std::string& what)
: ConfigurationException(what), message(what) {}
virtual const char* what() const noexcept override { return message.c_str(); }
private:
std::string message;
};
// struct for referring to specific parameters or scopes within a
// ConcordConfiguration. ConcordConfiguration provides for the definition of
// instantiable scopes that may contain configuration parameters or other scopes
// (for example, these scopes can be used to handle per-node or per-replica
// parameters). This struct enables constructing references to parameters (or
// scopes) given that they may be contained in (possibly nested) scopes, and
// that the scopes in which they are contained may be either instances of scopes
// or the templates from which those instances are created. Several utility
// functions for workign with ConfigurationPaths are also defined for this
// struct.
// For example, a ConfigurationPath could refer to the parameter "port" for the
// 2nd replica. Such a path would be constructed from scratch like this:
//
// ConfigurationPath path("replica", (size_t)2);
// path.subpath.reset(new ConfigurationPath("port", false));
//
// This struct provides no synchronization or guarantees of synchronization.
// Behavior of this class is currently undefined in the event the subpath
// pointers are used to create a cycle.
struct ConfigurationPath {
// Whether this segment of the path is a scope (true indicates a scope, false
// indicates a parameter).
bool isScope;
// If this segment of the path is a scope, whether it is the temmplate for the
// scope or an instance of the scope (true indicates an intance, false
// indicates the template; note useInstance should be ignored if (isScope ==
// false).
bool useInstance;
// Name for this segment of the configuration path, either the name of a scope
// or of a parameter depending on isScope.
std::string name;
// If this segment of the path selects a scope instance, index selects which
// one (note scope indexes are 0-indexed). This field should not be given any
// meaning unless (isScope && useInstance).
size_t index;
// If this segment of the path is not the final segment, subpath points to the
// rest of the path. If this is the final segment, subpath is null. Note
// subpath should be ignored if (isScope == false). Note this
// ConfigurationPath object is considered to own the one pointed to by
// subpath; that one will be deleted by this path's destructor.
std::unique_ptr<ConfigurationPath> subpath;
// Default constructor for ConfigurationPath. This constructor is defined
// primarily to allow declaring a ConfigurationPath by value without
// initializing it. Although this constructor will make a path to a variable
// with the empty string as its name, client code should not rely on the
// behavior of this constructor.
ConfigurationPath();
// Constructs a ConfigurationPath with the given values for name and isScope.
// If isScope is true, subpath will be initialized to null.
ConfigurationPath(const std::string& name, bool isScope = false);
// Constructs a ConfigurationPath to a scope instance with the given name and
// index (this constructor sets isScope and useInstance to true). subpath will
// be initialized to null.
ConfigurationPath(const std::string& name, size_t index);
// Copy constructor for ConfigurationPath. Note that, since each non-terminal
// path step is considered to own the next one, this constructor will
// recursively copy the entire path; subpath will not be alliased between
// other and the newly constructed instance.
ConfigurationPath(const ConfigurationPath& other);
// Destructor for ConcigurationPath. Note subpath will be freed (and this
// freeing will be recursive if the subpath has multiple segments).
~ConfigurationPath();
// Copy assignment operator for ConfigurationPaths. this will be equal to
// other after this operator returns. Note any subpath the caller currently
// has will be freed, and other's subpath (if any) will be recursively copied.
ConfigurationPath& operator=(const ConfigurationPath& other);
// Equality and inequality operators for ConfigurationPaths. If isScope is
// true and subpath exists, the equality check is recursive; it will not
// merely be a test for alliasing of subpath. Note useInstance will be ignored
// if isScope is not true, index will be ignored if isScope and useInstance
// are not both true, and subpath will be ignored if isScope is not true.
bool operator==(const ConfigurationPath& other) const;
bool operator!=(const ConfigurationPath& other) const;
// Generates a string representation of this configuration path. The primary
// intended use case of this function is in generation of human-readable
// output such as error messages. The format is:
// name
// for parameters or scope templates
// name[index]
// for scope instances
// If subpath is non-null,
// /<STRING REPRESENTATION OF THE SUBPATH>
// will be appended. For example, the string representation of a path to the
// "port" parameter for the second replica would be: replica[2]/port
std::string toString() const;
// Returns true if and only if (1) this (the caller) is ultimately a path to a
// scope (i.e. isScope is true for the terminal segment of this
// ConfigurationPath) and (2) other is within that scope. Note this is
// effectively equivalent to this being a scope and a prefix of other.
bool contains(const ConfigurationPath& other) const;
// Concatenate other to the end of this ConfigurationPath.
// If this ConfigurationPath ultimately refers to a parameter, this operation
// is illegal and will throw std::invalid_argument.
ConfigurationPath concatenate(const ConfigurationPath& other) const;
// Get the "leaf" of this ConfigurationPath, that is, its terminal segment.
ConfigurationPath getLeaf() const;
// Get a ConfigurationPath that is equivalent to this path with the "leaf"
// (that is, its terminal segment) truncated. This will return an unaltered
// copy of this path if trimLeaf is called directly on a single-segment path.
ConfigurationPath trimLeaf() const;
};
// Struct for storing "auxiliary state" to a ConcordConfiguration. This class is
// intended to facilitate giving ownership of objects related to or used by the
// configuration to a ConcordConfiguration without breaking
// ConcordConfiguration's properties of being largely agnostic to the contents
// and purpose of a configuration it stores. A ConcordConfiguration can be given
// ownership of a ConfigurationAuxiliaryState with the setAuxiliaryState
// function; that ConfigurationAuxiliaryState object can then be accessed with
// the getAuxiliaryState function. The ConcordConfiguration object will destruct
// its auxiliary state object whenever the ConcordConfiguration is destroyed,
// cleared, or when setAuxiliaryState is called again.
//
// It is anticipated a typical use of auxiliary configuration will involve
// implementing a struct extending ConfigurationAuxiliaryState with member data
// whose ownership is to be given to a ConcordConfiguration and making dynamic
// casts to this subtype when the state is accessed with getAuxiliaryState.
//
// An example of a reason for using this class might be if we are storing
// cryptographic keys in a ConcordConfiguration and need to give the
// ConcordConfiguration ownership of a Cryptosystem object that is needed in
// validating and generating the keys; giving the ConcordConfiguration ownership
// of the object can help ensure the configuration does not outlive the
// cryptographic object and start generating errors or other undesirable
// behavior when trying to validate cryptographic parameters whose validator
// functions depend on the object.
struct ConfigurationAuxiliaryState {
public:
virtual ~ConfigurationAuxiliaryState() {}
// When a ConcordConfiguration is copied, it will call this function to try to
// copy the ConfigurationAuxiliaryState it owns (if it owns any auxiliary
// state). Therefore, a complete implementation of this function for a struct
// extending ConfigurationAuxiliaryState should return a pointer to a newly
// allocated copy of the caller. Keep in mind that ConcordConfiguration scope
// instantiation makes a copy of the scope template for each scope instance
// created.
//
// ConcordConfiguration provides the following guarantees about how it uses
// ConfigurationAuxiliaryState::clone:
// - When a ConcordConfiguration is copied (via either copy construction or
// copy assignment), if the ConcordConfiguraiton copied from owns a non-null
// ConfigurationAuxiliaryState, then clone will be called for that state, the
// configuration copied from will retain its auxiliary state pointer, and the
// ConcordConfiguration copied to will be given the pointer returned by this
// clone function.
// - If a ConcordConfiguration is copied but the configuration copied from has
// a null auxiliary state, no ConfigurationAuxiliaryState::clone will be
// attempted and both the configurations copied from and to will have null
// auxiliary state pointers.
// - A ConcordConfiguration will never call ConfigurationAuxiliaryState::clone
// if that configuration is never copied.
virtual ConfigurationAuxiliaryState* clone() = 0;
};
// The ConcordConfiguration class provides a framework for defining the
// structure and contents of configuration and handles storing and managing that
// configuration. ConcordConfiguration assumes the fundamental unit of
// configuration is a configuration parameter with value representable as a
// string. In addition to allowing definition of configuration parameters,
// ConcordConfiguration also permits the definition of instantiable "scopes"
// which may contain parameters or other scopes (i.e. scopes can be nested,
// theoretically to an arbitrary depth). These scopes can be used to model
// things such as per-replica or per-node parameters. Declaring a scope creates
// a template for its instances; at a later time, the scope can be instantiated
// to create a copy of it for each instance. Scope instances and templates are
// themselves fully-featured ConcordConfiguration objects. One goal in designing
// this class is to enable a common definition of the Concord configuration to
// be shared between each agent involved in the configuration's lifecycle. At
// the time of this writing, that includes a configuration generation utility or
// service and the node consuming the configuration. Other than definition of
// parameters and instantiable scopes, this class currently supports the
// following features:
// - Iteration: The entire contents of a ConcordConfiguration, including all
// parameters, all scopes, or both, can be iterated through as a series of
// ConfigurationPaths.
// - Parameter Tagging: Any parameter can be tagged with any set of arbitrary
// string tags. This is intended to facilitate categorizing parameters.
// - Parameter Validation: Any number of validation functions may be associated
// with any parameter. The validators will be enforced when trying to load a
// parameter, causing a failure if any validator explicitly rejects the
// parameter. Validators may also be re-run at an arbitrary time for any
// parameter to enable support for validators that are sensitive to other
// parameters.
// - Default Values: A default value can be given for any parameter.
// - Parameter Generation: A generation function may be defined for any
// parameter that is automatically generated rather than taken as input.
// - Parameter Type Interpretation: Although this class internally handles and
// processes parameter values as strings, it supports interpreting them as other
// types on access via the hasValue and getValue functions (see comments for
// these functions below). This class relies on template specializations for
// type conversions, so interpretations as arbitrary types are not supported. At
// the type of this writing, conversion to the following types is supported:
// - int
// - short
// - std::string
// - uint16_t
// - uint32_t
// - uint64_t
// - bool
//
// This class currently provides no synchronization or guarantees of
// synchronization and has not been designed with multiple threads writing to
// configuration concurrently in mind.
class ConcordConfiguration {
public:
// Return type for the three function type definitions immediately following.
enum class ParameterStatus { VALID, INSUFFICIENT_INFORMATION, INVALID };
// Type for parameter validator functions.
// A validator should return VALID if it finds the parameter's value valid,
// INVALID if it confirms the value is definitevely invalid, and
// INSUFFICIENT_INFORMATION if it lacks the information to definitively
// confirm the parameter's validity. When a ConcordConfiguration calls a
// parameter validator, it gives the following arguments:
// - value: The value to assess the validity of.
// - config: The ConcordConfiguration calling this function; note validator
// functions will always be given a reference to the root config for this
// parameter (as opposed to the ConcordConfiguration representing the scope
// in which the parameter being validated exists).
// - path: The path to the parameter within this configuration for which
// this value is to be validated.
// - failureMessage: If the validator does not find value to be valid, it
// may choose to write back a message to failureMessage reporting the reason
// it did not find value to be valid.
// - state: An arbitrary pointer provided at the time this validator was
// added to the configuration. It is anticipated this will be used if this
// validator requires additional state.
typedef ParameterStatus (*Validator)(const std::string& value,
const ConcordConfiguration& config,
const ConfigurationPath& path,
std::string* failureMessage,
void* state);
// Type for parameter generation functions.
// A parameter generator should return VALID if it was able to successfully
// generate a valid value, INSUFFICIENT_INFORMATION if it information needed
// by the generator (such as other parameters) is missing, and INVALID if it
// is not possible to generate a valid value under the current state or the
// generator otherwise fails. When a ConcordConfiguration calls a parameter
// generator, it gives the following arguments:
// - config: The ConcordConfiguration calling this function. Note parameter
// generators will always be given a reference to the root config for this
// parameter (as opposed to the ConcordConfiguration representing the scope
// in which the parameter being generated exists).
// - path: Path to the parameter for which a value should be generated.
// - output: String pointer to output the generated value to if generation
// is successful (Note any value written to this pointer will be ignored by
// the ConcordConfiguration if the generator does not return VALID).
// - state: An arbitrary pointer provided at the time this generator was
// added to the configuration. It is anticipated this will be used if the
// generator requires additional state.
typedef ParameterStatus (*Generator)(const ConcordConfiguration& config,
const ConfigurationPath& path,
std::string* output, void* state);
// Type for a scope sizer function. A scope sizer function is called by the
// ConcordConfiguration when instantiation of a scope is requested to
// determine the appropriate size for it under the current configuration. A
// scope sizer should return VALID if it was able to successfully determine
// the correct size for the requested scope, INSUFFICIENT_INFORMATION if needs
// information that is currently not available, and INVALID if it is not
// possible to get a valid size for this scope under the current state or if
// the sizer otherwise fails. When a ConcordConfiguration calls a scope sizer,
// it gives the following arguments:
// - config: The ConcordConfiguration calling this function. Note scope
// sizer functioons will always be called with a reference to the root
// config for this parameter, even if the scope being instantiated itself
// exists in a subscope of the configuration.
// - path: Path to the scope for which a size is being requested.
// - output: size_t pointer to which to output the appropriate size for
// the requested scope (Note the ConcordConfiguration will ignore any value
// written here if the sizer does not return VALID).
// - state: An arbitrary pointer provided at the time the scope being sized
// was declared. It is anticipated this pointer will be used if the scope
// sizer requires any additional state.
typedef ParameterStatus (*ScopeSizer)(const ConcordConfiguration& config,
const ConfigurationPath& path,
size_t* output, void* state);
private:
struct ConfigurationScope {
std::unique_ptr<ConcordConfiguration> instanceTemplate;
bool instantiated;
std::vector<ConcordConfiguration> instances;
std::string description;
ScopeSizer size;
void* sizerState;
ConfigurationScope() {}
ConfigurationScope(const ConfigurationScope& original);
ConfigurationScope& operator=(const ConfigurationScope& original);
};
struct ConfigurationParameter {
std::string description;
bool hasDefaultValue;
std::string defaultValue;
bool initialized;
std::string value;
std::unordered_set<std::string> tags;
Validator validator;
void* validatorState;
Generator generator;
void* generatorState;
ConfigurationParameter() {}
ConfigurationParameter(const ConfigurationParameter& original);
ConfigurationParameter& operator=(const ConfigurationParameter& original);
};
std::unique_ptr<ConfigurationAuxiliaryState> auxiliaryState;
std::string configurationState;
// Both these pointers point to null if this ConcordConfiguration is the root
// scope of its configuration.
ConcordConfiguration* parentScope;
std::unique_ptr<ConfigurationPath> scopePath;
std::map<std::string, ConfigurationScope> scopes;
std::map<std::string, ConfigurationParameter> parameters;
// Private helper functions.
void invalidateIterators();
ConfigurationPath* getCompletePath(const ConfigurationPath& localPath) const;
std::string printCompletePath(const ConfigurationPath& localPath) const;
std::string printCompletePath(const std::string& localParameter) const;
void updateSubscopePaths();
ConfigurationParameter& getParameter(const std::string& parameter,
const std::string& failureMessage);
const ConfigurationParameter& getParameter(
const std::string& parameter, const std::string& failureMessage) const;
const ConcordConfiguration* getRootConfig() const;
template <typename T>
bool interpretAs(std::string value, T& output) const;
template <typename T>
std::string getTypeName() const;
public:
// Complete definition of the iterator type for iterating through a
// ConcordConfiguration returned by begin and end.
class ConfigurationIterator : public std::iterator<std::forward_iterator_tag,
const ConfigurationPath> {
private:
bool recursive;
bool scopes;
bool parameters;
bool instances;
bool templates;
ConcordConfiguration* config;
// Value returned by this iterator; the iterator stores this value itself
// because it returns values by reference rather than by value.
ConfigurationPath retVal;
// State of iteration.
std::map<std::string, ConfigurationScope>::iterator currentScope;
std::map<std::string, ConfigurationScope>::iterator endScopes;
bool usingInstance;
size_t instance;
std::unique_ptr<ConfigurationIterator> currentScopeContents;
std::unique_ptr<ConfigurationIterator> endCurrentScope;
std::map<std::string, ConfigurationParameter>::iterator currentParam;
std::map<std::string, ConfigurationParameter>::iterator endParams;
bool invalid;
void updateRetVal();
public:
ConfigurationIterator();
ConfigurationIterator(ConcordConfiguration& configuration,
bool recursive = true, bool scopes = true,
bool parameters = true, bool instances = true,
bool templates = true, bool end = false);
ConfigurationIterator(const ConfigurationIterator& original);
~ConfigurationIterator();
ConfigurationIterator& operator=(const ConfigurationIterator& original);
bool operator==(const ConfigurationIterator& other) const;
bool operator!=(const ConfigurationIterator& other) const;
const ConfigurationPath& operator*() const;
ConfigurationIterator& operator++();
ConfigurationIterator operator++(int);
void invalidate();
};
private:
// Iterators that need to be invalidated in the event this
// ConcordConfiguration is modified.
std::unordered_set<ConfigurationIterator*> iterators;
void registerIterator(ConfigurationIterator* iterator);
void deregisterIterator(ConfigurationIterator* iterator);
public:
// Type for iterators over this ConcordConfiguration returned by the begin and
// end functions below. These iterators return a series of const
// ConfigurationPath references pointing to each of the objects (scopes or
// parameters) in the configuration that the iterator iterates through.
// Iterators are forward iterators and have all behvior that is standard of
// such iterators in C++. This includes:
// - Support for copy construction and copy assignment.
// - Support for operators == and != to check if two iterators are currently
// at the same position.
// - Support for operator * to get the value at the iterator's current
// position.
// - Support for prefix and postfix operator ++ to advance the iterator.
// Note ConcordConfiguration::Iterators currently do not guarantee that the
// ConfigurationPath references they return will still refer to the same
// ConfigurationPath as they returned once the iterator has been advanced past
// the point where the reference was obtained; code using
// ConcordConfiguration::Iterators should make its own copy of the value
// stored by the reference the iterator returns if it needs the value past
// advancing the iterator.
typedef ConfigurationIterator Iterator;
ConcordConfiguration();
ConcordConfiguration(const ConcordConfiguration& original);
~ConcordConfiguration();
ConcordConfiguration& operator=(const ConcordConfiguration& original);
// Removes all parameter definitions and scope definitions for this
// ConcordConfiguration and resets its "configuration state" to the empty
// string.
void clear();
// Gives this ConcordConfiguration ownership of a ConfigurationAuxiliaryState
// object. The ConfigurationAuxiliaryState object will be freed when this
// function is called again, when this ConcordConfiguration is cleared, or
// when this ConcordConfiguration is destructed, but not before then.
void setAuxiliaryState(ConfigurationAuxiliaryState* auxState);
// Accesses and returns a pointer to the ConfigurationAuxiliaryState object
// this ConcordConfiguration has been given ownership of, if any. Returns
// nullptr if this ConcordConfiguration has not been given any auxiliary
// state.
ConfigurationAuxiliaryState* getAuxiliaryState();
const ConfigurationAuxiliaryState* getAuxiliaryState() const;
// Sets a "configuration state label" for this configuration to the given
// string. ConcordConfiguration itself does not use its own "configuration
// state label", but it can be retrieved and used at any time by client code
// with getConfigurationStateLabel.
void setConfigurationStateLabel(const std::string& state);
// Gets the most recent value passed to setConfigurationStateLabel. Returns an
// empty string if setConfigurationStateLabel has never been called for this
// ConcordConfiguration or if clear has been called more recently than
// setConfigurationStateLabel.
std::string getConfigurationStateLabel() const;
// Adds a new instantiable scope to this configuration. The scope begins empty
// and uninstantiated.
// Arguments:
// - scope: name for the new scope being declared. A
// ConfigurationRedefinitionException will be thrown if a scope with this
// name already exists or if the name is already in use by a parameter. The
// empty string is disallowed as a scope name. Furthermore, scope names are
// disallowed from having an ending matching kYAMLScopeTemplateSuffix
// (defined below). This function will throw an std::invalid_argument if
// scope is not a valid scope name.
// - description: a description for this scope.
// - size: pointer to a scope sizer function to be used to get the
// appropriate size for this scope when it is instantiated. An
// std::invalid_argument will be thrown if a nullptr is given.
// - sizerState: an arbitrary pointer to be passed to the scope sizer
// whenever it is called. It is anticipated this pointer will be used if the
// sizer requires any additional state.
void declareScope(const std::string& scope, const std::string& description,
ScopeSizer size, void* sizerState);
// Gets the description the scope named by the parameter was constructed with.
// Throws a ConfigurationResourceNotFoundException if the requested scope does
// not exist.
std::string getScopeDescription(const std::string& scope) const;
// Instantiates the scope named by the parameter. The sizer function provided
// when the scope was declared will be called to determine its size.
// Instantiation will not be attempted unless the sizer function returns
// VALID. If the scope is instantiated, a new copy of current scope template
// will be made for each instance. If this scope has was already instantiated,
// any existing instances will be deleted when this function instantiates it
// again. Returns the ParameterStatus returned by the scope's sizer function.
// Throws a ConfigurationResourceNotFoundException if no scope exists with the
// given name.
ParameterStatus instantiateScope(const std::string& scope);
// Gets a reference to the scope template for the scope with the name
// specified by the parameter. Modifying the ConcordConfiguration returned by
// this function will also modify the scope it represents within the
// ConcordConfiguration used to call this function. Throws a
// ConfigurationResourceNotFoundException if no scope exists with the given
// name.
ConcordConfiguration& subscope(const std::string& scope);
const ConcordConfiguration& subscope(const std::string& scope) const;
// Gets a reference to a scope instance from the scope named by the scope
// (string) parameter with index specified by the index (size_t) parameter
// (note scope instances are 0-indexed). Modifying the ConcordConfiguration
// returned by this function will also modify the instance within the
// ConcordConfiguration used to call this function. Throws a
// ConfigurationResourceNotFoundEsception if no scope exists with the
// requested name, if the reuested scope has not been instantiated, or if the
// requested index is out of ragne.
ConcordConfiguration& subscope(const std::string& scope, size_t index);
const ConcordConfiguration& subscope(const std::string& scope,
size_t index) const;
// Gets a reference to a scope template or scope instance within this
// ConcordConfiguration (or recursively within any scope within this
// ConcordConfiguration, where "within" is fully transitive) specified by the
// given path. Throws a ConfigurationResourceNotFoundException if no scope
// exists at the specified path within this ConcordConfiguration.
ConcordConfiguration& subscope(const ConfigurationPath& path);
const ConcordConfiguration& subscope(const ConfigurationPath& path) const;
// Returns true if this configuration contains a scope with the given name and
// false otherwise.
bool containsScope(const std::string& name) const;
// Returns true if this configuration contains a scope template or scope
// instance at the given path and false otherwise.
bool containsScope(const ConfigurationPath& path) const;
// Returns true if this configuration contains a scope with the given name and
// that scope has been instantiated and false otherwise. Note a scope may be
// considered instantiated even if it has 0 instances in the event the scope
// sizer returned 0 at instantiation time.
bool scopeIsInstantiated(const std::string& name) const;
// Returns the size (number of instances) that the scope named by the
// parameter is currently instantiated to. Throws a
// ConfigurationResourceNotFoundException if the requested scope does not
// exist or has not been instantiated.
size_t scopeSize(const std::string& scope) const;
// Declares a new parameter in this configuration with the given name and
// description and with no default value. Throws a
// ConfigurationRedefinitionException if a parameter already exists with the
// given name or if that name is already used by a scope.
// The empty string is disallowed as a parameter name. Furthermore, parameters
// are disallowed from having an ending matching kYAMLScopeTemplateSuffix
// (defined below). This function will throw an std::invalid_argument if name
// is not a valid parameter name.
void declareParameter(const std::string& name,
const std::string& description);
// Declares a new parameter in this configuration with the given name,
// description, and default value. Throws a ConfigurationRedifinitionException
// if a parameter already exists with the given name or if that name is
// already used by a scope.
// The empty string is disallowed as a parameter name. Furthermore, parameters
// are disallowed from having an ending matching kYAMLScopeTemplateSuffix
// (defined below). This function will throw an std::invalid_argument if name
// is not a valid parameter name.
void declareParameter(const std::string& name, const std::string& description,
const std::string& defaultValue);
// Adds any tags in the given vector that the parameter in this configuration
// with the given name is not already tagged with to that parameter. Throws a
// ConfigurationResourceNotFoundException if no parameter exists in this
// configuration with the given name.
void tagParameter(const std::string& name,
const std::vector<std::string>& tags);
// Returns true if the parameter in this configuration with the given name
// exists and has been tagged with the given tag, and false if it exists but
// has not been tagged with this tag. Throws a
// ConfigurationResourceNotFoundException if no parameter exists with this
// name.
bool isTagged(const std::string& name, const std::string& tag) const;
// Gets the description that the parameter with the given name was declared
// with. Throws a ConfigurationResourceNotFoundException if no parameter
// exists in this ConcordConfiguration with the given name.
std::string getDescription(const std::string& name) const;
// Adds a validation function to a configuration parameter in this
// ConcordConfiguration. Note that we allow only one validation function per
// parameter. Calling this function for a parameter that already has a
// validator will cause the existing validator to be replaced. Arguments:
// - name: The name of the parameter to add the validator to. Throws a
// ConfigurationResourceNotFoundException if no parameter exists in this
// ConcordConfiguration with this name.
// - validator: Function pointer to the validation function to add to this
// parameter. Throws an std::invalid_argument if this is a null pointer.
// - validatorState: Arbitrary pointer to pass to the validator each time it
// is called; it is expected this pointer will be used if the validator
// requires any additional state.
void addValidator(const std::string& name, Validator validator,
void* validatorState);
// Adds a generation function to a configuration parameter in this
// ConcordConfiguration. Note that a parameter can only have a single
// generator function; calling this function for a parameter that already has
// a generator function will replace the existing generator if this function
// is successful. Arguments:
// - name: The name of the parameter to add the generator to. Throws a
// ConfigurationResourceNotFoundException if no parameter exists in this
// ConcordConfiguration with this name.
// - generator: Function pointer to the generator function to be added. An
// std::invalid_argument will be thrown if a nullptr is given for this
// parameter.
// - generatorState: An arbitrary pointer to pass to the generator each time
// it is called; it is expected this pointer will be used if the generator
// requires additional state.
void addGenerator(const std::string& name, Generator generator,
void* generatorState);
// Returns true if this ConcordConfiguration contains a parameter with the
// given name and false otherwise.
bool contains(const std::string& name) const;
// Returns true if there is a parameter within this ConcordConfiguraiton at
// the given path and false otherwise. Note this function handles checking the
// appropriate subscope for the parameter if the path has multiple segments.
bool contains(const ConfigurationPath& path) const;
// Returns true if this ConcordConfiguration contains a parameter with the
// given name, that parameter has a value loaded, and that value can be
// validly converted to type T; returns false otherwise. Note this function
// relies on template specialization for type conversions, so not all types
// are supported; see the comments for class ConcordConfiguration for a list
// loadClusterSizeParameters(yamlInput, config, &(std::cout));
// of currently supported types.
template <typename T>
bool hasValue(const std::string& name) const {
T result;
return contains(name) && (parameters.at(name).initialized) &&
interpretAs<T>(parameters.at(name).value, result);
}
// Returns true if there is a parameter within this ConcordConfiguration at
// the given path, that parameter has a value loaded, and that value can be
// validly converted to type T; returns false otherwise. Note this function
// handles checking the appropriate subscope for the parameter if the path has
// multiple segments. Note this function relies on template specialization for
// type conversions, so not all types are supported; see the comments for
// class ConcordConfiguration for a list of currently supported types.
template <typename T>
bool hasValue(const ConfigurationPath& path) const {
if (!contains(path)) {
return false;
}
const ConcordConfiguration* containingScope = this;
if (path.isScope && path.subpath) {
containingScope = &(subscope(path.trimLeaf()));
}
return (containingScope->hasValue<T>(path.getLeaf().name));
}
// Gets the value currently loaded to the parameter in this
// ConcordConfiguration with the given name, interpreted as type T. Throws a
// ConfigurationResourceNotFoundException if this ConcordConfiguration does
// not contain a parameter with the given name, if the requested parameter
// does not have a value loaded, or if the loaded value cannot be interpreted
// as the requested type. Note this function relies on template specialization
// for type conversions, so not all types are supported; see the comments for
// class ConcordConfiguration for a list of currently supported types.
template <typename T>
T getValue(const std::string& name) const {
const ConfigurationParameter& parameter =
getParameter(name, "Could not get value for parameter ");
if (!(parameter.initialized)) {
throw ConfigurationResourceNotFoundException(
"Could not get value for parameter " +
printCompletePath(ConfigurationPath(name, false)) +
": parameter is uninitialized.");
}
T result;
if (!interpretAs<T>(parameter.value, result)) {
throw ConfigurationResourceNotFoundException(
"Could not get value for parameter " +
printCompletePath(ConfigurationPath(name, false)) +
": parameter value \"" + parameter.value +
"\" could not be interpreted as a(n) " + getTypeName<T>() + ".");
}
return result;
}
// Gets the value currently loaded to the parameter in this
// ConcordConfiguration at the given path. Throws a
// ConfigurationResourceNotFoundException if there is no parameter at the
// given path, if the requested parameter does not have a value loaded, or if
// the loaded value cannot be interpreted as the requested type. Note this
// function relies on template specialization for type conversions, so not all
// types are supported; see the comments for class ConcordConfiguration for a
// list of currently supported types.
template <typename T>
T getValue(const ConfigurationPath& path) const {
if (!contains(path)) {
throw ConfigurationResourceNotFoundException(
"Could not get value for parameter " + printCompletePath(path) +
": parameter not found.");
}
const ConcordConfiguration* containingScope = this;
if (path.isScope && path.subpath) {
containingScope = &(subscope(path.trimLeaf()));
}
const ConfigurationParameter& parameter = containingScope->getParameter(
path.getLeaf().name, "Could not get value for parameter ");
if (!parameter.initialized) {
throw ConfigurationResourceNotFoundException(
"Could not get value for parameter " + printCompletePath(path) +
": parameter is uninitialized.");
}
T result;
if (!interpretAs<T>(parameter.value, result)) {
throw ConfigurationResourceNotFoundException(
"Could not get value for parameter " + printCompletePath(path) +
": parameter value \"" + parameter.value +
"\" could not be interpreted as a(n) " + getTypeName<T>() + ".");
}
return result;
}
// Loads a value to a parameter in this ConcordConfiguration. This function
// will return without loading the requested value if the parameter's
// validator (if any) returns an INVALID status for the requested value.
// Arguments:
// - name: The name of the parameter to which to load the value. Throws a
// ConfigurationResourceNotFoundException if no parameter exists with this
// name.
// - value: Value to attempt to load to this parameter.
// - failureMessage: If a non-null pointer is given for failureMessage, the
// named parameter has a validator, and that validator returns a status
// other than valid for value, then any failure message the validator
// provides will be written back to failureMessage.
// - overwrite: If the requested parameter already has a value loaded,
// loadValue will not overwrite it unless true is given for this parameter.
// - prevValue: If loadValue successfully overwrites an existing value and
// prevValue is non-null, the existing value that was overwritten will be
// written to prevValue.
// Returns: the result of running the validator (if any) for this parameter
// for the requested value. If the parameter has no validator, VALID will be
// returned.
ParameterStatus loadValue(const std::string& name, const std::string& value,
std::string* failureMessage = nullptr,
bool overwrite = true,
std::string* prevValue = nullptr);
// Erases the value currently loaded (if any) for a parameter with the given
// name in this ConcordConfiguration. The parameter will have no value loaded
// after this function runs. If a non-null pointer is provided for prevValue
// and this function does erase a value, then the erased value will be written
// back to prevValue. Throws a ConfigurationResourceNotFoundException if no
// parameter exists with the given name.
void eraseValue(const std::string& name, std::string* prevValue = nullptr);
// Erases any and all values currently loaded in this ConcordConfiguration. No
// parameter in this configuraiton (including in any subscope of this
// configuration) will have a value loaded after this function runs.
void eraseAllValues();
// Loads the default value for a given parameter. The value will not be loaded
// if the validator for the parameter (if any) returns an INVALID status for
// the default value. Arguments:
// - name: The name of the parameter for which to load the default value.
// Throws a ConfigurationResourceNotFoundException if no parameter exists
// with this name, or if the named parameter has no default value.
// - failureMessage: If a non-null pointer is given for failureMessage, the
// named parameter has a validator, and that validator returns a status
// other than valid for the default value of the named parameter, then any
// failure message the validator provides will be written back to
// failureMessage.
// - overwrite: If the selected parameter already has a value loaded, that
// value will only be overwritten if true is given for the overwrite
// parameter.
// - prevValue: If a non-null pointer is given for prevValue and loadDefault
// does successfully overwrite an existing value, the existing value will be
// written back to prevValue.
// Returns: the result of running the validator (if any) for the default value
// for this parameter. If the parameter has no validators, VALID will be
// returned.
ParameterStatus loadDefault(const std::string& name,
std::string* failureMessage = nullptr,
bool overwrite = false,
std::string* prevValue = nullptr);
// Load the default values for all parameters within this
// ConcordConfiguration, including in any subscopes, that have default values.
// Any default value for which a validator of its parameter returns INVALID
// will not be loaded. Existing values will not be overwritten unless true is
// given for the overwrite parameter. Scope templates will be ignored unless
// true is given for the includeTemplates parameter. Returns: the result of
// running the validator(s) for every default parameter considered (i.e.
// excluding those in scope templates unless includeTemplates is specified).
// In aggregating the results of running these validator(s), the "least valid"
// result obtained will be returned. That is, VALID will only be returned if
// every validator run returns VALID, and INVALID will be returned over
// INSUFFICIENT_INFORMATION if any validator returns INVALID.
ParameterStatus loadAllDefaults(bool overwrite = false,
bool includeTemplates = false);
// Runs the validator (if any) for the currently loaded value of the named
// parameter and return its result. Throws a
// ConfigurationResourceNotFoundException if no parameter exists with the
// given name. If the requested parameter exists but has no value loaded,
// validate will return INSUFFICIENT_INFORMATION. If the named parameter
// exists, has a value loaded, and has no validators, VALID will be returned.
// If a non-null pointer is given for failureMessage, the named parameter has
// a validator, and the result is not VALID, then any failure message provided
// by the validator will be written back to failureMessage.
ParameterStatus validate(const std::string& name,
std::string* failureMessage = nullptr) const;
// Runs the validator(s) for the currently loaded value(s) in all parameter(s)
// in this ConcordConfiguration, including in any subscopes, and returns their
// result. If this results in no validators being run, then VALID will be
// returned. In aggregating the results of multiple validators, the "least
// valid" result obtained will be returned. That is, VALID will only be
// returned if every validator run returns VALID, and INVALID will be returned
// over INSUFFICIENT_INFORMATION if any validator returns INVALID. If false is
// given for the includeTemplates parameter, then scope templates will be
// skipped. If true is given for ignoreUninitializedParameters, then any
// parameter with no value loaded will be skipped entirely. Otherwise, the
// result of validation for any uninitialized parameter will be considered to
// be INSUFFICIENT_INFORMATION.
ParameterStatus validateAll(bool ignoreUninitializedParameters = true,
bool inclueTemplates = false);
// Runs a parameter's generation function and loads the result. generate will
// not attempt to load the generated value unless the generation function
// returns VALID. Generate also will not load any generated value for which
// the validator of the selected parameter returns INVALID. Parameters:
// - name: Name of the parameter for which to generate a value. A
// ConfigurationResourceNotFoundException will be thrown if no parameter
// exists with the given name or if the named parameter has no generation
// funciton.
// - failureMessage: If a non-null pointer is given for failure message, the
// named parameter has both a generator and validator, and the geneerator
// returns the status VALID but the validator returns a non-VALID status for
// the generated value, then any failure message provided by the validator
// will be written back to failureMessage.
// - overwrite: If the requested parameter is already initialized, the
// existing value will only be overwritten if true is given for overwrite.
// - prevValue: If generate does successfully overwrite an existing value
// and a non-null pointer was given for prevValue, the existing value will
// be written back to prevValue.
// Returns:
// If the parameter's generation function returns a value other than VALID,
// then that value will be returned; otherwise, generate returns the result of
// running the parameter's validator (if any) on its generated values. If the
// generator reutnred VALID but the parameter has no validators, VALID will be
// returned.
ParameterStatus generate(const std::string& name,
std::string* failureMessage = nullptr,
bool overwrite = false,
std::string* prevValue = nullptr);
// Runs the generation functions for any and all parameters in this
// ConcordConfiguration that have generation functions and loads the generated
// values. A value produced by a generator will not be loaded unless the
// generator returned VALID. Furthermore, a value will not be loaded if the
// parameter it would be loaded to has a validator function and that validator
// returns INVALID. generateAll will only overwrite existing values of
// initialized parameters if true is given for overwrite. generateAll will
// ignore scope templates if false is given for includeTemplates. Returns: The
// "least valid" result from the generation of any parameter that is not
// skipped (templates are skipped if false is given for includeTemplates, and
// parameters without generation functions are always skipped). That is, VALID
// will not be returned unless the result for every non-skipped parameter is
// VALID, and INVALID will be returned over INSUFFICIENT_INFORMATION if
// INVALID is obtained for any parameter. The result for each non-skipped
// parameter individually in this aggregation process will be considered to be
// the same as the result the generate function would return for generation of
// just that parameter.
ParameterStatus generateAll(bool overwrite = false,
bool includeTemplates = false);
// ConcordConfiguration::begin and ConcordConfiguration::end, which both
// should be declared immediately below these constant definitions; both
// essentially require enough boolean parameters that having them all as
// individual parameters in their function signatures would be somewhat
// unsightly. To make calls to these functions more intuitive and legible, we
// encode these five booleans in a bitmask. The following constants give the
// bits used in this bitmasks and a number of complete bitmasks for common
// selections of features. At the time of this comment's writing, there are
// five distinct feature bits used in selecting the features of a
// ConcordConfiguration::Iterator, specifically:
// - kTraverseParameters: If this bit is set to 0, the iterator will not
// return any paths to parameters.
// - kTraverseScopes: If this bit is set to 0, the iterator will not return
// any paths to scopes.
// - kTraverseTemplates: If this bit is set to 0, the iterator will ignore
// scope templates entirely.
// - kTraverseInstances: If this bit is set to 0, the iterator will ignore
// scope instances entirely.
// - kTraverseRecursively: If this bit is set to 0, the iterator will not
// recursively traverse subscopes of the ConcordConfiguration this iterator is
// constructed for. That is, it may return parameters directly in this
// configuration objectand single-step paths to scope templates and/or
// instances that lie directly within this configuration object, but it will
// not return any paths with more than one step which would require entering
// subscopes.
typedef uint8_t IteratorFeatureSelection;
const static IteratorFeatureSelection kTraverseParameters = (0x01 << 0);
const static IteratorFeatureSelection kTraverseScopes = (0x01 << 1);
const static IteratorFeatureSelection kTraverseTemplates = (0x01 << 2);
const static IteratorFeatureSelection kTraverseInstances = (0x01 << 3);
const static IteratorFeatureSelection kTraverseRecursively = (0x01 << 4);
const static IteratorFeatureSelection kIterateTopLevelParameters =
kTraverseParameters;
const static IteratorFeatureSelection kIterateTopLevelScopeTemplates =
kTraverseScopes | kTraverseTemplates;
const static IteratorFeatureSelection kIterateTopLevelScopeInstances =
kTraverseScopes | kTraverseInstances;
const static IteratorFeatureSelection kIterateAllTemplateParameters =
kTraverseParameters | kTraverseTemplates | kTraverseRecursively;
const static IteratorFeatureSelection kIterateAllInstanceParameters =
kTraverseParameters | kTraverseInstances | kTraverseRecursively;
const static IteratorFeatureSelection kIterateAllParameters =
kTraverseParameters | kTraverseTemplates | kTraverseInstances |
kTraverseRecursively;
const static IteratorFeatureSelection kIterateAll =
kTraverseParameters | kTraverseScopes | kTraverseTemplates |
kTraverseInstances | kTraverseRecursively;
// Obtains an iterator to the beginning of this ConcordConfiguration. The
// iterator returns the selected contents of this configuration as a series of
// const ConfigurationPath references.
// begin accepts one parameter, features, which is a bitmask for feature
// selection. Definition and documentation of constants for the bits in this
// bitmask and some common feature selections combining them should be
// immediately above this declaration. Note ConcordConfiguration::Iterators
// currently do not guarantee that the ConfigurationPath references they
// return will still refer to the same ConfigurationPath as they returned once
// the iterator has been advanced past the point where the reference was
// obtained; code using ConcordConfiguration::Iterators should make its own
// copy of the value stored by the reference the iterator returns if it needs
// the value past advancing the iterator.
Iterator begin(
IteratorFeatureSelection features = kIterateAllInstanceParameters);
// Obtains an iterator to the end of this ConcordConfiguration. The iterator
// will match the state of an iterator obtained with the begin function
// immediately above, given the same feature selection bitmask, once that
// iterator has exhausted all its contents.
Iterator end(
IteratorFeatureSelection features = kIterateAllInstanceParameters);
};
// A ParameterSelection object is intended to wrap a function that picks
// parameters from a configuration (by giving a boolean verdict on whether any
// particular parameter is contained in the set) and make it an iterable
// collection (with iteration returning ConfigurationPaths for each parameter
// that the function approves of). This class is intended to facilitate jobs
// that should be performed for some arbitrary subset of the configuration
// parameters, such as as I/O on certain parameters.
//
// This class currently does not provide any synchronization or guarantees of
// synchronization.
class ParameterSelection {
public:
// Type for parameter selector functions that this ParameterSelection wraps. a
// ParameterSelector is to accept the following parameters:
// - config: The ConcordConfiguration to which the parameter assessed
// belongs.
// - path: Path to a parameter within the provided conviguration to be
// evaluated. The ParameterSelector should return true if the specified
// parameter is within this selection and false otherwise.
// - state: An arbitrary pointer provided at the time the ParameterSelection
// was constructed with this ParameterSelector. It is anticipated this
// pointer will be used if the ParameterSelector requires any additional
// state.
typedef bool (*ParameterSelector)(const ConcordConfiguration& config,
const ConfigurationPath& path, void* state);
private:
class ParameterSelectionIterator
: public std::iterator<std::forward_iterator_tag,
const ConfigurationPath> {
private:
ParameterSelection* selection;
ConcordConfiguration::Iterator unfilteredIterator;
ConcordConfiguration::Iterator endUnfilteredIterator;
bool invalid;
public:
ParameterSelectionIterator();
ParameterSelectionIterator(ParameterSelection* selection, bool end = false);
ParameterSelectionIterator(const ParameterSelectionIterator& original);
virtual ~ParameterSelectionIterator();
ParameterSelectionIterator& operator=(
const ParameterSelectionIterator& original);
bool operator==(const ParameterSelectionIterator& other) const;
bool operator!=(const ParameterSelectionIterator& other) const;
const ConfigurationPath& operator*() const;
ParameterSelectionIterator& operator++();
ParameterSelectionIterator operator++(int);
void invalidate();
};
ConcordConfiguration* config;
ParameterSelector selector;
void* selectorState;
// Set for keeping track of any iterators over this ParameterSelection so
// they can be invalidated in the event of a concurrent modification of this
// ParameterSelection. At the time of this writing, the only
// ParameterSelection function which is actually considered to modify it and
// invalidate its iterators is its destructor.
std::unordered_set<ParameterSelectionIterator*> iterators;
// Private helper functions.
void registerIterator(ParameterSelectionIterator* iterator);
void deregisterIterator(ParameterSelectionIterator* iterator);
void invalidateIterators();
public:
// Type for iterators through this ParameterSelection returned by the begin
// and end functions below. These iterators return a series of const
// ConfigurationPath references pointing to each parameter in the selction.
// Iterators are forward iterators and have all behvior that is standard of
// such iterators in C++. This includes:
// - Support for copy construction and copy assignment.
// - Support for operators == and != to check if two iterators are currently
// at the same position.
// - Support for operator * to get the value at the iterator's current
// position.
// - Support for prefix and postfix operator ++ to advance the iterator.
typedef ParameterSelectionIterator Iterator;
// Primary constructor for ParameterSelections.
// Parameters:
// - config: ConcordConfiguration that this ParameterSelection should select
// its parameters from.
// - selector: Function pointer of the ParameterSelector type defined above
// that decides whether given parameters are within this selection. This
// constructor will throw an std::invalid_argument if selector is a null
// pointer.
// - selectorState: Arbitrary pointer to be passed to selector each time it
// is called. It is anticipated this pointer will be used for any
// additioinal state the selector requires.
ParameterSelection(ConcordConfiguration& config, ParameterSelector selector,
void* selectorState);
ParameterSelection(const ParameterSelection& original);
~ParameterSelection();
bool contains(const ConfigurationPath& parameter) const;
ParameterSelection::Iterator begin();
ParameterSelection::Iterator end();
};
// A suffix appended to scope names by YAMLConfigurationInput and
// YAMLConfigurationOutput to denote values for scope templates in the
// configuration files. In our current implementations, it is useful to have
// separate identifiers for scope templates and scope instances because we
// generally model the contents of a scope as a list of its instances and there
// is not a particularly natural way to include the contents of the template in
// the instance list.
const std::string kYAMLScopeTemplateSuffix = "__TEMPLATE";
// This class handles reading and inputting ConcordConfiguration values
// serialized to a YAML file. It is intended to be capable of reading
// configuration files output with the YAMLConfigurationOutput class below. With
// respect to configuration file format, this class expects a
// ConcordConfiguration will be serialized in YAML as follows:
// - A ConcordConfiguration, either the primary/root configuration or any of its
// subscope instances and/or templates, is represented with a YAML map.
// - Parameters in a particular scope are serialized in the map representing
// that ConcordConfiguration as an assignment of the parameter's value to the
// parameter's name.
// - A scope templates serialized in this configuration file is represented as a
// map (containing the template's contents) assiggned as a value to a key equal
// to the concatenation of the scope's name and kYAMLScopeTemplateSuffix.
// - Any instantiated scope instnaces serialized in this configuration file
// should be represented by a list of maps, where each map represents the
// contents of an instance. Each map entry in this list represents the scope
// instance with the same index (note scope instances are 0-indexed). This list
// should itself be mapped as a value to a key equal to the name of the
// instantiated scope, and this assigment should be in the map for the
// ConcordConfiguration containing this instantiated scope.
//
// This class currently does not provide any synchronization or guarantees of
// synchronization.
class YAMLConfigurationInput {
private:
std::istream* input;
YAML::Node yaml;
bool success;
void loadParameter(ConcordConfiguration& config,
const ConfigurationPath& path, const YAML::Node& obj,
log4cplus::Logger* errorOut, bool overwrite);
public:
// Constructor for YAMLConfigurationInput; it accepts an std::istream. It is
// expected that the code using the YAMLConfiguration will call parseInput to
// have this YAMLConfigurationInput parse the input from that stream.
YAMLConfigurationInput(std::istream& input);
~YAMLConfigurationInput();
// Parses the input from the std::istream given to this
// YAMLConfigurationInputas YAML and records it for later retrieval with
// loadConfiguration.
//
// Throws: Any exception that occurs while attempting to parse this input. It
// is anticipated this may include I/O exceptions and YAML parse failures.
void parseInput();
// Loads values from the configuration file this YAMLConfigurationInput parsed
// to the given ConcordConfiguration. Parameters:
// - config: ConcordConfiguration to load the requested values to, if
// possible.
// - iterator: Iterator returning ConfigurationPaths or ConfigurationPath
// references of paths to parameters within config to attempt to load values
// for.
// - end: Iterator to the end of the range of ConfigurationPaths requested,
// used to tell when iterator has finished iterating.
// - errorOut: If a non-null logger pointer is provided for errorOut, then an
// error message will be output to that logger in any case where
// loadConfiguration tries to load a value from its input to config, but
// config rejects that value as invalid. These error messages will be of the
// format: "Cannot load value for parameter <PARAMETER NAME>: <FAILURE
// MESSAGE>".
// - overwrite: loadConfiguration will only overwrite existing values in
// config if true is given for the overwrite parameter.
// Returns: true if this YAMLConfigurationInput was able to successfully parse
// the specified YAML configuration file and false otherwise. Note
// loadClusterSizeParameters(yamlInput, config, &(std::cout));
// YAMLConfigurationInput only considers failures to consist of either (a)
// parseInput was never called for this YAMLConfiguraitonInput or (b)
// parseInput was exited before it returned normally due to an exception
// occuring while trying to parse its input; it does not consider it a failure
// if the YAML parse contains unexpected extra information or if the parse is
// missing requested parameter(s). If false is returned, this function will
// not have loaded any values to config. If true is returned, this function
// will have loaded values from the configuration file it parsed to config for
// any parameter that meets the following requirements:
// - iterator returned a path to this parameter.
// - This parameter exists (was declared) in config.
// - The input configuration file had a value for this parameter.
// - config has no value already loaded for this parameter or overwrite is
// true.
// - config did not reject the loaded value of the parameter due to validator
// rejection.
template <class Iterator>
bool loadConfiguration(ConcordConfiguration& config, Iterator iterator,
Iterator end, log4cplus::Logger* errorOut = nullptr,
bool overwrite = true) {
if (!success) {
return false;
}
while (iterator != end) {
if (config.contains(*iterator)) {
loadParameter(config, *iterator, yaml, errorOut, overwrite);
}
++iterator;
}
return true;
}
};
// This class handles serializing ConcordConfiguration values to a YAML file. It
// is intended to be capable of writing configuration files readable by the
// YAMLConfigurationInput class above. As such, it represents
// ConcordConfiguration values in YAML using the same format outlined in the
// documentation of YAMLConfigurationInput above.
//
// This class currently does not provide any synchronization or guarantees of
// synchronization.
class YAMLConfigurationOutput {
private:
std::ostream* output;
YAML::Node yaml;
void addParameterToYAML(const ConcordConfiguration& config,
const ConfigurationPath& path, YAML::Node& yaml);
public:
YAMLConfigurationOutput(std::ostream& output);
~YAMLConfigurationOutput();
// Writes the selected values from the given configuration to the ostream this
// YAMLConfigurationOutput was constructed with. If this function is
// successful (i.e. an exception does not occur), it will output YAML for
// every parameer returned by iterator that config has a value for.
// Parameters:
// - config: ConcordConfiguration from which to write the selected values.
// - iterator: Iterator returning ConfigurationPaths or ConfigurationPath
// references of paths to parameters within config to write the values of.
// - end: Iterator to the end of the range of ConfigurationPaths requested,
// used to tell when iterator has finished iterating.
// Throws: Any exception that occurs while attempting the requested output
// operation. It is anticipated this could include any I/O exceptions that
// occur while trying to write to the std::ostrem this YAMLConfigurationOutput
// was constructed with.
template <class Iterator>
void outputConfiguration(ConcordConfiguration& config, Iterator iterator,
Iterator end) {
yaml.reset(YAML::Node(YAML::NodeType::Map));
while (iterator != end) {
if (config.hasValue<std::string>(*iterator)) {
addParameterToYAML(config, *iterator, yaml);
}
++iterator;
}
(*output) << yaml;
}
};
// Current auxiliary state to the main ConcordConfiguration, containing objects
// that we would like to give the configuration ownership of for purposes of
// memory management. At the time of this writing, this primarily consists of
// cryptographic state.
struct ConcordPrimaryConfigurationAuxiliaryState
: public ConfigurationAuxiliaryState {
std::unique_ptr<Cryptosystem> executionCryptosys;
std::unique_ptr<Cryptosystem> slowCommitCryptosys;
std::unique_ptr<Cryptosystem> commitCryptosys;
std::unique_ptr<Cryptosystem> optimisticCommitCryptosys;
std::vector<std::pair<std::string, std::string>> replicaRSAKeys;
std::vector<std::vector<std::pair<std::string, std::string>>>
clientProxyRSAKeys;
ConcordPrimaryConfigurationAuxiliaryState();
virtual ~ConcordPrimaryConfigurationAuxiliaryState();
virtual ConfigurationAuxiliaryState* clone();
};
const unsigned int kRSAKeyLength = 2048;
// Generates an RSA private/public key pair for use within Concord. This
// function is used primarily at configuration generation time, and, at the time
// of this writing, this function generally should not be used elsewhere within
// Concord's actual code, however, we are currently exposing this functionally
// to facilitate unit testing of components using RSA keys without requiring
// those unit tests to configure an entire Concord cluster. Note the keys are
// returned through an std::pair in the order (private key, public key).
std::pair<std::string, std::string> generateRSAKeyPair(
CryptoPP::RandomPool& randomnessSource);
// Builds a ConcordConfiguration object to contain the definition of the current
// configuration we are using. This function is intended to serve as a single
// source of truth for all places that need to know the current Concord
// configuration format. At the time of this writing, that includes both the
// configuration generation utility and configuration loading in Concord
// replicas.
//
// This function accepts the ConcordConfiguration it will be initializing by
// reference; it clears any existing contents of the ConcordConfiguration it is
// given before filling it with the configuration defintion.
//
// If you need to add new configuration parameters or otherwise change the
// format of our configuration files, you should add to or modify the code in
// this function's implementation.
void specifyConfiguration(ConcordConfiguration& config);
// Additional useful functions containing encoding knowledge about the current
// configuration.
// Loads all parameters necessary to size a concord cluster to the given
// ConcordConfiguration from the given YAMLConfigurationInput. This function
// expects that config was initialized with specifyConfiguration; this function
// also expects the YAMLConfigurationInput has already parsed and cached the
// YAML for its input file, and that the. Throws a
// ConfigurationResourceNotFoundException if values for any required cluster
// sizing parameters cannot be found in the input or cannot be loaded to the
// configuration.
void loadClusterSizeParameters(YAMLConfigurationInput& input,
ConcordConfiguration& config);
// Instantiates the scopes within the given concord node configuration. This
// function expects that config was initialized with specifyConfiguration. This
// function requires that all parameters needed to compute configuration scope
// sizes have already been loaded, which can be done with
// loadClusterSizeParameters. Furthermore, this function expects that input has
// already parsed and cached the YAML values for its input file. Throws a
// ConfigurationResourceNotFoundException if any parameters required to size the
// cluster have not had values loaded to the configuration.
//
// If input contains any values for parameters in scope templates, those
// parameters will also be loaded and propogated to the created instances. We
// choose to integrate the processes for loading values of parameters in
// templates and intantiating the templates into a single function to facilitate
// correctly handling cases where parameter values are given in places that mix
// scope templates and instances (For example, if the input includes a setting
// specific to the first client proxy on each node).
void instantiateTemplatedConfiguration(YAMLConfigurationInput& input,
ConcordConfiguration& config);
// Loads all non-generated (i.e. required and optional input) parameters from
// the given YAMLConfigurationInput to the given ConcordConfiguration object.
// This function expects that config was initialized with specifyConfiguration
// and that its scopes have already been instantiated to the correct sizes for
// this configuration (which can be done with
// instantiateTemplatedConfiguration). Furthermore, it is expected that the
// YAMLConfigurationInput given has already parsed its input file and cached the
// YAML values. This function will throw a
// ConfigurationResourceNotFoundException if any required input parameter is not
// available in the input.
void loadConfigurationInputParameters(YAMLConfigurationInput& input,
ConcordConfiguration& config);
// Runs key generation for all RSA and threshold cryptographic keys required by
// the Concord-BFT replicas in this Concord cluster. It should be noted that
// this does not cause the generated keys to be loaded to the
// ConcordConfiguration object; they are stored in the ConcordConfiguration's
// auxiliary state. We have chosen to generate the keys in this separate step
// rather than having the parameter generation functions the
// ConcordConfiguration is constructed with generate them in order to simplify
// things, given that certain pairs of keys must be generated at the same time
// (for example, a replica's public RSA key must be generated with its private
// key). This function expects the given ConcordConfiguration to have been
// initialized with specifyConfiguration and to have had its scopes instantiated
// to the correct size, which can be done with
// instantiateTemplatedConfiguration. Furthermore, values must be loaded to the
// configuration for all required cluster size parameters and cryptosystem
// selection parameters. A ConfigurationResourceNotFoundException will be thrown
// if any such parameters needed by this function are missing.
void generateConfigurationKeys(ConcordConfiguration& config);
// Validates that the given ConcordConfiguration has values for all parameters
// that are needed in the configuration files; returns true if this is the case
// and false otherwise. This function expects that config was initialized with
// specifyConfiguration.
bool hasAllParametersRequiredAtConfigurationGeneration(
ConcordConfiguration& config);
// Uses the provided YAMLConfigurationOutput to write a configuration file for a
// specified node. This function expects that values for all parameters that are
// desired in the output have already been loaded; it will only output values
// for parameters that are both initialized in config and that should be
// included in the given replica's configuration file. Note this function may
// throw any I/O or YAML serialization exceptions that occur while attempting
// this operation.
//
// Note that, at the time of this writing, Concord supports a feature (see the
// use_loopback_for_local_hosts configuration parameter) whereby loopback
// IPs (i.e. 127.0.0.1) are inserted into each node's configuration file for
// hosts used for internal Concord communication which are on that node. Note
// that, if this feature is enabled in config, this function will handle
// substitution of the loopback IPs as appropriate in the configuration file it
// outputs. Throws an std::invalid_argument if this feature is enabled but the
// loopback IP is rejected by the node's configuration object.
void outputConcordNodeConfiguration(const ConcordConfiguration& config,
YAMLConfigurationOutput& output,
size_t node);
// Loads the Concord configuration for a node (presumably the one running this
// function) from a specified configuration file. This function expects that
// config has been initilized with specifyConfiguration (see above); this
// function also expects that the YAMLConfigurationInput has already parsed its
// input file and cached the YAML values. Furthermore, this function expects
// that the logging system has been initialized so that it can log any issues it
// finds with the configuration. This function will throw a
// ConfigurationResourceNotFoundException if any required configuration
// parameters are missing from the input.
void loadNodeConfiguration(ConcordConfiguration& config,
YAMLConfigurationInput& input);
// Detects which node the given config is for. This function expects that the
// given config has been initialized with specifyConfiguration (see above) and
// that the configuration of interest was already loaded to it. This function
// will throw a ConfigurationResourceNotFoundException if it cannot determine
// which node the configuration is for.
size_t detectLocalNode(ConcordConfiguration& config);
// Initializes the cryptosystems in the given ConcordConfiguration's auxiliary
// state and load the keys contained in the configuration to them so they can be
// used in initializing SBFT to create threshold signers and verifiers. Note
// this function expects that config was initialized with specifyConfiguration
// (see above) and that the entire node configuration has already been loaded
// (this can be done with loadNodeConfiguration (see above)). This function may
// throw a ConfigurationResourceNotFoundException if it detects that any
// information it requires from the configuration is not available.
void loadSBFTCryptosystems(ConcordConfiguration& config);
// Outputs, to output, a mapping represented in JSON reporting which Concord-BFT
// principals (by principal ID) are on each Concord node in the cluster
// configured by config. The JSON output will be a single JSON object. For each
// node in the cluster, this object will contain one name-value pair, where the
// name is a (base 10) string representation of the index of a node in the
// Concord cluster, and the value is an array of numbers, where the numbers are
// the principal IDs of the Concord-BFT principals that have been placed on that
// node. Note the node IDs used are 1-indexed; this is done to make them
// consistent with the Concord configuration file indexes output in the
// filenames generated by conc_genconfig at the time of this writing. Note this
// function does not itself verify that config is a valid configuration and has
// all expected nodes and principal IDs; any missing information will be omitted
// from the output. Note this function may throw any I/O or JSON serializaation
// exceptions that occur while attempting to output the requested file.
void outputPrincipalLocationsMappingJSON(ConcordConfiguration& config,
std::ostream& output);
} // namespace config
} // namespace concord
boost::program_options::variables_map initialize_config(
concord::config::ConcordConfiguration& config, int argc, char** argv);
#endif // CONFIG_CONFIGURATION_MANAGER_HPP
| 53.691099 | 80 | 0.75345 | [
"object",
"vector",
"model"
] |
3dc3d5384df2891a176e45858ac7d06a555139ac | 3,397 | cpp | C++ | snap/eclipse-workspace/CMPE320_prototype1/src/Recipe.cpp | ETSnider/PantryPal | 8239c37701497195878ec07db37ccca61b23d2bb | [
"MIT"
] | null | null | null | snap/eclipse-workspace/CMPE320_prototype1/src/Recipe.cpp | ETSnider/PantryPal | 8239c37701497195878ec07db37ccca61b23d2bb | [
"MIT"
] | null | null | null | snap/eclipse-workspace/CMPE320_prototype1/src/Recipe.cpp | ETSnider/PantryPal | 8239c37701497195878ec07db37ccca61b23d2bb | [
"MIT"
] | null | null | null | #include<vector>
#include<string>
#include<iostream>
#include "Recipe.h"
using namespace std;
/// <summary>
/// 1 parameter Recipe constructor. nm is set to the "name" of the Recipe object, while the
/// "ingredients" attribute is instantiated as empty, and "directions" instantiated as
/// "Put your recipe directions here!"
/// </summary>
/// <param name="nm"> The name of the Recipe </param>
Recipe::Recipe(string nm) : ingredients() {
name = nm;
directions = "Put your recipe directions here!";
}
/// <summary>
/// 2 parameter Recipe constructor. nm is set as the name of the Recipe, while ing is set as
/// the "ingredients" attribute, provided it doesn't contain duplicates. If the vector contains duplicates,\
/// or is empty the constructor will throw a RecipeException.
/// </summary>
/// <param name="nm"> The name of the Recipe </param>
/// <param name="ing"> The "ingredients" attribute of the Recipe. Cannot contain duplicates or be empty</param>
Recipe::Recipe(string nm, vector<Ingredient> ing) {
if (ing.size() == 0) {
throw RecipeException("Ingredients list cannot be empty");
}
else if (dupIng(ing) != 0) {
throw RecipeException("Ingredients list cannot contain duplciate ingredients");
}
else {
name = nm;
ingredients = ing;
directions = "Put your recipe directions here!";
}
}
Recipe::Recipe(string nm, vector<Ingredient> ing, string dir) {
if (ing.size() == 0) {
throw RecipeException("Ingredients list cannot be empty");
}
else if (dupIng(ing) != 0) {
throw RecipeException("Ingredients list cannot contain duplicate ingredients");
}
else {
name = nm;
ingredients = ing;
directions = dir;
}
}
Recipe::Recipe() {
Recipe("");
}
// Accessor code
string Recipe::getName() const {
return name;
}
vector<Ingredient> Recipe::getIngredients() const {
return ingredients;
}
string Recipe::getDirections() const {
return directions;
}
int Recipe::getCalories() const {
return calories;
}
// Mutator code
void Recipe::changeName(string newname) {
name = newname;
}
void Recipe::changeIngredients(vector<Ingredient> newing) {
if (newing.size() == 0) {
throw RecipeException("New ingredients list must not be empty.");
}
ingredients = newing;
}
void Recipe::changeDirections(string newdir) {
directions = newdir;
}
void Recipe::changeCalories(int newcals) {
calories = newcals;
}
// Exception code
RecipeException::RecipeException(const string& message) : message(message) {};
string& RecipeException::what() { return message; };
/// <summary>
/// Checks the provided Ingredient vector for duplicate ingredients by name only.
/// Recipes should not contain duplicate ingredients.
/// </summary>
/// <param name="list"> The Ingredient vector to be checked for duplicate ingredients </param>
/// <returns> Returns 0 if there are no duplicates, 1 if there are any duplicates at all. </returns>
int dupIng(vector<Ingredient> list) {
int eInd = list.size() - 1;
// For each vector element, the rest of the list is checked for duplicates
for (int i = 0; i <= eInd; i++) {
Ingredient ing = list[i];
int j = i + 1;
// Returns 1 if a duplicate is found, otherwise iterates through the rest
for (j ; j <= eInd; j++) {
if (ing.getName() == list[j].getName()) {
return 1;
}
}
}
return 0;
} | 29.284483 | 112 | 0.671769 | [
"object",
"vector"
] |
3dc4181a2e5b1ce2a9bc03b5d19b4f22443d43aa | 1,627 | hpp | C++ | src/converters/log.hpp | Pandhariix/naoqi_driver | 460e778b60e48432aecb506e303db8ce64c8315e | [
"Apache-2.0"
] | 38 | 2015-08-20T15:35:48.000Z | 2022-03-23T13:43:06.000Z | src/converters/log.hpp | Pandhariix/naoqi_driver | 460e778b60e48432aecb506e303db8ce64c8315e | [
"Apache-2.0"
] | 109 | 2015-07-31T16:11:14.000Z | 2022-03-17T14:08:23.000Z | src/converters/log.hpp | Pandhariix/naoqi_driver | 460e778b60e48432aecb506e303db8ce64c8315e | [
"Apache-2.0"
] | 78 | 2015-08-23T08:50:39.000Z | 2022-03-07T11:05:39.000Z | /*
* Copyright 2015 Aldebaran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef CONVERTERS_LOG_HPP
#define CONVERTERS_LOG_HPP
#include <rosgraph_msgs/Log.h>
#include <naoqi_driver/message_actions.h>
#include "converter_base.hpp"
#include <qicore/logmanager.hpp>
#include <qicore/loglistener.hpp>
namespace naoqi
{
namespace converter
{
class LogConverter : public BaseConverter<LogConverter>
{
typedef boost::function<void(rosgraph_msgs::Log&) > Callback_t;
public:
LogConverter( const std::string& name, float frequency, const qi::SessionPtr& sessions );
void reset( );
void registerCallback( const message_actions::MessageAction action, Callback_t cb );
void callAll( const std::vector<message_actions::MessageAction>& actions );
private:
/** Function that sets the NAOqi log level to the ROS one */
void set_qi_logger_level();
qi::LogManagerPtr logger_;
/** Log level that is currently translated to ROS */
qi::LogLevel log_level_;
qi::LogListenerPtr listener_;
std::map<message_actions::MessageAction, Callback_t> callbacks_;
};
} //publisher
} //naoqi
#endif
| 25.421875 | 91 | 0.748617 | [
"vector"
] |
3dc6c1f906a85b849cd678c7c16da8b9b595954c | 53,852 | cpp | C++ | lib/UIlib/UIManager.cpp | fstudio/Phoenix | 28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d | [
"MIT"
] | 8 | 2015-01-23T05:41:46.000Z | 2019-11-20T05:10:27.000Z | lib/UIlib/UIManager.cpp | fstudio/Phoenix | 28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d | [
"MIT"
] | null | null | null | lib/UIlib/UIManager.cpp | fstudio/Phoenix | 28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d | [
"MIT"
] | 4 | 2015-05-05T05:15:43.000Z | 2020-03-07T11:10:56.000Z |
#include "StdAfx.h"
#include "UIManager.h"
#include "UIAnim.h"
#include <zmouse.h>
/////////////////////////////////////////////////////////////////////////////////////
//
//
static UINT GetNameHash(LPCTSTR pstrName)
{
UINT i = 0;
SIZE_T len = _tcslen(pstrName);
while( len-- > 0 ) i = (i << 5) + i + pstrName[len];
return i;
}
static UINT MapKeyState()
{
UINT uState = 0;
if( ::GetKeyState(VK_CONTROL) < 0 ) uState |= MK_CONTROL;
if( ::GetKeyState(VK_RBUTTON) < 0 ) uState |= MK_LBUTTON;
if( ::GetKeyState(VK_LBUTTON) < 0 ) uState |= MK_RBUTTON;
if( ::GetKeyState(VK_SHIFT) < 0 ) uState |= MK_SHIFT;
if( ::GetKeyState(VK_MENU) < 0 ) uState |= MK_ALT;
return uState;
}
/////////////////////////////////////////////////////////////////////////////////////
//
#define IDB_ICONS16 200
#define IDB_ICONS24 201
#define IDB_ICONS32 202
#define IDB_ICONS50 203
typedef struct tagFINDTABINFO
{
CControlUI* pFocus;
CControlUI* pLast;
bool bForward;
bool bNextIsIt;
} FINDTABINFO;
typedef struct tagFINDSHORTCUT
{
TCHAR ch;
bool bPickNext;
} FINDSHORTCUT;
typedef struct tagTIMERINFO
{
CControlUI* pSender;
UINT nLocalID;
HWND hWnd;
UINT uWinTimer;
} TIMERINFO;
/////////////////////////////////////////////////////////////////////////////////////
//
CAnimationSpooler m_anim;
HPEN m_hPens[UICOLOR__LAST] = { 0 };
HFONT m_hFonts[UIFONT__LAST] = { 0 };
HBRUSH m_hBrushes[UICOLOR__LAST] = { 0 };
LOGFONT m_aLogFonts[UIFONT__LAST] = { 0 };
COLORREF m_clrColors[UICOLOR__LAST][2] = { 0 };
TEXTMETRIC m_aTextMetrics[UIFONT__LAST] = { 0 };
HIMAGELIST m_himgIcons16 = NULL;
HIMAGELIST m_himgIcons24 = NULL;
HIMAGELIST m_himgIcons32 = NULL;
HIMAGELIST m_himgIcons50 = NULL;
/////////////////////////////////////////////////////////////////////////////////////
HINSTANCE CPaintManagerUI::m_hInstance = NULL;
HINSTANCE CPaintManagerUI::m_hLangInst = NULL;
CStdPtrArray CPaintManagerUI::m_aPreMessages;
CPaintManagerUI::CPaintManagerUI() :
m_hWndPaint(NULL),
m_hDcPaint(NULL),
m_hDcOffscreen(NULL),
m_hbmpOffscreen(NULL),
m_hwndTooltip(NULL),
m_uTimerID(0x1000),
m_pRoot(NULL),
m_pFocus(NULL),
m_pEventHover(NULL),
m_pEventClick(NULL),
m_pEventKey(NULL),
m_bFirstLayout(true),
m_bFocusNeeded(false),
m_bResizeNeeded(false),
m_bMouseTracking(false),
m_bOffscreenPaint(true),
m_aPostPaint(sizeof(TPostPaintUI))
{
if( m_hFonts[1] == NULL )
{
// Fill in default font information
LOGFONT lf = { 0 };
::GetObject(::GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &lf);
_tcscpy(lf.lfFaceName, _T("Tahoma"));
// TODO: Handle "large fonts" or other font sizes when
// screen resolution changes!!!
lf.lfHeight = -12;
m_aLogFonts[UIFONT_NORMAL] = lf;
m_aLogFonts[UIFONT_CAPTION] = lf;
LOGFONT lfBold = lf;
lfBold.lfWeight += FW_BOLD;
m_aLogFonts[UIFONT_BOLD] = lfBold;
lfBold.lfHeight -= 2;
m_aLogFonts[UIFONT_TITLE] = lfBold;
lfBold.lfHeight -= 4;
m_aLogFonts[UIFONT_HEADLINE] = lfBold;
LOGFONT lfSubscript = lf;
lfSubscript.lfHeight -= 4;
m_aLogFonts[UIFONT_SUBSCRIPT] = lfSubscript;
LOGFONT lfLink = lf;
lfLink.lfUnderline = TRUE;
m_aLogFonts[UIFONT_LINK] = lfLink;
// Fill the color table
m_clrColors[UICOLOR_WINDOW_BACKGROUND][0] = RGB(239,239,235);
m_clrColors[UICOLOR_DIALOG_BACKGROUND][0] = RGB(238,238,238);
m_clrColors[UICOLOR_DIALOG_TEXT_NORMAL][0] = RGB(0,0,0);
m_clrColors[UICOLOR_DIALOG_TEXT_DARK][0] = RGB(96,96,80);
m_clrColors[UICOLOR_TITLE_BACKGROUND][0] = RGB(114,136,172);
m_clrColors[UICOLOR_TITLE_TEXT][0] = RGB(255,255,255);
m_clrColors[UICOLOR_TITLE_BORDER_LIGHT][0] = RGB(171,192,231);
m_clrColors[UICOLOR_TITLE_BORDER_DARK][0] = RGB(0,55,122);
m_clrColors[UICOLOR_BUTTON_BACKGROUND_NORMAL][0] = RGB(250,250,252);
m_clrColors[UICOLOR_BUTTON_BACKGROUND_NORMAL][1] = RGB(215,215,227);
m_clrColors[UICOLOR_BUTTON_BACKGROUND_DISABLED][0] = RGB(248,248,248);
m_clrColors[UICOLOR_BUTTON_BACKGROUND_DISABLED][1] = RGB(214,214,214);
m_clrColors[UICOLOR_BUTTON_BACKGROUND_PUSHED][0] = RGB(215,215,227);
m_clrColors[UICOLOR_BUTTON_BACKGROUND_PUSHED][1] = RGB(250,250,252);
m_clrColors[UICOLOR_BUTTON_TEXT_NORMAL][0] = RGB(0,0,0);
m_clrColors[UICOLOR_BUTTON_TEXT_PUSHED][0] = RGB(0,0,20);
m_clrColors[UICOLOR_BUTTON_TEXT_DISABLED][0] = RGB(204,204,204);
m_clrColors[UICOLOR_BUTTON_BORDER_LIGHT][0] = RGB(123,158,189);
m_clrColors[UICOLOR_BUTTON_BORDER_DARK][0] = RGB(123,158,189);
m_clrColors[UICOLOR_BUTTON_BORDER_DISABLED][0] = RGB(204,204,204);
m_clrColors[UICOLOR_BUTTON_BORDER_FOCUS][0] = RGB(140,140,140);
m_clrColors[UICOLOR_TOOL_BACKGROUND_NORMAL][0] = RGB(114,136,172);
m_clrColors[UICOLOR_TOOL_BACKGROUND_DISABLED][0] = RGB(100,121,156);
m_clrColors[UICOLOR_TOOL_BACKGROUND_HOVER][0] = RGB(100,121,156);
m_clrColors[UICOLOR_TOOL_BACKGROUND_PUSHED][0] = RGB(80,101,136);
m_clrColors[UICOLOR_TOOL_BORDER_NORMAL][0] = RGB(0,55,122);
m_clrColors[UICOLOR_TOOL_BORDER_DISABLED][0] = RGB(0,55,122);
m_clrColors[UICOLOR_TOOL_BORDER_HOVER][0] = RGB(0,55,122);
m_clrColors[UICOLOR_TOOL_BORDER_PUSHED][0] = RGB(0,55,122);
m_clrColors[UICOLOR_EDIT_BACKGROUND_DISABLED][0] = RGB(255,251,255);
m_clrColors[UICOLOR_EDIT_BACKGROUND_READONLY][0] = RGB(255,251,255);
m_clrColors[UICOLOR_EDIT_BACKGROUND_NORMAL][0] = RGB(255,255,255);
m_clrColors[UICOLOR_EDIT_BACKGROUND_HOVER][0] = RGB(255,251,255);
m_clrColors[UICOLOR_EDIT_TEXT_NORMAL][0] = RGB(0,0,0);
m_clrColors[UICOLOR_EDIT_TEXT_DISABLED][0] = RGB(167,166,170);
m_clrColors[UICOLOR_EDIT_TEXT_READONLY][0] = RGB(167,166,170);
m_clrColors[UICOLOR_NAVIGATOR_BACKGROUND][0] = RGB(229,217,213);
m_clrColors[UICOLOR_NAVIGATOR_BACKGROUND][1] = RGB(201,199,187);
m_clrColors[UICOLOR_NAVIGATOR_TEXT_NORMAL][0] = RGB(102,102,102);
m_clrColors[UICOLOR_NAVIGATOR_TEXT_SELECTED][0] = RGB(0,0,0);
m_clrColors[UICOLOR_NAVIGATOR_TEXT_PUSHED][0] = RGB(0,0,0);
m_clrColors[UICOLOR_NAVIGATOR_BORDER_NORMAL][0] = RGB(131,133,116);
m_clrColors[UICOLOR_NAVIGATOR_BORDER_SELECTED][0] = RGB(159,160,144);
m_clrColors[UICOLOR_NAVIGATOR_BUTTON_HOVER][0] = RGB(200,200,200);
m_clrColors[UICOLOR_NAVIGATOR_BUTTON_PUSHED][0] = RGB(184,184,183);
m_clrColors[UICOLOR_NAVIGATOR_BUTTON_SELECTED][0] = RGB(238,238,238);
m_clrColors[UICOLOR_TAB_BACKGROUND_NORMAL][0] = RGB(255,251,255);
m_clrColors[UICOLOR_TAB_FOLDER_NORMAL][0] = RGB(255,251,255);
m_clrColors[UICOLOR_TAB_FOLDER_NORMAL][1] = RGB(233,231,215);
m_clrColors[UICOLOR_TAB_FOLDER_SELECTED][0] = RGB(255,251,255);
m_clrColors[UICOLOR_TAB_BORDER][0] = RGB(148,166,181);
m_clrColors[UICOLOR_TAB_TEXT_NORMAL][0] = RGB(0,0,0);
m_clrColors[UICOLOR_TAB_TEXT_SELECTED][0] = RGB(0,0,0);
m_clrColors[UICOLOR_TAB_TEXT_DISABLED][0] = RGB(0,0,0);
m_clrColors[UICOLOR_HEADER_BACKGROUND][0] = RGB(233,231,215);
m_clrColors[UICOLOR_HEADER_BACKGROUND][1] = RGB(150,150,147);
m_clrColors[UICOLOR_HEADER_BORDER][0] = RGB(218,219,201);
m_clrColors[UICOLOR_HEADER_SEPARATOR][0] = RGB(197,193,177);
m_clrColors[UICOLOR_HEADER_TEXT][0] = RGB(0,0,0);
m_clrColors[UICOLOR_TASK_BACKGROUND][0] = RGB(230,243,255);
m_clrColors[UICOLOR_TASK_BACKGROUND][1] = RGB(255,255,255);
m_clrColors[UICOLOR_TASK_BORDER][0] = RGB(140,158,198);
m_clrColors[UICOLOR_TASK_CAPTION][0] = RGB(140,158,198);
m_clrColors[UICOLOR_TASK_TEXT][0] = RGB(65,65,110);
m_clrColors[UICOLOR_LINK_TEXT_NORMAL][0] = RGB(0,0,255);
m_clrColors[UICOLOR_LINK_TEXT_HOVER][0] = RGB(0,0,100);
m_clrColors[UICOLOR_CONTROL_BACKGROUND_NORMAL][0] = RGB(255,255,255);
m_clrColors[UICOLOR_CONTROL_BACKGROUND_SELECTED][0] = RGB(173,195,231);
m_clrColors[UICOLOR_CONTROL_BACKGROUND_READONLY][0] = RGB(255,255,255);
m_clrColors[UICOLOR_CONTROL_BACKGROUND_DISABLED][0] = RGB(255,255,255);
m_clrColors[UICOLOR_CONTROL_BACKGROUND_HOVER][0] = RGB(233,245,255);
m_clrColors[UICOLOR_CONTROL_BACKGROUND_SORTED][0] = RGB(242,242,246);
m_clrColors[UICOLOR_CONTROL_BACKGROUND_EXPANDED][0] = RGB(255,255,255);
m_clrColors[UICOLOR_CONTROL_BACKGROUND_EXPANDED][1] = RGB(236,242,255);
m_clrColors[UICOLOR_CONTROL_BORDER_NORMAL][0] = RGB(123,158,189);
m_clrColors[UICOLOR_CONTROL_BORDER_SELECTED][0] = RGB(123,158,189);
m_clrColors[UICOLOR_CONTROL_BORDER_DISABLED][0] = RGB(204,204,204);
m_clrColors[UICOLOR_CONTROL_TEXT_NORMAL][0] = RGB(0,0,0);
m_clrColors[UICOLOR_CONTROL_TEXT_SELECTED][0] = RGB(0,0,0);
m_clrColors[UICOLOR_CONTROL_TEXT_DISABLED][0] = RGB(204,204,204);
m_clrColors[UICOLOR_STANDARD_BLACK][0] = RGB(0,0,0);
m_clrColors[UICOLOR_STANDARD_YELLOW][0] = RGB(255,255,204);
m_clrColors[UICOLOR_STANDARD_RED][0] = RGB(255,204,204);
m_clrColors[UICOLOR_STANDARD_GREY][0] = RGB(145,146,119);
m_clrColors[UICOLOR_STANDARD_LIGHTGREY][0] = RGB(195,196,179);
m_clrColors[UICOLOR_STANDARD_WHITE][0] = RGB(255,255,255);
// Boot Windows Common Controls (for the ToolTip control)
::InitCommonControls();
// We need the image library for effects. It is however optional in Windows so
// we'll also need to provide a gracefull fallback.
::LoadLibrary(_T("msimg32.dll"));
}
m_szMinWindow.cx = 140;
m_szMinWindow.cy = 200;
m_ptLastMousePos.x = m_ptLastMousePos.y = -1;
m_uMsgMouseWheel = ::RegisterWindowMessage(MSH_MOUSEWHEEL);
// System Config
m_SystemConfig.bShowKeyboardCues = false;
m_SystemConfig.bScrollLists = false;
// System Metrics
m_SystemMetrics.cxvscroll = (INT) ::GetSystemMetrics(SM_CXVSCROLL);
}
CPaintManagerUI::~CPaintManagerUI()
{
// Delete the control-tree structures
int i;
for( i = 0; i < m_aDelayedCleanup.GetSize(); i++ ) delete static_cast<CControlUI*>(m_aDelayedCleanup[i]);
delete m_pRoot;
// Release other collections
for( i = 0; i < m_aTimers.GetSize(); i++ ) delete static_cast<TIMERINFO*>(m_aTimers[i]);
// Reset other parts...
if( m_hwndTooltip != NULL ) ::DestroyWindow(m_hwndTooltip);
if( m_hDcOffscreen != NULL ) ::DeleteDC(m_hDcOffscreen);
if( m_hbmpOffscreen != NULL ) ::DeleteObject(m_hbmpOffscreen);
if( m_hDcPaint != NULL ) ::ReleaseDC(m_hWndPaint, m_hDcPaint);
m_aPreMessages.Remove(m_aPreMessages.Find(this));
}
void CPaintManagerUI::Init(HWND hWnd)
{
ASSERT(::IsWindow(hWnd));
// Remember the window context we came from
m_hWndPaint = hWnd;
m_hDcPaint = ::GetDC(hWnd);
// We'll want to filter messages globally too
m_aPreMessages.Add(this);
}
HINSTANCE CPaintManagerUI::GetResourceInstance()
{
return m_hInstance;
}
HINSTANCE CPaintManagerUI::GetLanguageInstance()
{
return m_hLangInst;
}
void CPaintManagerUI::SetResourceInstance(HINSTANCE hInst)
{
m_hInstance = hInst;
if( m_hLangInst == NULL ) m_hLangInst = hInst;
}
void CPaintManagerUI::SetLanguageInstance(HINSTANCE hInst)
{
m_hLangInst = hInst;
}
HWND CPaintManagerUI::GetPaintWindow() const
{
return m_hWndPaint;
}
HDC CPaintManagerUI::GetPaintDC() const
{
return m_hDcPaint;
}
POINT CPaintManagerUI::GetMousePos() const
{
return m_ptLastMousePos;
}
SIZE CPaintManagerUI::GetClientSize() const
{
RECT rcClient = { 0 };
::GetClientRect(m_hWndPaint, &rcClient);
return CSize(rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
}
void CPaintManagerUI::SetMinMaxInfo(int cx, int cy)
{
ASSERT(cx>=0 && cy>=0);
m_szMinWindow.cx = cx;
m_szMinWindow.cy = cy;
}
bool CPaintManagerUI::PreMessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& /*lRes*/)
{
switch( uMsg ) {
case WM_KEYDOWN:
{
// Tabbing between controls
if( wParam == VK_TAB ) {
SetNextTabControl(::GetKeyState(VK_SHIFT) >= 0);
m_SystemConfig.bShowKeyboardCues = true;
::InvalidateRect(m_hWndPaint, NULL, FALSE);
return true;
}
// Handle default dialog controls OK and CANCEL.
// If there are controls named "ok" or "cancel" they
// will be activated on keypress.
if( wParam == VK_RETURN ) {
CControlUI* pControl = FindControl(_T("ok"));
if( pControl != NULL && m_pFocus != pControl ) {
if( m_pFocus == NULL || (m_pFocus->GetControlFlags() & UIFLAG_WANTRETURN) == 0 ) {
pControl->Activate();
return true;
}
}
}
if( wParam == VK_ESCAPE ) {
CControlUI* pControl = FindControl(_T("cancel"));
if( pControl != NULL ) {
pControl->Activate();
return true;
}
}
}
break;
case WM_SYSCHAR:
{
// Handle ALT-shortcut key-combinations
FINDSHORTCUT fs = { 0 };
fs.ch = toupper(wParam);
CControlUI* pControl = m_pRoot->FindControl(__FindControlFromShortcut, &fs, UIFIND_VISIBLE | UIFIND_ENABLED | UIFIND_ME_FIRST);
if( pControl != NULL ) {
pControl->SetFocus();
pControl->Activate();
return true;
}
}
break;
case WM_SYSKEYDOWN:
{
// Press ALT once and the shortcuts will be shown in view
if( wParam == VK_MENU && !m_SystemConfig.bShowKeyboardCues ) {
m_SystemConfig.bShowKeyboardCues = true;
::InvalidateRect(m_hWndPaint, NULL, FALSE);
}
if( m_pFocus != NULL ) {
TEventUI event = { 0 };
event.Type = UIEVENT_SYSKEY;
event.chKey = wParam;
event.ptMouse = m_ptLastMousePos;
event.wKeyState = MapKeyState();
event.dwTimestamp = ::GetTickCount();
m_pFocus->Event(event);
}
}
break;
}
return false;
}
bool CPaintManagerUI::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lRes)
{
#ifdef _DEBUG
switch( uMsg ) {
case WM_NCPAINT:
case WM_NCHITTEST:
case WM_SETCURSOR:
break;
default:
TRACE(_T("MSG: %-20s (%08ld)"), TRACEMSG(uMsg), ::GetTickCount());
}
#endif
// Not ready yet?
if( m_hWndPaint == NULL ) return false;
// Cycle through listeners
for( int i = 0; i < m_aMessageFilters.GetSize(); i++ )
{
bool bHandled = false;
LRESULT lResult = static_cast<IMessageFilterUI*>(m_aMessageFilters[i])->MessageHandler(uMsg, wParam, lParam, bHandled);
if( bHandled ) {
lRes = lResult;
return true;
}
}
// Custom handling of events
switch( uMsg ) {
case WM_APP + 1:
{
// Delayed control-tree cleanup. See AttachDialog() for details.
for( int i = 0; i < m_aDelayedCleanup.GetSize(); i++ ) delete static_cast<CControlUI*>(m_aDelayedCleanup[i]);
m_aDelayedCleanup.Empty();
}
break;
case WM_CLOSE:
{
// Make sure all matching "closing" events are sent
TEventUI event = { 0 };
event.ptMouse = m_ptLastMousePos;
event.dwTimestamp = ::GetTickCount();
if( m_pEventHover != NULL ) {
event.Type = UIEVENT_MOUSELEAVE;
event.pSender = m_pEventHover;
m_pEventHover->Event(event);
}
if( m_pEventClick != NULL ) {
event.Type = UIEVENT_BUTTONUP;
event.pSender = m_pEventClick;
m_pEventClick->Event(event);
}
SetFocus(NULL);
// Hmmph, the usual Windows tricks to avoid
// focus loss...
HWND hwndParent = GetWindowOwner(m_hWndPaint);
if( hwndParent != NULL ) ::SetFocus(hwndParent);
}
break;
case WM_ERASEBKGND:
{
// We'll do the painting here...
lRes = 1;
}
return true;
case WM_PAINT:
{
// Should we paint?
RECT rcPaint = { 0 };
if( !::GetUpdateRect(m_hWndPaint, &rcPaint, FALSE) ) return true;
// Do we need to resize anything?
// This is the time where we layout the controls on the form.
// We delay this even from the WM_SIZE messages since resizing can be
// a very expensize operation.
if( m_bResizeNeeded ) {
RECT rcClient = { 0 };
::GetClientRect(m_hWndPaint, &rcClient);
if( !::IsRectEmpty(&rcClient) ) {
HDC hDC = ::CreateCompatibleDC(m_hDcPaint);
m_pRoot->SetPos(rcClient);
::DeleteDC(hDC);
m_bResizeNeeded = false;
// We'll want to notify the window when it is first initialized
// with the correct layout. The window form would take the time
// to submit swipes/animations.
if( m_bFirstLayout ) {
m_bFirstLayout = false;
SendNotify(m_pRoot, _T("windowinit"));
}
}
// Reset offscreen device
if( m_hDcOffscreen != NULL ) ::DeleteDC(m_hDcOffscreen);
if( m_hbmpOffscreen != NULL ) ::DeleteObject(m_hbmpOffscreen);
m_hDcOffscreen = NULL;
m_hbmpOffscreen = NULL;
}
// Set focus to first control?
if( m_bFocusNeeded ) {
SetNextTabControl();
}
//
// Render screen
//
if( m_anim.IsAnimating() )
{
// 3D animation in progress
m_anim.Render();
// Do a minimum paint loop
// Keep the client area invalid so we generate lots of
// WM_PAINT messages. Cross fingers that Windows doesn't
// batch these somehow in the future.
PAINTSTRUCT ps = { 0 };
::BeginPaint(m_hWndPaint, &ps);
::EndPaint(m_hWndPaint, &ps);
::InvalidateRect(m_hWndPaint, NULL, FALSE);
}
else if( m_anim.IsJobScheduled() ) {
// Animation system needs to be initialized
m_anim.Init(m_hWndPaint);
// A 3D animation was scheduled; allow the render engine to
// capture the window content and repaint some other time
if( !m_anim.PrepareAnimation(m_hWndPaint) ) m_anim.CancelJobs();
::InvalidateRect(m_hWndPaint, NULL, TRUE);
}
else
{
// Standard painting of control-tree - no 3D animation now.
// Prepare offscreen bitmap?
if( m_bOffscreenPaint && m_hbmpOffscreen == NULL )
{
RECT rcClient = { 0 };
::GetClientRect(m_hWndPaint, &rcClient);
m_hDcOffscreen = ::CreateCompatibleDC(m_hDcPaint);
m_hbmpOffscreen = ::CreateCompatibleBitmap(m_hDcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
ASSERT(m_hDcOffscreen);
ASSERT(m_hbmpOffscreen);
}
// Begin Windows paint
PAINTSTRUCT ps = { 0 };
::BeginPaint(m_hWndPaint, &ps);
if( m_bOffscreenPaint )
{
// We have an offscreen device to paint on for flickerfree display.
HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(m_hDcOffscreen, m_hbmpOffscreen);
// Paint the image on the offscreen bitmap
int iSaveDC = ::SaveDC(m_hDcOffscreen);
m_pRoot->DoPaint(m_hDcOffscreen, ps.rcPaint);
::RestoreDC(m_hDcOffscreen, iSaveDC);
// Draw alpha bitmaps on top?
for( int i = 0; i < m_aPostPaint.GetSize(); i++ ) {
TPostPaintUI* pBlit = static_cast<TPostPaintUI*>(m_aPostPaint[i]);
CBlueRenderEngineUI::DoPaintAlphaBitmap(m_hDcOffscreen, this, pBlit->hBitmap, pBlit->rc, pBlit->iAlpha);
}
m_aPostPaint.Empty();
// Blit offscreen bitmap back to display
::BitBlt(ps.hdc,
ps.rcPaint.left,
ps.rcPaint.top,
ps.rcPaint.right - ps.rcPaint.left,
ps.rcPaint.bottom - ps.rcPaint.top,
m_hDcOffscreen,
ps.rcPaint.left,
ps.rcPaint.top,
SRCCOPY);
::SelectObject(m_hDcOffscreen, hOldBitmap);
}
else
{
// A standard paint job
int iSaveDC = ::SaveDC(ps.hdc);
m_pRoot->DoPaint(ps.hdc, ps.rcPaint);
::RestoreDC(ps.hdc, iSaveDC);
}
// All Done!
::EndPaint(m_hWndPaint, &ps);
}
}
// If any of the painting requested a resize again, we'll need
// to invalidate the entire window once more.
if( m_bResizeNeeded ) ::InvalidateRect(m_hWndPaint, NULL, FALSE);
return true;
case WM_PRINTCLIENT:
{
RECT rcClient;
::GetClientRect(m_hWndPaint, &rcClient);
HDC hDC = (HDC) wParam;
int save = ::SaveDC(hDC);
m_pRoot->DoPaint(hDC, rcClient);
// Check for traversing children. The crux is that WM_PRINT will assume
// that the DC is positioned at frame coordinates and will paint the child
// control at the wrong position. We'll simulate the entire thing instead.
if( (lParam & PRF_CHILDREN) != 0 ) {
HWND hWndChild = ::GetWindow(m_hWndPaint, GW_CHILD);
while( hWndChild != NULL ) {
RECT rcPos = { 0 };
::GetWindowRect(hWndChild, &rcPos);
::MapWindowPoints(HWND_DESKTOP, m_hWndPaint, reinterpret_cast<LPPOINT>(&rcPos), 2);
::SetWindowOrgEx(hDC, -rcPos.left, -rcPos.top, NULL);
// NOTE: We use WM_PRINT here rather than the expected WM_PRINTCLIENT
// since the latter will not print the nonclient correctly for
// EDIT controls.
::SendMessage(hWndChild, WM_PRINT, wParam, lParam | PRF_NONCLIENT);
hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT);
}
}
::RestoreDC(hDC, save);
}
break;
case WM_GETMINMAXINFO:
{
LPMINMAXINFO lpMMI = (LPMINMAXINFO) lParam;
lpMMI->ptMinTrackSize.x = m_szMinWindow.cx;
lpMMI->ptMinTrackSize.y = m_szMinWindow.cy;
}
break;
case WM_SIZE:
{
if( m_pFocus != NULL ) {
TEventUI event = { 0 };
event.Type = UIEVENT_WINDOWSIZE;
event.dwTimestamp = ::GetTickCount();
m_pFocus->Event(event);
}
if( m_anim.IsAnimating() ) m_anim.CancelJobs();
m_bResizeNeeded = true;
}
return true;
case WM_TIMER:
{
for( int i = 0; i < m_aTimers.GetSize(); i++ ) {
const TIMERINFO* pTimer = static_cast<TIMERINFO*>(m_aTimers[i]);
if( pTimer->hWnd == m_hWndPaint && pTimer->uWinTimer == LOWORD(wParam) ) {
TEventUI event = { 0 };
event.Type = UIEVENT_TIMER;
event.wParam = pTimer->nLocalID;
event.dwTimestamp = ::GetTickCount();
pTimer->pSender->Event(event);
break;
}
}
}
break;
case WM_MOUSEHOVER:
{
m_bMouseTracking = false;
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
CControlUI* pHover = FindControl(pt);
if( pHover == NULL ) break;
// Generate mouse hover event
if( m_pEventHover != NULL ) {
TEventUI event = { 0 };
event.ptMouse = pt;
event.Type = UIEVENT_MOUSEHOVER;
event.pSender = pHover;
event.dwTimestamp = ::GetTickCount();
m_pEventHover->Event(event);
}
// Create tooltip information
CStdString sToolTip = pHover->GetToolTip();
if( sToolTip.IsEmpty() ) return true;
sToolTip.ProcessResourceTokens();
::ZeroMemory(&m_ToolTip, sizeof(TOOLINFO));
m_ToolTip.cbSize = sizeof(TOOLINFO);
m_ToolTip.uFlags = TTF_IDISHWND;
m_ToolTip.hwnd = m_hWndPaint;
m_ToolTip.uId = (UINT) m_hWndPaint;
m_ToolTip.hinst = m_hInstance;
m_ToolTip.lpszText = const_cast<LPTSTR>( (LPCTSTR) sToolTip );
m_ToolTip.rect = pHover->GetPos();
if( m_hwndTooltip == NULL ) {
m_hwndTooltip = ::CreateWindowEx(0, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hWndPaint, NULL, m_hInstance, NULL);
::SendMessage(m_hwndTooltip, TTM_ADDTOOL, 0, (LPARAM) &m_ToolTip);
}
::SendMessage(m_hwndTooltip, TTM_SETTOOLINFO, 0, (LPARAM) &m_ToolTip);
::SendMessage(m_hwndTooltip, TTM_TRACKACTIVATE, TRUE, (LPARAM) &m_ToolTip);
}
return true;
case WM_MOUSELEAVE:
{
if( m_hwndTooltip != NULL ) ::SendMessage(m_hwndTooltip, TTM_TRACKACTIVATE, FALSE, (LPARAM) &m_ToolTip);
if( m_bMouseTracking ) ::SendMessage(m_hWndPaint, WM_MOUSEMOVE, 0, (LPARAM) -1);
m_bMouseTracking = false;
}
break;
case WM_MOUSEMOVE:
{
// Start tracking this entire window again...
if( !m_bMouseTracking ) {
TRACKMOUSEEVENT tme = { 0 };
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER | TME_LEAVE;
tme.hwndTrack = m_hWndPaint;
tme.dwHoverTime = m_hwndTooltip == NULL ? 1000UL : (DWORD) ::SendMessage(m_hwndTooltip, TTM_GETDELAYTIME, TTDT_INITIAL, 0L);
_TrackMouseEvent(&tme);
m_bMouseTracking = true;
}
// Generate the appropriate mouse messages
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
m_ptLastMousePos = pt;
CControlUI* pNewHover = FindControl(pt);
if( pNewHover != NULL && pNewHover->GetManager() != this ) break;
TEventUI event = { 0 };
event.ptMouse = pt;
event.dwTimestamp = ::GetTickCount();
if( pNewHover != m_pEventHover && m_pEventHover != NULL ) {
event.Type = UIEVENT_MOUSELEAVE;
event.pSender = pNewHover;
m_pEventHover->Event(event);
m_pEventHover = NULL;
if( m_hwndTooltip != NULL ) ::SendMessage(m_hwndTooltip, TTM_TRACKACTIVATE, FALSE, (LPARAM) &m_ToolTip);
}
if( pNewHover != m_pEventHover && pNewHover != NULL ) {
event.Type = UIEVENT_MOUSEENTER;
event.pSender = m_pEventHover;
pNewHover->Event(event);
m_pEventHover = pNewHover;
}
if( m_pEventClick != NULL ) {
event.Type = UIEVENT_MOUSEMOVE;
event.pSender = NULL;
m_pEventClick->Event(event);
}
else if( pNewHover != NULL ) {
event.Type = UIEVENT_MOUSEMOVE;
event.pSender = NULL;
pNewHover->Event(event);
}
}
break;
case WM_LBUTTONDOWN:
{
// We alway set focus back to our app (this helps
// when Win32 child windows are placed on the dialog
// and we need to remove them on focus change).
::SetFocus(m_hWndPaint);
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
m_ptLastMousePos = pt;
CControlUI* pControl = FindControl(pt);
if( pControl == NULL ) break;
if( pControl->GetManager() != this ) break;
m_pEventClick = pControl;
pControl->SetFocus();
TEventUI event = { 0 };
event.Type = UIEVENT_BUTTONDOWN;
event.wParam = wParam;
event.lParam = lParam;
event.ptMouse = pt;
event.wKeyState = wParam;
event.dwTimestamp = ::GetTickCount();
pControl->Event(event);
// No need to burden user with 3D animations
m_anim.CancelJobs();
// We always capture the mouse
::SetCapture(m_hWndPaint);
}
break;
case WM_LBUTTONUP:
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
m_ptLastMousePos = pt;
if( m_pEventClick == NULL ) break;
::ReleaseCapture();
TEventUI event = { 0 };
event.Type = UIEVENT_BUTTONUP;
event.wParam = wParam;
event.lParam = lParam;
event.ptMouse = pt;
event.wKeyState = wParam;
event.dwTimestamp = ::GetTickCount();
m_pEventClick->Event(event);
m_pEventClick = NULL;
}
break;
case WM_LBUTTONDBLCLK:
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
m_ptLastMousePos = pt;
CControlUI* pControl = FindControl(pt);
if( pControl == NULL ) break;
if( pControl->GetManager() != this ) break;
TEventUI event = { 0 };
event.Type = UIEVENT_DBLCLICK;
event.ptMouse = pt;
event.wKeyState = wParam;
event.dwTimestamp = ::GetTickCount();
pControl->Event(event);
m_pEventClick = pControl;
// We always capture the mouse
::SetCapture(m_hWndPaint);
}
break;
case WM_CHAR:
{
if( m_pFocus == NULL ) break;
TEventUI event = { 0 };
event.Type = UIEVENT_CHAR;
event.chKey = wParam;
event.ptMouse = m_ptLastMousePos;
event.wKeyState = MapKeyState();
event.dwTimestamp = ::GetTickCount();
m_pFocus->Event(event);
}
break;
case WM_KEYDOWN:
{
if( m_pFocus == NULL ) break;
TEventUI event = { 0 };
event.Type = UIEVENT_KEYDOWN;
event.chKey = wParam;
event.ptMouse = m_ptLastMousePos;
event.wKeyState = MapKeyState();
event.dwTimestamp = ::GetTickCount();
m_pFocus->Event(event);
m_pEventKey = m_pFocus;
}
break;
case WM_KEYUP:
{
if( m_pEventKey == NULL ) break;
TEventUI event = { 0 };
event.Type = UIEVENT_KEYUP;
event.chKey = wParam;
event.ptMouse = m_ptLastMousePos;
event.wKeyState = MapKeyState();
event.dwTimestamp = ::GetTickCount();
m_pEventKey->Event(event);
m_pEventKey = NULL;
}
break;
case WM_SETCURSOR:
{
POINT pt = { 0 };
::GetCursorPos(&pt);
::ScreenToClient(m_hWndPaint, &pt);
CControlUI* pControl = FindControl(pt);
if( pControl == NULL ) break;
if( (pControl->GetControlFlags() & UIFLAG_SETCURSOR) == 0 ) break;
TEventUI event = { 0 };
event.Type = UIEVENT_SETCURSOR;
event.wParam = wParam;
event.lParam = lParam;
event.ptMouse = pt;
event.wKeyState = MapKeyState();
event.dwTimestamp = ::GetTickCount();
pControl->Event(event);
}
return true;
case WM_CTLCOLOREDIT:
{
::DefWindowProc(m_hWndPaint, uMsg, wParam, lParam);
HDC hDC = (HDC) wParam;
::SetTextColor(hDC, GetThemeColor(UICOLOR_EDIT_TEXT_NORMAL));
::SetBkColor(hDC, GetThemeColor(UICOLOR_EDIT_BACKGROUND_NORMAL));
lRes = (LRESULT) GetThemeBrush(UICOLOR_EDIT_BACKGROUND_NORMAL);
}
return true;
case WM_MEASUREITEM:
{
if( wParam == 0 ) break;
HWND hWndChild = ::GetDlgItem(m_hWndPaint, ((LPMEASUREITEMSTRUCT) lParam)->CtlID);
lRes = ::SendMessage(hWndChild, OCM__BASE + uMsg, wParam, lParam);
return true;
}
break;
case WM_DRAWITEM:
{
if( wParam == 0 ) break;
HWND hWndChild = ((LPDRAWITEMSTRUCT) lParam)->hwndItem;
lRes = ::SendMessage(hWndChild, OCM__BASE + uMsg, wParam, lParam);
return true;
}
break;
case WM_VSCROLL:
{
if( lParam == NULL ) break;
CContainerUI* pContainer = static_cast<CContainerUI*>(::GetProp((HWND) lParam, _T("WndX")));
if( pContainer == NULL ) break;
TEventUI event = { 0 };
event.Type = UIEVENT_VSCROLL;
event.wParam = wParam;
event.lParam = lParam;
event.dwTimestamp = ::GetTickCount();
pContainer->Event(event);
}
break;
case WM_NOTIFY:
{
LPNMHDR lpNMHDR = (LPNMHDR) lParam;
if( lpNMHDR != NULL ) lRes = ::SendMessage(lpNMHDR->hwndFrom, OCM__BASE + uMsg, wParam, lParam);
return true;
}
break;
case WM_COMMAND:
{
if( lParam == 0 ) break;
HWND hWndChild = (HWND) lParam;
lRes = ::SendMessage(hWndChild, OCM__BASE + uMsg, wParam, lParam);
return true;
}
break;
default:
// Handle WM_MOUSEWHEEL
if( (uMsg == m_uMsgMouseWheel || uMsg == 0x020A) && m_pFocus != NULL )
{
int zDelta = (int) (short) HIWORD(wParam);
TEventUI event = { 0 };
event.Type = UIEVENT_SCROLLWHEEL;
event.wParam = MAKELPARAM(zDelta < 0 ? SB_LINEDOWN : SB_LINEUP, 0);
event.lParam = lParam;
event.dwTimestamp = ::GetTickCount();
m_pFocus->Event(event);
// Simulate regular scrolling by sending scroll events
event.Type = UIEVENT_VSCROLL;
for( int i = 0; i < abs(zDelta); i += 40 ) m_pFocus->Event(event);
// Let's make sure that the scroll item below the cursor is the same as before...
::SendMessage(m_hWndPaint, WM_MOUSEMOVE, 0, (LPARAM) MAKELPARAM(m_ptLastMousePos.x, m_ptLastMousePos.y));
}
break;
}
return false;
}
void CPaintManagerUI::UpdateLayout()
{
m_bResizeNeeded = true;
::InvalidateRect(m_hWndPaint, NULL, FALSE);
}
void CPaintManagerUI::Invalidate(RECT rcItem)
{
::InvalidateRect(m_hWndPaint, &rcItem, FALSE);
}
bool CPaintManagerUI::AttachDialog(CControlUI* pControl)
{
ASSERT(::IsWindow(m_hWndPaint));
// Reset any previous attachment
SetFocus(NULL);
m_pEventKey = NULL;
m_pEventHover = NULL;
m_pEventClick = NULL;
m_aNameHash.Empty();
// Remove the existing control-tree. We might have gotten inside this function as
// a result of an event fired or similar, so we cannot just delete the objects and
// pull the internal memory of the calling code. We'll delay the cleanup.
if( m_pRoot != NULL ) {
m_aDelayedCleanup.Add(m_pRoot);
::PostMessage(m_hWndPaint, WM_APP + 1, 0, 0L);
}
// Set the dialog root element
m_pRoot = pControl;
// Go ahead...
m_bResizeNeeded = true;
m_bFirstLayout = true;
m_bFocusNeeded = true;
// Initiate all control
return InitControls(pControl);
}
bool CPaintManagerUI::InitControls(CControlUI* pControl, CControlUI* pParent /*= NULL*/)
{
ASSERT(pControl);
if( pControl == NULL ) return false;
pControl->SetManager(this, pParent != NULL ? pParent : pControl->GetParent());
// We're usually initializing the control after adding some more of them to the tree,
// and thus this would be a good time to request the name-map rebuilt.
m_aNameHash.Empty();
return true;
}
void CPaintManagerUI::ReapObjects(CControlUI* pControl)
{
if( pControl == m_pEventKey ) m_pEventKey = NULL;
if( pControl == m_pEventHover ) m_pEventHover = NULL;
if( pControl == m_pEventClick ) m_pEventClick = NULL;
// TODO: Do something with name-hash-map
//m_aNameHash.Empty();
}
void CPaintManagerUI::MessageLoop()
{
MSG msg = { 0 };
while( ::GetMessage(&msg, NULL, 0, 0) ) {
if( !CPaintManagerUI::TranslateMessage(&msg) ) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
bool CPaintManagerUI::TranslateMessage(const LPMSG pMsg)
{
// Pretranslate Message takes care of system-wide messages, such as
// tabbing and shortcut key-combos. We'll look for all messages for
// each window and any child control attached.
HWND hwndParent = ::GetParent(pMsg->hwnd);
UINT uStyle = GetWindowStyle(pMsg->hwnd);
LRESULT lRes = 0;
for( int i = 0; i < m_aPreMessages.GetSize(); i++ ) {
CPaintManagerUI* pT = static_cast<CPaintManagerUI*>(m_aPreMessages[i]);
if( pMsg->hwnd == pT->GetPaintWindow()
|| (hwndParent == pT->GetPaintWindow() && ((uStyle & WS_CHILD) != 0)) )
{
if( pT->PreMessageHandler(pMsg->message, pMsg->wParam, pMsg->lParam, lRes) ) return true;
}
}
return false;
}
bool CPaintManagerUI::AddAnimJob(const CAnimJobUI& job)
{
CAnimJobUI* pJob = new CAnimJobUI(job);
if( pJob == NULL ) return false;
::InvalidateRect(m_hWndPaint, NULL, FALSE);
return m_anim.AddJob(pJob);
}
bool CPaintManagerUI::AddPostPaintBlit(const TPostPaintUI& job)
{
return m_aPostPaint.Add(&job);
}
CControlUI* CPaintManagerUI::GetFocus() const
{
return m_pFocus;
}
void CPaintManagerUI::SetFocus(CControlUI* pControl)
{
// Paint manager window has focus?
if( ::GetFocus() != m_hWndPaint ) ::SetFocus(m_hWndPaint);
// Already has focus?
if( pControl == m_pFocus ) return;
// Remove focus from old control
if( m_pFocus != NULL )
{
TEventUI event = { 0 };
event.Type = UIEVENT_KILLFOCUS;
event.pSender = pControl;
event.dwTimestamp = ::GetTickCount();
m_pFocus->Event(event);
SendNotify(m_pFocus, _T("killfocus"));
m_pFocus = NULL;
}
// Set focus to new control
if( pControl != NULL
&& pControl->GetManager() == this
&& pControl->IsVisible()
&& pControl->IsEnabled() )
{
m_pFocus = pControl;
TEventUI event = { 0 };
event.Type = UIEVENT_SETFOCUS;
event.pSender = pControl;
event.dwTimestamp = ::GetTickCount();
m_pFocus->Event(event);
SendNotify(m_pFocus, _T("setfocus"));
}
}
bool CPaintManagerUI::SetTimer(CControlUI* pControl, UINT nTimerID, UINT uElapse)
{
ASSERT(pControl!=NULL);
ASSERT(uElapse>0);
m_uTimerID = (++m_uTimerID) % 0xFF;
if( !::SetTimer(m_hWndPaint, m_uTimerID, uElapse, NULL) ) return FALSE;
TIMERINFO* pTimer = new TIMERINFO;
if( pTimer == NULL ) return FALSE;
pTimer->hWnd = m_hWndPaint;
pTimer->pSender = pControl;
pTimer->nLocalID = nTimerID;
pTimer->uWinTimer = m_uTimerID;
return m_aTimers.Add(pTimer);
}
bool CPaintManagerUI::KillTimer(CControlUI* pControl, UINT nTimerID)
{
ASSERT(pControl!=NULL);
for( int i = 0; i< m_aTimers.GetSize(); i++ ) {
TIMERINFO* pTimer = static_cast<TIMERINFO*>(m_aTimers[i]);
if( pTimer->pSender == pControl
&& pTimer->hWnd == m_hWndPaint
&& pTimer->nLocalID == nTimerID )
{
::KillTimer(pTimer->hWnd, pTimer->uWinTimer);
delete pTimer;
return m_aTimers.Remove(i);
}
}
return false;
}
bool CPaintManagerUI::SetNextTabControl(bool bForward)
{
// If we're in the process of restructuring the layout we can delay the
// focus calulation until the next repaint.
if( m_bResizeNeeded && bForward ) {
m_bFocusNeeded = true;
::InvalidateRect(m_hWndPaint, NULL, FALSE);
return true;
}
// Find next/previous tabbable control
FINDTABINFO info1 = { 0 };
info1.pFocus = m_pFocus;
info1.bForward = bForward;
CControlUI* pControl = m_pRoot->FindControl(__FindControlFromTab, &info1, UIFIND_VISIBLE | UIFIND_ENABLED | UIFIND_ME_FIRST);
if( pControl == NULL ) {
if( bForward ) {
// Wrap around
FINDTABINFO info2 = { 0 };
info2.pFocus = bForward ? NULL : info1.pLast;
info2.bForward = bForward;
pControl = m_pRoot->FindControl(__FindControlFromTab, &info2, UIFIND_VISIBLE | UIFIND_ENABLED | UIFIND_ME_FIRST);
}
else {
pControl = info1.pLast;
}
}
if( pControl != NULL ) SetFocus(pControl);
m_bFocusNeeded = false;
return true;
}
TSystemSettingsUI CPaintManagerUI::GetSystemSettings() const
{
return m_SystemConfig;
}
void CPaintManagerUI::SetSystemSettings(const TSystemSettingsUI Config)
{
m_SystemConfig = Config;
}
TSystemMetricsUI CPaintManagerUI::GetSystemMetrics() const
{
return m_SystemMetrics;
}
bool CPaintManagerUI::AddNotifier(INotifyUI* pNotifier)
{
ASSERT(m_aNotifiers.Find(pNotifier)<0);
return m_aNotifiers.Add(pNotifier);
}
bool CPaintManagerUI::RemoveNotifier(INotifyUI* pNotifier)
{
for( int i = 0; i < m_aNotifiers.GetSize(); i++ ) {
if( static_cast<INotifyUI*>(m_aNotifiers[i]) == pNotifier ) {
return m_aNotifiers.Remove(i);
}
}
return false;
}
bool CPaintManagerUI::AddMessageFilter(IMessageFilterUI* pFilter)
{
ASSERT(m_aMessageFilters.Find(pFilter)<0);
return m_aMessageFilters.Add(pFilter);
}
bool CPaintManagerUI::RemoveMessageFilter(IMessageFilterUI* pFilter)
{
for( int i = 0; i < m_aMessageFilters.GetSize(); i++ ) {
if( static_cast<IMessageFilterUI*>(m_aMessageFilters[i]) == pFilter ) {
return m_aMessageFilters.Remove(i);
}
}
return false;
}
void CPaintManagerUI::SendNotify(CControlUI* pControl, LPCTSTR pstrMessage, WPARAM wParam /*= 0*/, LPARAM lParam /*= 0*/)
{
TNotifyUI Msg;
Msg.pSender = pControl;
Msg.sType = pstrMessage;
Msg.wParam = 0;
Msg.lParam = 0;
SendNotify(Msg);
}
void CPaintManagerUI::SendNotify(TNotifyUI& Msg)
{
// Pre-fill some standard members
Msg.ptMouse = m_ptLastMousePos;
Msg.dwTimestamp = ::GetTickCount();
// Allow sender control to react
Msg.pSender->Notify(Msg);
// Send to all listeners
for( int i = 0; i < m_aNotifiers.GetSize(); i++ ) {
static_cast<INotifyUI*>(m_aNotifiers[i])->Notify(Msg);
}
}
HFONT CPaintManagerUI::GetThemeFont(UITYPE_FONT Index) const
{
if( Index <= UIFONT__FIRST || Index >= UIFONT__LAST ) return NULL;
if( m_hFonts[Index] == NULL ) m_hFonts[Index] = ::CreateFontIndirect(&m_aLogFonts[Index]);
return m_hFonts[Index];
}
HICON CPaintManagerUI::GetThemeIcon(int iIndex, int cxySize) const
{
if( m_himgIcons16 == NULL ) {
m_himgIcons16 = ImageList_LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_ICONS16), 16, 0, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
m_himgIcons24 = ImageList_LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_ICONS16), 16, 0, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
m_himgIcons32 = ImageList_LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_ICONS16), 16, 0, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
m_himgIcons50 = ImageList_LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_ICONS50), 50, 0, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
}
if( cxySize == 16 ) return ImageList_GetIcon(m_himgIcons16, iIndex, ILD_NORMAL);
else if( cxySize == 24 ) return ImageList_GetIcon(m_himgIcons24, iIndex, ILD_NORMAL);
else if( cxySize == 32 ) return ImageList_GetIcon(m_himgIcons32, iIndex, ILD_NORMAL);
else if( cxySize == 50 ) return ImageList_GetIcon(m_himgIcons50, iIndex, ILD_NORMAL);
return NULL;
}
HPEN CPaintManagerUI::GetThemePen(UITYPE_COLOR Index) const
{
if( Index <= UICOLOR__FIRST || Index >= UICOLOR__LAST ) return NULL;
if( m_hPens[Index] == NULL ) m_hPens[Index] = ::CreatePen(PS_SOLID, 1, m_clrColors[Index][0]);
return m_hPens[Index];
}
HBRUSH CPaintManagerUI::GetThemeBrush(UITYPE_COLOR Index) const
{
if( Index <= UICOLOR__FIRST || Index >= UICOLOR__LAST ) return NULL;
if( m_hBrushes[Index] == NULL ) m_hBrushes[Index] = ::CreateSolidBrush(m_clrColors[Index][0]);
return m_hBrushes[Index];
}
const TEXTMETRIC& CPaintManagerUI::GetThemeFontInfo(UITYPE_FONT Index) const
{
if( Index <= UIFONT__FIRST || Index >= UIFONT__LAST ) return m_aTextMetrics[0];
if( m_aTextMetrics[Index].tmHeight == 0 ) {
HFONT hOldFont = (HFONT) ::SelectObject(m_hDcPaint, GetThemeFont(Index));
::GetTextMetrics(m_hDcPaint, &m_aTextMetrics[Index]);
::SelectObject(m_hDcPaint, hOldFont);
}
return m_aTextMetrics[Index];
}
COLORREF CPaintManagerUI::GetThemeColor(UITYPE_COLOR Index) const
{
if( Index <= UICOLOR__FIRST || Index >= UICOLOR__LAST ) return RGB(0,0,0);
return m_clrColors[Index][0];
}
bool CPaintManagerUI::GetThemeColorPair(UITYPE_COLOR Index, COLORREF& clr1, COLORREF& clr2) const
{
if( Index <= UICOLOR__FIRST || Index >= UICOLOR__LAST ) return false;
clr1 = m_clrColors[Index][0];
clr2 = m_clrColors[Index][1];
return true;
}
CControlUI* CPaintManagerUI::FindControl(LPCTSTR pstrName)
{
ASSERT(m_pRoot);
// First time here? Build hash array...
if( m_aNameHash.GetSize() == 0 ) {
int nCount = 0;
m_pRoot->FindControl(__FindControlFromCount, &nCount, UIFIND_ALL);
m_aNameHash.Resize(nCount + (nCount / 10));
m_pRoot->FindControl(__FindControlFromNameHash, this, UIFIND_ALL);
}
// Find name in the hash array
int nCount = 0;
int nSize = m_aNameHash.GetSize();
int iNameHash = (int) (GetNameHash(pstrName) % nSize);
while( m_aNameHash[iNameHash] != NULL ) {
if( static_cast<CControlUI*>(m_aNameHash[iNameHash])->GetName() == pstrName ) return static_cast<CControlUI*>(m_aNameHash[iNameHash]);
iNameHash = (iNameHash + 1) % nSize;
if( ++nCount >= nSize ) break;
}
return NULL;
}
CControlUI* CPaintManagerUI::FindControl(POINT pt) const
{
ASSERT(m_pRoot);
return m_pRoot->FindControl(__FindControlFromPoint, &pt, UIFIND_VISIBLE | UIFIND_HITTEST);
}
CControlUI* CALLBACK CPaintManagerUI::__FindControlFromCount(CControlUI* /*pThis*/, LPVOID pData)
{
int* pnCount = static_cast<int*>(pData);
(*pnCount)++;
return NULL; // Count all controls
}
CControlUI* CALLBACK CPaintManagerUI::__FindControlFromTab(CControlUI* pThis, LPVOID pData)
{
FINDTABINFO* pInfo = static_cast<FINDTABINFO*>(pData);
if( pInfo->pFocus == pThis ) {
if( pInfo->bForward ) pInfo->bNextIsIt = true;
return pInfo->bForward ? NULL : pInfo->pLast;
}
if( (pThis->GetControlFlags() & UIFLAG_TABSTOP) == 0 ) return NULL;
pInfo->pLast = pThis;
if( pInfo->bNextIsIt ) return pThis;
if( pInfo->pFocus == NULL ) return pThis;
return NULL; // Examine all controls
}
CControlUI* CALLBACK CPaintManagerUI::__FindControlFromNameHash(CControlUI* pThis, LPVOID pData)
{
CPaintManagerUI* pManager = static_cast<CPaintManagerUI*>(pData);
// No name?
const CStdString& sName = pThis->GetName();
if( sName.IsEmpty() ) return NULL;
// Add this control to the hash list
int nCount = 0;
int nSize = pManager->m_aNameHash.GetSize();
int iNameHash = (int) (GetNameHash(sName) % nSize);
while( pManager->m_aNameHash[iNameHash] != NULL ) {
iNameHash = (iNameHash + 1) % nSize;
if( ++nCount == nSize ) return NULL;
}
pManager->m_aNameHash.SetAt(iNameHash, pThis);
return NULL; // Attempt to add all controls
}
CControlUI* CALLBACK CPaintManagerUI::__FindControlFromShortcut(CControlUI* pThis, LPVOID pData)
{
FINDSHORTCUT* pFS = static_cast<FINDSHORTCUT*>(pData);
if( pFS->ch == toupper(pThis->GetShortcut()) ) pFS->bPickNext = true;
if( _tcsstr(pThis->GetClass(), _T("Label")) != NULL ) return NULL; // Labels never get focus!
return pFS->bPickNext ? pThis : NULL;
}
CControlUI* CALLBACK CPaintManagerUI::__FindControlFromPoint(CControlUI* pThis, LPVOID pData)
{
LPPOINT pPoint = static_cast<LPPOINT>(pData);
return ::PtInRect(&pThis->GetPos(), *pPoint) ? pThis : NULL;
}
/////////////////////////////////////////////////////////////////////////////////////
//
//
CControlUI::CControlUI() :
m_pManager(NULL),
m_pParent(NULL),
m_pTag(NULL),
m_chShortcut('\0'),
m_bVisible(true),
m_bFocused(false),
m_bEnabled(true)
{
::ZeroMemory(&m_rcItem, sizeof(RECT));
}
CControlUI::~CControlUI()
{
if( m_pManager != NULL ) m_pManager->ReapObjects(this);
}
bool CControlUI::IsVisible() const
{
return m_bVisible;
}
bool CControlUI::IsEnabled() const
{
return m_bEnabled;
}
bool CControlUI::IsFocused() const
{
return m_bFocused;
}
UINT CControlUI::GetControlFlags() const
{
return 0;
}
void CControlUI::SetVisible(bool bVisible)
{
if( m_bVisible == bVisible ) return;
m_bVisible = bVisible;
if( m_pManager != NULL ) m_pManager->UpdateLayout();
}
void CControlUI::SetEnabled(bool bEnabled)
{
m_bEnabled = bEnabled;
Invalidate();
}
bool CControlUI::Activate()
{
if( !IsVisible() ) return false;
if( !IsEnabled() ) return false;
return true;
}
CControlUI* CControlUI::GetParent() const
{
return m_pParent;
}
void CControlUI::SetFocus()
{
if( m_pManager != NULL ) m_pManager->SetFocus(this);
}
void CControlUI::SetShortcut(TCHAR ch)
{
m_chShortcut = ch;
}
TCHAR CControlUI::GetShortcut() const
{
return m_chShortcut;
}
CStdString CControlUI::GetText() const
{
return m_sText;
}
void CControlUI::SetText(LPCTSTR pstrText)
{
m_sText = pstrText;
Invalidate();
}
UINT_PTR CControlUI::GetTag() const
{
return m_pTag;
}
void CControlUI::SetTag(UINT_PTR pTag)
{
m_pTag = pTag;
}
void CControlUI::SetToolTip(LPCTSTR pstrText)
{
m_sToolTip = pstrText;
}
CStdString CControlUI::GetToolTip() const
{
return m_sToolTip;
}
void CControlUI::Init()
{
}
CPaintManagerUI* CControlUI::GetManager() const
{
return m_pManager;
}
void CControlUI::SetManager(CPaintManagerUI* pManager, CControlUI* pParent)
{
bool bInit = m_pManager == NULL;
m_pManager = pManager;
m_pParent = pParent;
if( bInit ) Init();
}
CStdString CControlUI::GetName() const
{
return m_sName;
}
void CControlUI::SetName(LPCTSTR pstrName)
{
m_sName = pstrName;
}
LPVOID CControlUI::GetInterface(LPCTSTR pstrName)
{
if( _tcscmp(pstrName, _T("Control")) == 0 ) return this;
return NULL;
}
CControlUI* CControlUI::FindControl(FINDCONTROLPROC Proc, LPVOID pData, UINT uFlags)
{
if( (uFlags & UIFIND_VISIBLE) != 0 && !IsVisible() ) return NULL;
if( (uFlags & UIFIND_ENABLED) != 0 && !IsEnabled() ) return NULL;
if( (uFlags & UIFIND_HITTEST) != 0 && !::PtInRect(&m_rcItem, * static_cast<LPPOINT>(pData)) ) return NULL;
return Proc(this, pData);
}
RECT CControlUI::GetPos() const
{
return m_rcItem;
}
void CControlUI::SetPos(RECT rc)
{
m_rcItem = rc;
// NOTE: SetPos() is usually called during the WM_PAINT cycle where all controls are
// being laid out. Calling UpdateLayout() again would be wrong. Refreshing the
// window won't hurt (if we're already inside WM_PAINT we'll just validate it out).
Invalidate();
}
void CControlUI::Invalidate()
{
if( m_pManager != NULL ) m_pManager->Invalidate(m_rcItem);
}
void CControlUI::UpdateLayout()
{
if( m_pManager != NULL ) m_pManager->UpdateLayout();
}
void CControlUI::Event(TEventUI& event)
{
if( event.Type == UIEVENT_SETCURSOR )
{
::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
return;
}
if( event.Type == UIEVENT_SETFOCUS )
{
m_bFocused = true;
Invalidate();
return;
}
if( event.Type == UIEVENT_KILLFOCUS )
{
m_bFocused = false;
Invalidate();
return;
}
if( event.Type == UIEVENT_TIMER )
{
m_pManager->SendNotify(this, _T("timer"), event.wParam, event.lParam);
return;
}
if( m_pParent != NULL ) m_pParent->Event(event);
}
void CControlUI::Notify(TNotifyUI& /*msg*/)
{
}
void CControlUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
{
if( _tcscmp(pstrName, _T("pos")) == 0 ) {
RECT rcPos = { 0 };
LPTSTR pstr = NULL;
rcPos.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr);
rcPos.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);
rcPos.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);
rcPos.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);
SetPos(rcPos);
}
else if( _tcscmp(pstrName, _T("name")) == 0 ) SetName(pstrValue);
else if( _tcscmp(pstrName, _T("text")) == 0 ) SetText(pstrValue);
else if( _tcscmp(pstrName, _T("tooltip")) == 0 ) SetToolTip(pstrValue);
else if( _tcscmp(pstrName, _T("enabled")) == 0 ) SetEnabled(_tcscmp(pstrValue, _T("true")) == 0);
else if( _tcscmp(pstrName, _T("visible")) == 0 ) SetVisible(_tcscmp(pstrValue, _T("true")) == 0);
else if( _tcscmp(pstrName, _T("shortcut")) == 0 ) SetShortcut(pstrValue[0]);
}
CControlUI* CControlUI::ApplyAttributeList(LPCTSTR pstrList)
{
CStdString sItem;
CStdString sValue;
while( *pstrList != '\0' ) {
sItem.Empty();
sValue.Empty();
while( *pstrList != '\0' && *pstrList != '=' ) sItem += *pstrList++;
ASSERT(*pstrList=='=');
if( *pstrList++ != '=' ) return this;
ASSERT(*pstrList=='\"');
if( *pstrList++ != '\"' ) return this;
while( *pstrList != '\0' && *pstrList != '\"' ) sValue += *pstrList++;
ASSERT(*pstrList=='\"');
if( *pstrList++ != '\"' ) return this;
SetAttribute(sItem, sValue);
if( *pstrList++ != ',' ) return this;
}
return this;
}
| 34.432225 | 209 | 0.617396 | [
"render",
"3d"
] |
3dcf9b07c048d0b94cd18bae2acb4ba4025a1351 | 74,937 | cpp | C++ | ManagedScripts/Mda_settings.cpp | mpforums/RenSharp | 5b3fb8bff2a1772a82a4148bcf3e1265a11aa097 | [
"Apache-2.0"
] | 1 | 2021-10-04T02:36:30.000Z | 2021-10-04T02:36:30.000Z | ManagedScripts/Mda_settings.cpp | TheUnstoppable/RenSharp | 2a123c6018c18f3fc73501737d600e291ac3afa7 | [
"Apache-2.0"
] | 9 | 2019-07-03T19:19:59.000Z | 2020-03-02T22:00:21.000Z | ManagedScripts/Mda_settings.cpp | TheUnstoppable/RenSharp | 2a123c6018c18f3fc73501737d600e291ac3afa7 | [
"Apache-2.0"
] | 2 | 2019-08-14T08:37:36.000Z | 2020-09-29T06:44:26.000Z | /*
Copyright 2020 Neijwiert
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "stdafx.h"
#include "Mda_settings.h"
#include "Mengine_io.h"
#include "UnmanagedContainer.h"
#include "Imports.h"
using namespace System::Runtime::InteropServices;
using namespace System::Text;
namespace RenSharp
{
DASettingsClass::DASettingsClass()
: AbstractUnmanagedObject(IntPtr(Imports::CreateDASettingsClass1()))
{
}
DASettingsClass::DASettingsClass(String ^filename)
: AbstractUnmanagedObject()
{
if (filename == nullptr)
{
throw gcnew ArgumentNullException("filename");
}
Pointer = IntPtr(Imports::CreateDASettingsClass2(filename));
}
DASettingsClass::DASettingsClass(IINIClass ^ini)
: AbstractUnmanagedObject()
{
if (ini == nullptr || ini->Pointer.ToPointer() == nullptr)
{
throw gcnew ArgumentNullException("ini");
}
Pointer = IntPtr(Imports::CreateDASettingsClass3(reinterpret_cast<::INIClass *>(ini->INIClassPointer.ToPointer())));
}
DASettingsClass::DASettingsClass(IntPtr pointer)
: AbstractUnmanagedObject(pointer)
{
}
bool DASettingsClass::Equals(Object ^other)
{
if (AbstractUnmanagedObject::Equals(other))
{
return true;
}
IDASettingsClass ^otherThis = dynamic_cast<IDASettingsClass ^>(other);
if (otherThis == nullptr)
{
return nullptr;
}
return DASettingsClassPointer.Equals(otherThis->DASettingsClassPointer);
}
String ^DASettingsClass::ToString()
{
StringBuilder ^builder = gcnew StringBuilder();
builder->Append(Filename);
return builder->ToString();
}
IUnmanagedContainer<IDASettingsClass ^> ^DASettingsClass::CreateDASettingsClass()
{
return gcnew UnmanagedContainer<IDASettingsClass ^>(gcnew DASettingsClass());
}
IUnmanagedContainer<IDASettingsClass ^> ^DASettingsClass::CreateDASettingsClass(String ^filename)
{
return gcnew UnmanagedContainer<IDASettingsClass ^>(gcnew DASettingsClass(filename));
}
IUnmanagedContainer<IDASettingsClass ^> ^DASettingsClass::CreateDASettingsClass(IINIClass ^ini)
{
return gcnew UnmanagedContainer<IDASettingsClass ^>(gcnew DASettingsClass(ini));
}
void DASettingsClass::Reload()
{
InternalDASettingsClassPointer->Reload();
}
void DASettingsClass::ReloadSilent()
{
InternalDASettingsClassPointer->Reload_Silent();
}
int DASettingsClass::GetInt(String ^entry, int defaultValue)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Int(
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Int(
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
int DASettingsClass::GetInt(String ^section, String ^entry, int defaultValue)
{
if (section == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Int(
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Int(
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Int(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Int(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
}
int DASettingsClass::GetInt(String ^section1, String ^section2, String ^entry, int defaultValue)
{
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Int(
nullptr,
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Int(
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Int(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Int(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Int(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Int(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Int(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Int(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
}
float DASettingsClass::GetFloat(String ^entry, float defaultValue)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Float(
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Float(
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
float DASettingsClass::GetFloat(String ^section, String ^entry, float defaultValue)
{
if (section == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Float(
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Float(
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Float(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Float(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
}
float DASettingsClass::GetFloat(String ^section1, String ^section2, String ^entry, float defaultValue)
{
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Float(
nullptr,
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Float(
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Float(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Float(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Float(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Float(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Float(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Float(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
}
bool DASettingsClass::GetBool(String ^entry, bool defaultValue)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Bool(
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Bool(
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
bool DASettingsClass::GetBool(String ^section, String ^entry, bool defaultValue)
{
if (section == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Bool(
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Bool(
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Bool(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Bool(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
}
bool DASettingsClass::GetBool(String ^section1, String ^section2, String ^entry, bool defaultValue)
{
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Bool(
nullptr,
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Bool(
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Bool(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Bool(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Bool(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Bool(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return InternalDASettingsClassPointer->Get_Bool(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return InternalDASettingsClassPointer->Get_Bool(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
}
String ^DASettingsClass::GetString(String ^entry, String ^defaultValue)
{
::StringClass result;
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
return gcnew String(result.Peek_Buffer());
}
String ^DASettingsClass::GetString(String ^section, String ^entry, String ^defaultValue)
{
::StringClass result;
if (section == nullptr)
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
return gcnew String(result.Peek_Buffer());
}
String ^DASettingsClass::GetString(String ^section1, String ^section2, String ^entry, String ^defaultValue)
{
::StringClass result;
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
nullptr,
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
nullptr,
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
InternalDASettingsClassPointer->Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
return gcnew String(result.Peek_Buffer());
}
Vector3 DASettingsClass::GetVector3(String ^entry, Vector3 defaultValue)
{
::Vector3 result;
IntPtr defaultValueHandle = Marshal::AllocHGlobal(Marshal::SizeOf(Vector3::typeid));
try
{
Marshal::StructureToPtr(defaultValue, defaultValueHandle, false);
if (entry == nullptr)
{
InternalDASettingsClassPointer->Get_Vector3(
result,
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
InternalDASettingsClassPointer->Get_Vector3(
result,
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
return Marshal::PtrToStructure<Vector3>(IntPtr(&result));
}
Vector3 DASettingsClass::GetVector3(String ^section, String ^entry, Vector3 defaultValue)
{
::Vector3 result;
IntPtr defaultValueHandle = Marshal::AllocHGlobal(Marshal::SizeOf(Vector3::typeid));
try
{
Marshal::StructureToPtr(defaultValue, defaultValueHandle, false);
if (section == nullptr)
{
if (entry == nullptr)
{
InternalDASettingsClassPointer->Get_Vector3(
result,
nullptr,
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
InternalDASettingsClassPointer->Get_Vector3(
result,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
InternalDASettingsClassPointer->Get_Vector3(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
InternalDASettingsClassPointer->Get_Vector3(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
return Marshal::PtrToStructure<Vector3>(IntPtr(&result));
}
Vector3 DASettingsClass::GetVector3(String ^section1, String ^section2, String ^entry, Vector3 defaultValue)
{
::Vector3 result;
IntPtr defaultValueHandle = Marshal::AllocHGlobal(Marshal::SizeOf(Vector3::typeid));
try
{
Marshal::StructureToPtr(defaultValue, defaultValueHandle, false);
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
InternalDASettingsClassPointer->Get_Vector3(
result,
nullptr,
nullptr,
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
InternalDASettingsClassPointer->Get_Vector3(
result,
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
InternalDASettingsClassPointer->Get_Vector3(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
InternalDASettingsClassPointer->Get_Vector3(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
InternalDASettingsClassPointer->Get_Vector3(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
InternalDASettingsClassPointer->Get_Vector3(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
InternalDASettingsClassPointer->Get_Vector3(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
InternalDASettingsClassPointer->Get_Vector3(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
return Marshal::PtrToStructure<Vector3>(IntPtr(&result));
}
IINISection ^DASettingsClass::GetSection(String ^section)
{
::INISection *result;
if (section == nullptr)
{
result = InternalDASettingsClassPointer->Get_Section(nullptr);
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
result = InternalDASettingsClassPointer->Get_Section(reinterpret_cast<char *>(sectionHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
if (result == nullptr)
{
return nullptr;
}
else
{
return gcnew INISection(IntPtr(result));
}
}
IntPtr DASettingsClass::DASettingsClassPointer::get()
{
return IntPtr(InternalDASettingsClassPointer);
}
IINIClass ^DASettingsClass::INI::get()
{
auto ini = const_cast<::INIClass *>(InternalDASettingsClassPointer->Get_INI());
if (ini == nullptr)
{
return nullptr;
}
else
{
return gcnew INIClass(IntPtr(ini));
}
}
String ^DASettingsClass::Filename::get()
{
auto filename = InternalDASettingsClassPointer->Get_File_Name();
if (filename == nullptr)
{
return nullptr;
}
else
{
return gcnew String(filename);
}
}
bool DASettingsClass::InternalDestroyPointer()
{
Imports::DestroyDASettingsClass(InternalDASettingsClassPointer);
Pointer = IntPtr::Zero;
return true;
}
::DASettingsClass *DASettingsClass::InternalDASettingsClassPointer::get()
{
return reinterpret_cast<::DASettingsClass *>(Pointer.ToPointer());
}
IINISection ^DASettingsManager::GetSection(String ^section)
{
::INISection *sectionPtr;
if (section == nullptr)
{
sectionPtr = ::DASettingsManager::Get_Section(nullptr);
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
sectionPtr = ::DASettingsManager::Get_Section(reinterpret_cast<char *>(sectionHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
if (sectionPtr == nullptr)
{
return nullptr;
}
else
{
return gcnew INISection(IntPtr(sectionPtr));
}
}
void DASettingsManager::Shutdown()
{
::DASettingsManager::Shutdown();
}
void DASettingsManager::Reload()
{
::DASettingsManager::Reload();
}
void DASettingsManager::ReloadSilent()
{
::DASettingsManager::Reload_Silent();
}
void DASettingsManager::AddSettings(String ^filename)
{
if (filename == nullptr)
{
throw gcnew ArgumentNullException("filename");
}
IntPtr filenameHandle = Marshal::StringToHGlobalAnsi(filename);
try
{
::DASettingsManager::Add_Settings(reinterpret_cast<char *>(filenameHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(filenameHandle);
}
}
void DASettingsManager::RemoveSettings(String ^filename)
{
if (filename == nullptr)
{
throw gcnew ArgumentNullException("filename");
}
IntPtr filenameHandle = Marshal::StringToHGlobalAnsi(filename);
try
{
::DASettingsManager::Remove_Settings(reinterpret_cast<char *>(filenameHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(filenameHandle);
}
}
void DASettingsManager::RemoveSettings(int position)
{
if (position < 0 || position >= ::DASettingsManager::Get_Settings_Count())
{
throw gcnew ArgumentOutOfRangeException("position");
}
::DASettingsManager::Remove_Settings(position);
}
IDASettingsClass ^DASettingsManager::GetSettings(String ^filename)
{
if (filename == nullptr)
{
throw gcnew ArgumentNullException("filename");
}
// The actual DASettingsManager::Get_Settings(const char *) implementation uses literal pointer comparison on the strings
// Which is dumb and we cant really use that
IntPtr filenameHandle = Marshal::StringToHGlobalAnsi(filename);
try
{
char *filenamePtr = reinterpret_cast<char *>(filenameHandle.ToPointer());
int settingsCount = ::DASettingsManager::Get_Settings_Count();
for (int x = 0; x < settingsCount; x++)
{
auto currentSettings = const_cast<::DASettingsClass *>(::DASettingsManager::Get_Settings(x));
if (currentSettings != nullptr && !_stricmp(currentSettings->Get_File_Name(), filenamePtr))
{
return gcnew DASettingsClass(IntPtr(currentSettings));
}
}
}
finally
{
Marshal::FreeHGlobal(filenameHandle);
}
return nullptr;
}
IDASettingsClass ^DASettingsManager::GetSettings(int position)
{
if (position < 0 || position >= ::DASettingsManager::Get_Settings_Count())
{
throw gcnew ArgumentOutOfRangeException("position");
}
auto result = const_cast<::DASettingsClass *>(::DASettingsManager::Get_Settings(position));
if (result == nullptr)
{
return nullptr;
}
else
{
return gcnew DASettingsClass(IntPtr(result));
}
}
int DASettingsManager::GetInt(String ^entry, int defaultValue)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Int(
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Int(
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
int DASettingsManager::GetInt(String ^section, String ^entry, int defaultValue)
{
if (section == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Int(
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Int(
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Int(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Int(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
}
int DASettingsManager::GetInt(String ^section1, String ^section2, String ^entry, int defaultValue)
{
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Int(
nullptr,
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Int(
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Int(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Int(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Int(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Int(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Int(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Int(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
}
float DASettingsManager::GetFloat(String ^entry, float defaultValue)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Float(
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Float(
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
float DASettingsManager::GetFloat(String ^section, String ^entry, float defaultValue)
{
if (section == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Float(
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Float(
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Float(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Float(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
}
float DASettingsManager::GetFloat(String ^section1, String ^section2, String ^entry, float defaultValue)
{
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Float(
nullptr,
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Float(
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Float(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Float(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Float(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Float(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Float(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Float(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
}
bool DASettingsManager::GetBool(String ^entry, bool defaultValue)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Bool(
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Bool(
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
bool DASettingsManager::GetBool(String ^section, String ^entry, bool defaultValue)
{
if (section == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Bool(
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Bool(
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Bool(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Bool(
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
}
bool DASettingsManager::GetBool(String ^section1, String ^section2, String ^entry, bool defaultValue)
{
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Bool(
nullptr,
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Bool(
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Bool(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Bool(
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Bool(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Bool(
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
return ::DASettingsManager::Get_Bool(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
defaultValue);
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
return ::DASettingsManager::Get_Bool(
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
defaultValue);
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
}
String ^DASettingsManager::GetString(String ^entry, String ^defaultValue)
{
::StringClass result;
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
return gcnew String(result.Peek_Buffer());
}
String ^DASettingsManager::GetString(String ^section, String ^entry, String ^defaultValue)
{
::StringClass result;
if (section == nullptr)
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
nullptr,
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
nullptr,
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
return gcnew String(result.Peek_Buffer());
}
String ^DASettingsManager::GetString(String ^section1, String ^section2, String ^entry, String ^defaultValue)
{
::StringClass result;
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
nullptr,
nullptr,
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
nullptr,
nullptr,
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
if (defaultValue == nullptr)
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
nullptr);
}
else
{
IntPtr defaultValueHandle = Marshal::StringToHGlobalAnsi(defaultValue);
try
{
::DASettingsManager::Get_String(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
reinterpret_cast<char *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
return gcnew String(result.Peek_Buffer());
}
Vector3 DASettingsManager::GetVector3(String ^entry, Vector3 defaultValue)
{
::Vector3 result;
IntPtr defaultValueHandle = Marshal::AllocHGlobal(Marshal::SizeOf(Vector3::typeid));
try
{
Marshal::StructureToPtr(defaultValue, defaultValueHandle, false);
if (entry == nullptr)
{
::DASettingsManager::Get_Vector3(
result,
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
::DASettingsManager::Get_Vector3(
result,
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
return Marshal::PtrToStructure<Vector3>(IntPtr(&result));
}
Vector3 DASettingsManager::GetVector3(String ^section, String ^entry, Vector3 defaultValue)
{
::Vector3 result;
IntPtr defaultValueHandle = Marshal::AllocHGlobal(Marshal::SizeOf(Vector3::typeid));
try
{
Marshal::StructureToPtr(defaultValue, defaultValueHandle, false);
if (section == nullptr)
{
if (entry == nullptr)
{
::DASettingsManager::Get_Vector3(
result,
nullptr,
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
::DASettingsManager::Get_Vector3(
result,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr sectionHandle = Marshal::StringToHGlobalAnsi(section);
try
{
if (entry == nullptr)
{
::DASettingsManager::Get_Vector3(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
::DASettingsManager::Get_Vector3(
result,
reinterpret_cast<char *>(sectionHandle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(sectionHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
return Marshal::PtrToStructure<Vector3>(IntPtr(&result));
}
Vector3 DASettingsManager::GetVector3(String ^section1, String ^section2, String ^entry, Vector3 defaultValue)
{
::Vector3 result;
IntPtr defaultValueHandle = Marshal::AllocHGlobal(Marshal::SizeOf(Vector3::typeid));
try
{
Marshal::StructureToPtr(defaultValue, defaultValueHandle, false);
if (section1 == nullptr)
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
::DASettingsManager::Get_Vector3(
result,
nullptr,
nullptr,
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
::DASettingsManager::Get_Vector3(
result,
nullptr,
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
::DASettingsManager::Get_Vector3(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
::DASettingsManager::Get_Vector3(
result,
nullptr,
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
else
{
IntPtr section1Handle = Marshal::StringToHGlobalAnsi(section1);
try
{
if (section2 == nullptr)
{
if (entry == nullptr)
{
::DASettingsManager::Get_Vector3(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
::DASettingsManager::Get_Vector3(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
nullptr,
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
else
{
IntPtr section2Handle = Marshal::StringToHGlobalAnsi(section2);
try
{
if (entry == nullptr)
{
::DASettingsManager::Get_Vector3(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
nullptr,
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
else
{
IntPtr entryHandle = Marshal::StringToHGlobalAnsi(entry);
try
{
::DASettingsManager::Get_Vector3(
result,
reinterpret_cast<char *>(section1Handle.ToPointer()),
reinterpret_cast<char *>(section2Handle.ToPointer()),
reinterpret_cast<char *>(entryHandle.ToPointer()),
*reinterpret_cast<::Vector3 *>(defaultValueHandle.ToPointer()));
}
finally
{
Marshal::FreeHGlobal(entryHandle);
}
}
}
finally
{
Marshal::FreeHGlobal(section2Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(section1Handle);
}
}
}
finally
{
Marshal::FreeHGlobal(defaultValueHandle);
}
return Marshal::PtrToStructure<Vector3>(IntPtr(&result));
}
int DASettingsManager::SettingsCount::get()
{
return ::DASettingsManager::Get_Settings_Count();
}
} | 22.557797 | 123 | 0.604628 | [
"object"
] |
3dd21ea8a1860d686693981a423b45d917bf8eb2 | 4,420 | cpp | C++ | v_0_2/util_functions/a_star.cpp | TimoLoomets/TeamSuccessRobotex2018Taxify | 702da19a93761892174f3950924e0da07ea0c568 | [
"MIT"
] | 1 | 2018-07-03T21:17:29.000Z | 2018-07-03T21:17:29.000Z | v_0_2/util_functions/a_star.cpp | TimoLoomets/TeamSuccessRobotex2018Taxify | 702da19a93761892174f3950924e0da07ea0c568 | [
"MIT"
] | null | null | null | v_0_2/util_functions/a_star.cpp | TimoLoomets/TeamSuccessRobotex2018Taxify | 702da19a93761892174f3950924e0da07ea0c568 | [
"MIT"
] | 2 | 2018-07-03T21:17:31.000Z | 2018-07-06T15:55:21.000Z | #ifndef A_STAR_CPP
#define A_STAR_CPP
#include <bits/stdc++.h>
#include "../util_functions/util_functions.hpp"
//#include "../input_readers/graph_file_reader.cpp"
//#include "../graph_handlers/graph_depos_handler.cpp"
class a_star_instance{
public:
std::map<std::pair<double, double>, std::map<std::pair<double, double>, double> > * graph;
std::set<std::pair<double, double> > closed_set;
std::set<std::pair<double, double> > open_set;
std::map<std::pair<double, double>, std::pair<double, double> > came_from;
std::map<std::pair<double, double>, double> g_score;
std::pair<double, double> start_loc;
/*<deprecated>*/
double path_length( std::vector<std::pair<double, double> > path,
std::map<std::pair<double, double>, std::map<std::pair<double, double>, double> > * graph){
double total_length = 0;
for(unsigned int i=0; i<path.size()-1; i++){
total_length += graph->find(path[i])->second.find(path[i+1])->second;
}
return total_length;
}
/*</deprecated>*/
std::vector<std::pair<double, double> > reconstruct_path(std::pair<double, double> current){
std::vector<std::pair<double, double> > total_path = {current};
while(came_from.find(current)!=came_from.end()){
current = came_from[current];
total_path.push_back(current);
}
return total_path;
}
void set_start(std::pair<double, double> start_loc_in,
std::map<std::pair<double, double>, std::map<std::pair<double, double>, double> > * graph_i){
start_loc = start_loc_in;
graph = graph_i;
closed_set = std::set<std::pair<double, double> >();
open_set = std::set<std::pair<double, double> >();
open_set.insert(start_loc);
came_from = std::map<std::pair<double, double>, std::pair<double, double> >();
g_score = std::map<std::pair<double, double>, double>();
}
void calculate_path_to(std::pair<double, double> end_loc){
if(closed_set.find(end_loc) == closed_set.end()){
//std::cout << "\t\tcalculating path\n";
std::map<std::pair<double, double>, double> f_score;
for(std::pair<double, double> point : open_set){
f_score[point] = vincenty_distance(point, end_loc);
}
//std::cout << "\t\tstarting while\n";
while(!open_set.empty()){
//std::cout << "\t\t\tfinding min f score\n";
double min_f_score = DBL_MAX;
std::pair<double, double> current;
for(auto node : open_set){
if(f_score[node] < min_f_score){
current = node;
}
}
//std::cout << "\t\t\tcheck if end\n";
if(current == end_loc){
break;
}
//std::cout << "\t\t\tcp0\n";
if(open_set.find(current) != open_set.end()){
open_set.erase(open_set.find(current));
}
//std::cout << "\t\t\tcp1\n";
closed_set.insert(current);
//std::cout << "\t\t\tcp2\n";
//std::cout << "\t\t\tcurrent: " << current.first << " , " << current.second << "\n";
//std::cout << "\t\t\tcp666\n";
graph->find(current);
//std::cout << "\t\t\tcp777\n";
//bool is_end_check = graph->find(current) != graph->end();
//std::cout << "\t\t\tfind: " << is_end_check << "\n";
for(auto neighbor : graph->find(current)->second){
//std::cout << "\t\t\tcp3\n";
if(closed_set.find(neighbor.first) != closed_set.end()){
continue;
}
//std::cout << "\t\t\tcp4\n";
double tentative_g_score = g_score[current] + neighbor.second;
//std::cout << "\t\t\tcp5\n";
if(open_set.find(neighbor.first) == open_set.end()){
open_set.insert(neighbor.first);
}else if(tentative_g_score >= g_score[neighbor.first]){
continue;
}
//std::cout << "\t\t\tcp7\n";
came_from[neighbor.first] = current;
//std::cout << "\t\t\tcp8\n";
g_score[neighbor.first] = tentative_g_score;
//std::cout << "\t\t\tcp9\n";
f_score[neighbor.first] = g_score[neighbor.first] + vincenty_distance(neighbor.first, end_loc);
}
}
}
}
std::vector<std::pair<double, double> > get_path_to(std::pair<double, double> end_loc){
calculate_path_to(end_loc);
return reconstruct_path(end_loc);
}
double get_distance_to(std::pair<double, double> end_loc){
//std::cout << "\tcalculating distance to: " << end_loc.first << " , " << end_loc.second << "\n";
calculate_path_to(end_loc);
//std::cout << "\treturning \n";
return g_score[end_loc];
}
std::pair<double, double> get_last_to(std::pair<double, double> end_loc){
calculate_path_to(end_loc);
return came_from[end_loc];
}
};
#endif
| 35.36 | 100 | 0.63733 | [
"vector"
] |
3dd418a9d72601f10a3733d85c16bd3d0e2ce420 | 16,756 | cpp | C++ | Libraries/ManagedAnimatTools/ManagedAnimatTools/DataObjectInterface.cpp | NeuroRoboticTech/AnimatLabPublicSource | c5b23f8898513582afb7891eb994a7bd40a89f08 | [
"BSD-3-Clause"
] | 8 | 2015-01-09T21:59:50.000Z | 2021-04-14T14:08:47.000Z | Libraries/ManagedAnimatTools/ManagedAnimatTools/DataObjectInterface.cpp | NeuroRoboticTech/AnimatLabPublicSource | c5b23f8898513582afb7891eb994a7bd40a89f08 | [
"BSD-3-Clause"
] | null | null | null | Libraries/ManagedAnimatTools/ManagedAnimatTools/DataObjectInterface.cpp | NeuroRoboticTech/AnimatLabPublicSource | c5b23f8898513582afb7891eb994a7bd40a89f08 | [
"BSD-3-Clause"
] | 2 | 2018-12-21T02:58:30.000Z | 2020-08-12T11:44:39.000Z | #include "stdafx.h"
#include "Util.h"
#include "PropertyUpdateException.h"
#include "SimulatorInterface.h"
#include "SimGUICallback.h"
#include "DataObjectInterface.h"
#include "MovableItemCallback.h"
namespace AnimatGUI
{
namespace Interfaces
{
DataObjectInterface::DataObjectInterface(ManagedAnimatInterfaces::ISimulatorInterface ^SimInt, System::String ^strID)
{
try
{
AnimatGUI::Interfaces::SimulatorInterface ^RealSimInt = dynamic_cast<AnimatGUI::Interfaces::SimulatorInterface ^>(SimInt);
if(RealSimInt != nullptr)
{
m_aryDataPointers = NULL;
m_Sim = RealSimInt;
m_lpSim = RealSimInt->Sim();
std::string strSID = Util::StringToStd(strID);
m_lpBase = m_lpSim->FindByID(strSID);
m_lpMovable = dynamic_cast<MovableItem *>(m_lpBase);
m_lpRigidBody = dynamic_cast<RigidBody *>(m_lpBase);
//If this is a bodypart or struture type then lets add the callbacks to it so those
//classes can fire managed events back up to the gui.
if(m_lpMovable)
{
MovableItemCallback *lpCallback = NULL;
lpCallback = new MovableItemCallback(this);
m_lpMovable->Callback(lpCallback);
GetPointers();
}
}
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to set a data value.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew System::Exception(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to set a data value.";
throw gcnew System::Exception(strErrorMessage);
}
}
DataObjectInterface::!DataObjectInterface()
{
try
{
if(m_aryDataPointers)
{
m_aryDataPointers->RemoveAll();
delete m_aryDataPointers;
}
}
catch(...)
{
}
}
DataObjectInterface::~DataObjectInterface()
{
this->!DataObjectInterface();
}
void DataObjectInterface::GetPointers()
{
try
{
TRACE_DEBUG("Getting Dataobject position pointers.\r\n");
m_lpPositionX = m_lpBase->GetDataPointer("POSITIONX");
m_lpPositionY = m_lpBase->GetDataPointer("POSITIONY");
m_lpPositionZ = m_lpBase->GetDataPointer("POSITIONZ");
m_lpWorldPositionX = m_lpBase->GetDataPointer("WORLDPOSITIONX");
m_lpWorldPositionY = m_lpBase->GetDataPointer("WORLDPOSITIONY");
m_lpWorldPositionZ = m_lpBase->GetDataPointer("WORLDPOSITIONZ");
m_lpRotationX = m_lpBase->GetDataPointer("ROTATIONX");
m_lpRotationY = m_lpBase->GetDataPointer("ROTATIONY");
m_lpRotationZ = m_lpBase->GetDataPointer("ROTATIONZ");
TRACE_DEBUG("Got Dataobject position pointers.\r\n");
}
catch(...)
{
m_lpPositionX = NULL;
m_lpPositionY = NULL;
m_lpPositionZ = NULL;
m_lpWorldPositionX = NULL;
m_lpWorldPositionY = NULL;
m_lpWorldPositionZ = NULL;
m_lpRotationX = NULL;
m_lpRotationY = NULL;
m_lpRotationZ = NULL;
}
}
System::Boolean DataObjectInterface::SetData(System::String ^sDataType, System::String ^sValue, System::Boolean bThrowError)
{
try
{
if(m_lpBase)
{
if(m_lpSim->WaitForSimulationBlock())
{
std::string strDataType = Std_Trim(Std_ToUpper(Util::StringToStd(sDataType)));
std::string strValue = Util::StringToStd(sValue);
TRACE_DEBUG("Setting data. Object ID: " + m_lpBase->ID() + ", DataType: " + strDataType + ", Value: " + strValue + "\r\n");
bool bVal = m_lpBase->SetData(strDataType, strValue, bThrowError);
m_lpSim->UnblockSimulation();
return bVal;
}
else
return false;
}
else
return false;
}
catch(CStdErrorInfo oError)
{
if(m_lpSim) m_lpSim->UnblockSimulation();
std::string strError = "An error occurred while attempting to set a data value.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
if(m_lpSim) m_lpSim->UnblockSimulation();
System::String ^strErrorMessage = "An unknown error occurred while attempting to set a data value.";
throw gcnew System::Exception(strErrorMessage);
}
return false;
}
void DataObjectInterface::QueryProperties(System::Collections::ArrayList ^aryPropertyNames, System::Collections::ArrayList ^aryPropertyTypes, System::Collections::ArrayList ^aryDirections)
{
try
{
if(m_lpBase)
{
CStdPtrArray<TypeProperty> aryProperties;
m_lpBase->QueryProperties(aryProperties);
aryPropertyNames->Clear();
aryPropertyTypes->Clear();
aryDirections->Clear();
int iCount = aryProperties.GetSize();
for(int iIdx=0; iIdx<iCount; iIdx++)
{
System::String^ sName = gcnew System::String(aryProperties[iIdx]->m_strName.c_str());
System::String^ sType = gcnew System::String(aryProperties[iIdx]->TypeName().c_str());
System::String^ sDirection = gcnew System::String(aryProperties[iIdx]->DirectionName().c_str());
aryPropertyNames->Add(sName);
aryPropertyTypes->Add(sType);
aryDirections->Add(sDirection);
}
}
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to QueryProperties.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to QueryProperties.";
throw gcnew System::Exception(strErrorMessage);
}
}
void DataObjectInterface::SelectItem(bool bVal, bool bSelectMultiple)
{
try
{
if(m_lpBase && m_lpSim->WaitForSimulationBlock())
{
TRACE_DEBUG("Selecting Item. Object ID: " + m_lpBase->ID() + ", Val: " + STR(bVal) + ", Select Multiple: " + STR(bSelectMultiple) + "\r\n");
if(m_lpBase && ((bool) bVal) != m_lpBase->Selected())
m_lpBase->Selected( (bool) bVal, (bool) bSelectMultiple);
m_lpSim->UnblockSimulation();
}
}
catch(CStdErrorInfo oError)
{
if(m_lpSim) m_lpSim->UnblockSimulation();
std::string strError = "An error occurred while attempting to select an item.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
if(m_lpSim) m_lpSim->UnblockSimulation();
System::String ^strErrorMessage = "An unknown error occurred while attempting to select an item.";
throw gcnew System::Exception(strErrorMessage);
}
}
void DataObjectInterface::GetDataPointer(System::String ^sData)
{
try
{
if(m_lpBase)
{
std::string strData = Util::StringToStd(sData);
TRACE_DEBUG("Getting Data pointer Item. Object ID: " + m_lpBase->ID() + ", Data: " + strData+ "\r\n");
float *lpData = m_lpBase->GetDataPointer(strData);
if(!lpData)
throw gcnew System::Exception("The data pointer is not defined!");
if(!m_aryDataPointers)
m_aryDataPointers = new CStdMap<std::string, float *>;
if(FindDataPointer(strData, false) == NULL)
m_aryDataPointers->Add(Std_CheckString(strData), lpData);
}
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to get a data pointer.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to get a data pointer.";
throw gcnew System::Exception(strErrorMessage);
}
}
float *DataObjectInterface::FindDataPointer(std::string strData, bool bThrowError)
{
float *lpData = NULL;
if(m_aryDataPointers)
{
CStdMap<std::string, float *>::iterator oPos;
TRACE_DEBUG("FindDataPointer. Object ID: " + m_lpBase->ID() + ", Data: " + strData+ "\r\n");
oPos = m_aryDataPointers->find(Std_CheckString(strData));
if(oPos != m_aryDataPointers->end())
lpData = oPos->second;
//else if(bThrowError)
// THROW_TEXT_ERROR(Al_Err_lDataTypeNotFound, Al_Err_strDataTypeNotFound, " Data Type: " + strData);
}
return lpData;
}
float DataObjectInterface::GetDataValue(System::String ^sData)
{
if(!m_lpBase)
throw gcnew System::Exception("The base object has not been defined!");
if(!m_aryDataPointers)
throw gcnew System::Exception("The data pointers array has not been defined!");
try
{
std::string strData = Util::StringToStd(sData);
float *lpData = NULL;
TRACE_DEBUG("GetDataValue. Object ID: " + m_lpBase->ID() + ", Data: " + strData + "\r\n");
CStdMap<std::string, float *>::iterator oPos;
oPos = m_aryDataPointers->find(Std_CheckString(strData));
if(oPos != m_aryDataPointers->end())
lpData = oPos->second;
else
throw gcnew System::Exception("The data pointer has not been defined: " + sData);
if(!lpData)
throw gcnew System::Exception("The data pointer is not defined: " + sData);
return *lpData;
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to get a data value.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to get a data value.";
throw gcnew System::Exception(strErrorMessage);
}
}
float DataObjectInterface::GetDataValueImmediate(System::String ^sData)
{
if(!m_lpBase)
throw gcnew System::Exception("The base object has not been defined!");
try
{
std::string strData = Util::StringToStd(sData);
float *lpData = m_lpBase->GetDataPointer(strData);
if(!lpData)
throw gcnew System::Exception("The data pointer is not defined!");
return *lpData;
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to get a data value.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to get a data value.";
throw gcnew System::Exception(strErrorMessage);
}
}
float DataObjectInterface::GetBoundingBoxValue(int iIndex)
{
try
{
if(m_lpMovable && m_lpSim)
{
BoundingBox bb = m_lpMovable->GetBoundingBox();
float fltDist = m_lpSim->DistanceUnits();
if(iIndex == 0 && m_lpRotationX)
return (bb.Length()*fltDist);
else if(iIndex == 1 && m_lpRotationY)
return (bb.Height()*fltDist);
else if(iIndex == 2 && m_lpRotationZ)
return (bb.Width()*fltDist);
else
return 0;
}
else
return 0;
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to call GetBoundingBoxValue.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to call GetBoundingBoxValue.";
throw gcnew System::Exception(strErrorMessage);
}
}
void DataObjectInterface::OrientNewPart(double dblXPos, double dblYPos, double dblZPos, double dblXNorm, double dblYNorm, double dblZNorm)
{
try
{
if(m_lpMovable)
m_lpMovable->OrientNewPart(dblXPos, dblYPos, dblZPos, dblXNorm, dblYNorm, dblZNorm);
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to OrientNewPart.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to OrientNewPart.";
throw gcnew System::Exception(strErrorMessage);
}
}
System::Boolean DataObjectInterface::CalculateLocalPosForWorldPos(double dblXWorldX, double dblWorldY, double dblWorldZ, System::Collections::ArrayList ^aryLocalPos)
{
try
{
if(m_lpMovable)
{
CStdFPoint vPos;
if(m_lpMovable->CalculateLocalPosForWorldPos(dblXWorldX, dblWorldY, dblWorldZ, vPos))
{
aryLocalPos->Clear();
aryLocalPos->Add(vPos.x);
aryLocalPos->Add(vPos.y);
aryLocalPos->Add(vPos.z);
return true;
}
}
return false;
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to CalculateLocalPosForWorldPos.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to CalculateLocalPosForWorldPos.";
throw gcnew System::Exception(strErrorMessage);
}
}
void DataObjectInterface::EnableCollisions(System::String ^sOtherBodyID)
{
try
{
if(m_lpBase)
{
std::string strOtherBodyID = Util::StringToStd(sOtherBodyID);
TRACE_DEBUG("EnableCollisions. Body1 ID: " + m_lpBase->ID() + ", Body2: " + strOtherBodyID + "\r\n");
if(!m_lpRigidBody)
throw gcnew System::Exception("Base object is not a rigid body.");
RigidBody *lpOtherBody = dynamic_cast<RigidBody *>(m_lpSim->FindByID(strOtherBodyID));
if(!lpOtherBody)
throw gcnew System::Exception("Other object is not a rigid body.");
m_lpRigidBody->EnableCollision(lpOtherBody);
}
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to add a collision exclusion pair.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to add a collision exclusion pair.";
throw gcnew System::Exception(strErrorMessage);
}
}
void DataObjectInterface::DisableCollisions(System::String ^sOtherBodyID)
{
try
{
if(m_lpBase)
{
std::string strOtherBodyID = Util::StringToStd(sOtherBodyID);
TRACE_DEBUG("DisableCollisions. Body1 ID: " + m_lpBase->ID() + ", Body2: " + strOtherBodyID + "\r\n");
if(!m_lpRigidBody)
throw gcnew System::Exception("Base object is not a rigid body.");
RigidBody *lpOtherBody = dynamic_cast<RigidBody *>(m_lpSim->FindByID(strOtherBodyID));
if(!lpOtherBody)
throw gcnew System::Exception("Other object is not a rigid body.");
m_lpRigidBody->DisableCollision(lpOtherBody);
}
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to remove a collision exclusion pair.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to remove a collision exclusion pair.";
throw gcnew System::Exception(strErrorMessage);
}
}
System::String ^DataObjectInterface::GetLocalTransformMatrixString()
{
try
{
if(m_lpMovable)
{
std::string strMatrix = m_lpMovable->LocalTransformationMatrixString();
return gcnew System::String(strMatrix.c_str());
}
return gcnew System::String("");
}
catch(CStdErrorInfo oError)
{
std::string strError = "An error occurred while attempting to CalculateLocalPosForWorldPos.\nError: " + oError.m_strError;
System::String ^strErrorMessage = gcnew System::String(strError.c_str());
throw gcnew PropertyUpdateException(strErrorMessage);
}
catch(System::Exception ^ex)
{throw ex;}
catch(...)
{
System::String ^strErrorMessage = "An unknown error occurred while attempting to CalculateLocalPosForWorldPos.";
throw gcnew System::Exception(strErrorMessage);
}
}
}
} | 30.245487 | 189 | 0.698556 | [
"object"
] |
3dd7a14ac75cfe41870611d3b7342ecaca7b71e8 | 11,682 | cpp | C++ | source/glannotations/source/Renderer/QuadStrip.cpp | dgimb89/glannotations | df687dbae1906cdb08c7b10cb006c025c4ba6406 | [
"MIT"
] | null | null | null | source/glannotations/source/Renderer/QuadStrip.cpp | dgimb89/glannotations | df687dbae1906cdb08c7b10cb006c025c4ba6406 | [
"MIT"
] | null | null | null | source/glannotations/source/Renderer/QuadStrip.cpp | dgimb89/glannotations | df687dbae1906cdb08c7b10cb006c025c4ba6406 | [
"MIT"
] | null | null | null | #include <glannotations/Renderer/QuadStrip.h>
#include "../ShaderSources.hpp"
#include <glbinding/gl/functions.h>
#include <glbinding/gl/enum.h>
#include <globjects/VertexAttributeBinding.h>
#include <algorithm>
static const char* vertShader = R"(
#version 330
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 texCoord;
layout (location = 2) in vec2 texAdvance;
layout (location = 3) in vec3 advanceH;
layout (location = 4) in vec3 advanceW;
out QuadData {
vec2 texCoord;
vec2 texAdvance;
vec3 advanceH;
vec3 advanceW;
} quad;
void main()
{
quad.texCoord = texCoord;
quad.advanceH = advanceH;
quad.advanceW = advanceW;
quad.texAdvance = texAdvance;
gl_Position = vec4(position, 1.0);
}
)";
static const char* geomShader = R"(
#version 330
uniform bool onNearplane;
### MATRIX_BLOCK ###
layout(points) in;
layout(triangle_strip, max_vertices = 4) out;
in QuadData {
vec2 texCoord;
vec2 texAdvance;
vec3 advanceH;
vec3 advanceW;
} quad[];
out vec2 v_uv;
void setVertexData(in float upper, in float right, out vec4 position, out vec2 texCoord) {
position = vec4(gl_in[0].gl_Position.xyz + upper * quad[0].advanceH + right * quad[0].advanceW, 1.0);
texCoord = quad[0].texCoord + vec2(right * quad[0].texAdvance.x, upper * quad[0].texAdvance.y);
}
void main() {
mat4 viewProjection = (1.0 - float(onNearplane)) * (projectionMatrix * viewMatrix) + float(onNearplane) * mat4(1);
// ll
setVertexData(0.0, 0.0, gl_Position, v_uv);
gl_Position = viewProjection * gl_Position;
EmitVertex();
// lr
setVertexData(0.0, 1.0, gl_Position, v_uv);
gl_Position = viewProjection * gl_Position;
EmitVertex();
// ul
setVertexData(1.0, 0.0, gl_Position, v_uv);
gl_Position = viewProjection * gl_Position;
EmitVertex();
// ur
setVertexData(1.0, 1.0, gl_Position, v_uv);
gl_Position = viewProjection * gl_Position;
EmitVertex();
EndPrimitive();
}
)";
static const char* dfFragShader = R"(
#version 330
uniform sampler2D source;
uniform int style;
uniform vec4 color;
uniform vec3 outlineColor;
uniform float outlineSize;
uniform float bumpIntensity;
layout (location = 0) out vec4 fragColor;
in vec2 v_uv;
float aastep(float t, float value) {
//float afwidth = length(vec2(dFdx(value), dFdy(value))) * 1.0;
float afwidth = fwidth(value);
return smoothstep(t - afwidth, t + afwidth, value);
}
float tex(float t, vec2 uv) {
return aastep(t, texture(source, uv).r);
}
float aastep3(float t, vec2 uv) {
vec2 dfdy = dFdy(uv);
vec2 y = dfdy * 1.0 / 3.0;
float v = tex(t, uv - y) ;
v = tex(t, uv ) + v;
v = tex(t, uv + y) + v;
return v / 3.0;
}
float aastep8(float t, vec2 uv) {
vec2 dfdx = dFdx(uv);
vec2 dfdy = dFdy(uv);
vec2 x1 = dfdx * 1.0 / 8.0;
vec2 y1 = dfdy * 1.0 / 8.0;
vec2 y2 = dfdy * 3.0 / 8.0;
float v = tex(t, uv - x1 - y2) ;
v = tex(t, uv - x1 - y1) + v;
v = tex(t, uv - x1 + y1) + v;
v = tex(t, uv - x1 + y2) + v;
v = tex(t, uv + x1 - y2) + v;
v = tex(t, uv + x1 - y1) + v;
v = tex(t, uv + x1 + y1) + v;
v = tex(t, uv + x1 + y2) + v;
return v / 8.0;
}
float aastep12(float t, vec2 uv) {
vec2 dfdx = dFdx(uv);
vec2 dfdy = dFdy(uv);
vec2 x1 = dfdx * 1.0 / 12.0;
vec2 y1 = dfdy * 1.0 / 12.0;
vec2 y2 = dfdy * 3.0 / 12.0;
vec2 y3 = dfdy * 5.0 / 12.0;
float v = tex(t, uv - x1 - y3) ;
v = tex(t, uv - x1 - y2) + v;
v = tex(t, uv - x1 - y1) + v;
v = tex(t, uv - x1 + y1) + v;
v = tex(t, uv - x1 + y2) + v;
v = tex(t, uv - x1 + y3) + v;
v = tex(t, uv + x1 - y3) + v;
v = tex(t, uv + x1 - y2) + v;
v = tex(t, uv + x1 - y1) + v;
v = tex(t, uv + x1 + y1) + v;
v = tex(t, uv + x1 + y2) + v;
v = tex(t, uv + x1 + y3) + v;
return v / 12.0;
}
float aastep3x3(float t, vec2 uv) {
vec2 dfdx = dFdx(uv);
vec2 dfdy = dFdy(uv);
vec2 x = dfdx * 1.0 / 3.0;
vec2 y = dfdy * 1.0 / 3.0;
float v = tex(t, uv - x - y) ;
v = tex(t, uv - x ) + v;
v = tex(t, uv - x + y) + v;
v = tex(t, uv - y) + v;
v = tex(t, uv ) + v;
v = tex(t, uv + y) + v;
v = tex(t, uv + x - y) + v;
v = tex(t, uv + x ) + v;
v = tex(t, uv + x + y) + v;
return v / 9.0;
}
float aastep4x4s(float t, vec2 uv) {
vec2 dfdx = dFdx(uv);
vec2 dfdy = dFdy(uv);
vec2 x1 = dfdx * 1.0 / 8.0;
vec2 y1 = dfdy * 1.0 / 8.0;
vec2 x2 = dfdx * 3.0 / 8.0;
vec2 y2 = dfdy * 3.0 / 8.0;
float v = tex(t, uv - x2 - y2) ;
v = tex(t, uv - x2 - y1) + v;
v = tex(t, uv - x2 + y1) + v;
v = tex(t, uv - x2 + y2) + v;
v = tex(t, uv - x1 - y2) + v;
v = tex(t, uv - x1 - y1) + v;
v = tex(t, uv - x1 + y1) + v;
v = tex(t, uv - x1 + y2) + v;
v = tex(t, uv + x1 - y2) + v;
v = tex(t, uv + x1 - y1) + v;
v = tex(t, uv + x1 + y1) + v;
v = tex(t, uv + x1 + y2) + v;
v = tex(t, uv + x2 - y2) + v;
v = tex(t, uv + x2 - y1) + v;
v = tex(t, uv + x2 + y1) + v;
v = tex(t, uv + x2 + y2) + v;
return v / 16.0;
}
vec4 subpix(float r, float g, float b, vec4 fore, vec4 back) {
return vec4(mix(back.rgb, fore.rgb, vec3(r, g, b)), mix(back.a, fore.a, (r + b + g) / 3.0));
}
void main() {
float s = texture(source, v_uv).r;
if(s - outlineSize > 0.55)
discard;
vec4 fc = (style * vec4(outlineColor.rgb, 1.0)) + ((1 - style) * vec4(color.rgb, 0.0));
vec4 bc = color;
float threshold = 0.55 - outlineSize;
// subpixel variations
float r, g, b;
vec2 dfdx = dFdx(v_uv);
vec2 dfdy = dFdy(v_uv);
vec2 uvr = v_uv;
vec2 uvg = v_uv + dfdx * 1.0 / 3.0;
vec2 uvb = v_uv + dfdx * 2.0 / 3.0;
if(true)
//if(x > 0.002) // optional: only use if glyph is small (todo: adjust threshold)
{ // higher quality - more samples
r = aastep12(threshold, uvr);
g = aastep12(threshold, uvg);
b = aastep12(threshold, uvb);
}
else
{ // lower quality - less samples
r = aastep3(threshold, uvr);
g = aastep3(threshold, uvg);
b = aastep3(threshold, uvb);
}
fragColor = subpix(r, g, b, fc, bc);
}
)";
static const char* texturingFragShader = R"(
#version 330
uniform sampler2D source;
layout (location = 0) out vec4 fragColor;
in vec2 v_uv;
void main() {
fragColor = texture(source, v_uv);
if(fragColor.a < 0.001) discard;
}
)";
glannotations::QuadStrip::QuadStrip(std::shared_ptr<globjects::Texture> texture, gl::GLuint matricesBindingIndex, bool isDistanceField) : glannotations::AbstractTexturedPrimitive(texture) {
if (isDistanceField) {
setupShader(vertShader, geomShader, dfFragShader);
} else {
setupShader(vertShader, geomShader, texturingFragShader);
}
setBindingIndex(matricesBindingIndex);
// initial position
m_ll = m_lr = m_ur = glm::vec3(0.0f, 0.0f, 0.0f);
m_vertexCount = 0;
m_advanceH = new globjects::Buffer;
m_advanceW = new globjects::Buffer;
m_texAdvance = new globjects::Buffer;
m_vao->binding(0)->setAttribute(0);
m_vao->binding(0)->setFormat(3, gl::GL_FLOAT, gl::GL_FALSE, 0);
m_vao->enable(0);
}
void glannotations::QuadStrip::addQuad(texVec2_t texture_ll, texVec2_t texture_advance) {
m_textureRanges.push_back(std::make_pair(texture_ll, texture_advance));
}
void glannotations::QuadStrip::clearQuads() {
m_textureRanges.clear();
}
void glannotations::QuadStrip::draw() {
if (m_texture) {
gl::glActiveTexture(gl::GL_TEXTURE0);
m_texture->bind();
}
m_program->use();
directDrawCall();
m_program->release();
if (m_texture) {
m_texture->unbind();
}
}
glm::vec2 glannotations::QuadStrip::getExtends() const {
glm::vec2 texAdvance(0.f, m_textureRanges.front().second.y * static_cast<float>(getQuadstripRowCount()));
for (auto textureCoords : m_textureRanges) {
texAdvance.x += textureCoords.second.x;
}
return texAdvance;
}
void glannotations::QuadStrip::updateQuadRanges() {
// update texture VBO
std::vector<texVec2_t> textures, texAdvances;
for (auto textureCoords : m_textureRanges) {
// calculate full texture width for later usage
textures.push_back(textureCoords.first);
texAdvances.push_back(textureCoords.second);
}
// update vertices VBO
std::vector<glm::vec3> vertexVector;
std::vector<glm::vec3> vertAdvanceW, vertAdvanceH;
glm::vec3 widthSpan = m_lr - m_ll;
widthSpan /= getExtends().x; // normalize
glm::vec3 heightSpan = m_ur - m_lr;
glm::vec3 currentLL = m_ll;
for (auto textureCoords : m_textureRanges) {
// we can calculate necessary width for current quad from texture widths because the scaling is done uniformly
vertexVector.push_back(currentLL);
auto currentWidthSpan = widthSpan;
currentWidthSpan *= textureCoords.second.x;
vertAdvanceW.push_back(currentWidthSpan);
vertAdvanceH.push_back(heightSpan);
currentLL += currentWidthSpan;
}
m_positions->setData(vertexVector, gl::GL_STATIC_DRAW);
m_vao->binding(0)->setAttribute(0);
m_vao->binding(0)->setFormat(3, gl::GL_FLOAT, gl::GL_FALSE, 0);
m_vao->binding(0)->setBuffer(m_positions, 0, sizeof(glm::vec3));
m_vao->enable(0);
m_vertexCount = vertexVector.size();
m_texCoords->setData(textures, gl::GL_STATIC_DRAW);
m_vao->binding(1)->setAttribute(1);
m_vao->binding(1)->setFormat(2, gl::GL_FLOAT, gl::GL_FALSE, 0);
m_vao->binding(1)->setBuffer(m_texCoords, 0, sizeof(texVec2_t));
m_vao->enable(1);
m_texAdvance->setData(texAdvances, gl::GL_STATIC_DRAW);
m_vao->binding(2)->setAttribute(2);
m_vao->binding(2)->setFormat(2, gl::GL_FLOAT, gl::GL_FALSE, 0);
m_vao->binding(2)->setBuffer(m_texAdvance, 0, sizeof(texVec2_t));
m_vao->enable(2);
m_advanceH->setData(vertAdvanceH, gl::GL_STATIC_DRAW);
m_vao->binding(3)->setAttribute(3);
m_vao->binding(3)->setFormat(3, gl::GL_FLOAT, gl::GL_FALSE, 0);
m_vao->binding(3)->setBuffer(m_advanceH, 0, sizeof(glm::vec3));
m_vao->enable(3);
m_advanceW->setData(vertAdvanceW, gl::GL_STATIC_DRAW);
m_vao->binding(4)->setAttribute(4);
m_vao->binding(4)->setFormat(3, gl::GL_FLOAT, gl::GL_FALSE, 0);
m_vao->binding(4)->setBuffer(m_advanceW, 0, sizeof(glm::vec3));
m_vao->enable(4);
}
bool glannotations::QuadStrip::setPosition(glm::vec3 ll, glm::vec3 lr, glm::vec3 ur) {
if (positionValid(ll, lr, ur)) {
m_ll = ll;
m_lr = lr;
m_ur = ur;
updateQuadRanges();
// finalize geom shader for internal rendering
m_program->setUniform("onNearplane", false);
return true;
}
return false;
}
bool glannotations::QuadStrip::setViewportPosition(glm::vec2 ll, glm::vec2 lr, glm::vec2 ur) {
if (setPosition(glm::vec3(ll, 0.f), glm::vec3(lr, 0.f), glm::vec3(ur, 0.f))) {
// finalize geom shader for viewport rendering
m_program->setUniform("onNearplane", true);
return true;
}
return false;
}
float glannotations::QuadStrip::getUniformQuadHeight() {
return m_textureRanges.front().second.y; // returning random texture advance y
}
size_t glannotations::QuadStrip::getQuadstripRowCount() const {
// TODO: support multiple rows
return 1u;
}
float glannotations::QuadStrip::getQuadStripHeight() {
return static_cast<float>(getQuadstripRowCount()) * getUniformQuadHeight();
}
float glannotations::QuadStrip::getQuadStripWidth() {
// TODO: adapt when multiple row support is added
float resultWidth = 0.f;
std::for_each(m_textureRanges.begin(), m_textureRanges.end(), [&](textureRange_t elem){ resultWidth += elem.second.x; });
return resultWidth;
}
bool glannotations::QuadStrip::positionValid( const glm::vec3& ll, const glm::vec3& lr, const glm::vec3& ur ) const {
return ll != lr && ll != ur && lr != ur;
}
| 26.855172 | 189 | 0.627461 | [
"vector"
] |
3ddac8128712a49572ae50be5c8f8fb488f8d4ce | 6,436 | cpp | C++ | src/icebox/icebox_cmd/main.cpp | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | 1 | 2021-05-22T16:50:12.000Z | 2021-05-22T16:50:12.000Z | src/icebox/icebox_cmd/main.cpp | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | null | null | null | src/icebox/icebox_cmd/main.cpp | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | null | null | null | #define FDP_MODULE "main"
#include <icebox/core.hpp>
#include <icebox/log.hpp>
#include <icebox/plugins/syscalls.hpp>
#include <icebox/utils/path.hpp>
#include <icebox/utils/pe.hpp>
#include <chrono>
#include <string>
#include <thread>
namespace
{
template <typename T>
void test_tracer(core::Core& core, proc_t target)
{
T syscall_plugin(core, target);
LOG(INFO, "Everything is set up ! Please trigger some syscalls");
const auto n = 100;
for(size_t i = 0; i < n; ++i)
state::exec(core);
syscall_plugin.generate("output.json");
}
void test_wait_and_trace(core::Core& core, const std::string& proc_target)
{
LOG(INFO, "searching for 32 bits %s process", proc_target.data());
const auto target = process::wait(core, proc_target, flags::x86);
if(!target)
return;
const auto ok = symbols::load_module(core, *target, "wntdll");
if(!ok)
return;
process::join(core, *target, mode_e::user);
plugins::Syscalls32 syscalls(core, *target);
LOG(INFO, "Every thing is ready ! Please trigger some syscalls");
for(size_t i = 0; i < 3000; ++i)
{
state::exec(core);
if(i % 200 == 0)
LOG(INFO, "%zd", i);
}
syscalls.generate("output.json");
}
bool test_core(core::Core& core)
{
LOG(INFO, "drivers:");
drivers::list(core, [&](driver_t drv)
{
const auto name = drivers::name(core, drv);
const auto span = drivers::span(core, drv);
const auto filename = name ? path::filename(*name).generic_string() : "_";
LOG(INFO, " driver: 0x%" PRIx64 " %s 0x%" PRIx64 " 0x%" PRIx64, drv.id, filename.data(), span ? span->addr : 0, span ? span->size : 0);
return walk_e::next;
});
const auto pc = process::current(core);
LOG(INFO, "current process: 0x%" PRIx64 " kdtb: 0x%" PRIx64 " udtb: 0x%" PRIx64 " %s", pc->id, pc->kdtb.val, pc->udtb.val, process::name(core, *pc)->data());
const auto tc = threads::current(core);
LOG(INFO, "current thread: 0x%" PRIx64, tc->id);
LOG(INFO, "processes:");
process::list(core, [&](proc_t proc)
{
const auto procname = process::name(core, proc);
LOG(INFO, "proc: 0x%" PRIx64 " %s", proc.id, procname ? procname->data() : "<noname>");
return walk_e::next;
});
const char proc_target[] = "notepad.exe";
LOG(INFO, "searching for %s", proc_target);
const auto target = process::wait(core, proc_target, {});
if(!target)
return false;
LOG(INFO, "%s: 0x%" PRIx64 " kdtb: 0x%" PRIx64 " ukdtb: 0x%" PRIx64 " %s", proc_target, target->id, target->kdtb.val, target->udtb.val, process::name(core, *target)->data());
process::join(core, *target, mode_e::kernel);
process::join(core, *target, mode_e::user);
const auto is_32bit = process::flags(core, *target).is_x86;
symbols::load_modules(core, *target);
threads::list(core, *target, [&](thread_t thread)
{
const auto rip = threads::program_counter(core, *target, thread);
if(!rip)
return walk_e::next;
const auto name = symbols::string(core, *target, *rip);
LOG(INFO, "thread: 0x%" PRIx64 " 0x%" PRIx64 "%s", thread.id, *rip, name.data());
return walk_e::next;
});
// check breakpoints
{
const auto ptr = symbols::address(core, symbols::kernel, "nt", "SwapContext");
const auto bp = state::break_on(core, "SwapContext", *ptr, [&]
{
const auto rip = registers::read(core, reg_e::rip);
if(!rip)
return;
const auto proc = process::current(core);
const auto pid = process::pid(core, *proc);
const auto thread = threads::current(core);
const auto tid = threads::tid(core, *proc, *thread);
const auto procname = proc ? process::name(core, *proc) : std::nullopt;
const auto symbol = symbols::string(core, *proc, rip);
LOG(INFO, "BREAK! rip: 0x%" PRIx64 " %s %s pid:%" PRId64 " tid:%" PRId64,
rip, symbol.data(), procname ? procname->data() : "", pid, tid);
});
for(size_t i = 0; i < 16; ++i)
state::exec(core);
}
// test callstack
{
const auto pdb_name = "ntdll";
const auto func_name = "RtlAllocateHeap";
const auto func_addr = symbols::address(core, *target, pdb_name, func_name);
LOG(INFO, "%s = 0x%" PRIx64, func_name, func_addr ? *func_addr : 0);
auto callers = std::vector<callstacks::caller_t>(128);
const auto bp = state::break_on_process(core, func_name, *target, *func_addr, [&]
{
const auto n = callstacks::read(core, &callers[0], callers.size(), *target);
for(size_t i = 0; i < n; ++i)
{
const auto addr = callers[i].addr;
const auto symbol = symbols::string(core, *target, addr);
LOG(INFO, "%-2zd - %s", i, symbol.data());
}
LOG(INFO, " ");
});
for(size_t i = 0; i < 3; ++i)
state::exec(core);
}
// test syscall plugin
{
if(is_32bit)
test_tracer<plugins::Syscalls32>(core, *target);
else
test_tracer<plugins::Syscalls>(core, *target);
}
{
if(false)
test_wait_and_trace(core, "notepad.exe");
}
return true;
}
}
int main(int argc, char* argv[])
{
logg::init(argc, argv);
if(argc != 2)
return FAIL(-1, "usage: icebox <name>");
const auto name = std::string{argv[1]};
LOG(INFO, "starting on %s", name.data());
const auto core = core::attach(name);
if(!core)
return FAIL(-1, "unable to start core at %s", name.data());
// core.state.resume();
state::pause(*core);
const auto valid = test_core(*core);
state::resume(*core);
return !valid;
}
| 34.978261 | 182 | 0.524705 | [
"vector"
] |
3ddf2846ce44f8862159f15663fb2ddcbe7508d0 | 17,749 | cpp | C++ | src/Trikin_Astar/reference/PCTrajNode.cpp | GaoLon/trikin_astar | b935dfe111f540c031232998de1ecad632a54246 | [
"MIT"
] | null | null | null | src/Trikin_Astar/reference/PCTrajNode.cpp | GaoLon/trikin_astar | b935dfe111f540c031232998de1ecad632a54246 | [
"MIT"
] | null | null | null | src/Trikin_Astar/reference/PCTrajNode.cpp | GaoLon/trikin_astar | b935dfe111f540c031232998de1ecad632a54246 | [
"MIT"
] | null | null | null | #include "PCTrajNode.h"
extern pcl::KdTreeFLANN<pcl::PointXYZI> kdtree;
param_restrain PCTrajNode::PR;
pcl::PointCloud<pcl::PointXYZI>::Ptr PCTrajNode::PCMap(new pcl::PointCloud<pcl::PointXYZI>);
PCTrajNode::PCTrajNode(const Matrix4d& Tr, double _kap) :T(MatrixXd::Identity(4, 4)), \
tau(0.0), kappa(_kap), t(VectorXd::Zero(5))
{
//pcl::StopWatch time;
/*pcl::KdTreeFLANN<pcl::PointXYZI> kd;
pcl::PointXYZI searchPoint;
searchPoint.x = Tr.col(3)[0];
searchPoint.y = Tr.col(3)[1];
searchPoint.z = Tr.col(3)[2];
std::vector<int> Idx_res;
std::vector<float> Dist_res;
kdtree.radiusSearch(searchPoint, 1.5, Idx_res, Dist_res);
pcl::PointCloud<pcl::PointXYZI>::Ptr kdmap(new pcl::PointCloud<pcl::PointXYZI>);
kdmap->is_dense = false;
kdmap->points.resize(Idx_res.size());
for (size_t i = 0; i < kdmap->points.size(); ++i)
{
kdmap->points[i] = PCTrajNode::PCMap->points[Idx_res[i]];
}
kd.setInputCloud(kdmap);*/
if (fp(Tr, PCMap, kdtree))
{
tau = ft(PCMap, kdtree);
}
else
{
tau = 0;
}
//cout << "terrain assessment consume:" << time.getTime() << "ms" << std::endl;
}
PCTrajNode::PCTrajNode(const Matrix4d& Tr, bool simple) :T(Tr), \
tau(0.0), kappa(0.0), t(VectorXd::Zero(5))
{
if (!simple)
{
if (fp(Tr, PCMap, kdtree))
{
tau = ft(PCMap, kdtree);
//vis
// this->pubProjectedPose();
}
else
{
tau = 0;
}
}
}
void PCTrajNode::ter_assess(void)
{
if (fp(T, PCMap, kdtree))
tau = ft(PCMap, kdtree);
else
tau = 0;
}
bool PCTrajNode::fp(const Matrix4d& Tr, pcl::PointCloud<pcl::PointXYZI>::Ptr kdmap, pcl::KdTreeFLANN<pcl::PointXYZI> kd, int K)
{
// Initilization
Matrix<double, 3, 1> X = Tr.col(0).head(3);
Matrix<double, 3, 1> Y = Tr.col(1).head(3);
Matrix<double, 3, 1> Z = Tr.col(2).head(3);
Vector3d t = Tr.col(3).head(3);
// get Z-axis Z_t
/// get convariance matrix with KNN
std::vector<int> pointIdxNKNSearch(K);
std::vector<float> pointNKNSquaredDistance(K);
pcl::PointXYZI searchPoint;
searchPoint.x = t[0];
searchPoint.y = t[1];
searchPoint.z = t[2];
Matrix<double, 3, 1> mean_p = Vector3d::Zero();
//get the nearest k neighbors of searchPoint
kd.nearestKSearch(searchPoint, K, pointIdxNKNSearch, pointNKNSquaredDistance);
/*for (size_t i = 0; i < pointIdxNKNSearch.size(); ++i)
{
mean_p += Vector3d(PCTrajNode::PCMap->points[pointIdxNKNSearch[i]].x, \
PCTrajNode::PCMap->points[pointIdxNKNSearch[i]].y, PCTrajNode::PCMap->points[pointIdxNKNSearch[i]].z);
}*/
for (size_t i = 0; i < pointIdxNKNSearch.size(); ++i)
{
mean_p += Vector3d(kdmap->points[pointIdxNKNSearch[i]].x, \
kdmap->points[pointIdxNKNSearch[i]].y, kdmap->points[pointIdxNKNSearch[i]].z);
}
mean_p /= pointIdxNKNSearch.size();
Matrix3d cov = Matrix3d::Zero();
/*for (int i = 0; i < pointIdxNKNSearch.size(); i++)
{
Matrix<double, 3, 1> v = Matrix<double, 3, 1>(kdmap->points[pointIdxNKNSearch[i]].x, \
kdmap->points[pointIdxNKNSearch[i]].y, \
kdmap->points[pointIdxNKNSearch[i]].z) - mean_p;
cov += v * v.transpose();
}*/
for (int i = 0; i < pointIdxNKNSearch.size(); i++)
{
Matrix<double, 3, 1> v = Matrix<double, 3, 1>(kdmap->points[pointIdxNKNSearch[i]].x, \
kdmap->points[pointIdxNKNSearch[i]].y, \
kdmap->points[pointIdxNKNSearch[i]].z) - mean_p;
cov += v * v.transpose();
}
/// opposite PCA
EigenSolver<Matrix3d> es(cov);
Matrix<double, 3, 1> D = es.pseudoEigenvalueMatrix().diagonal();// 特征值
Matrix3d V = es.pseudoEigenvectors(); // 特征向量
MatrixXd::Index evalsMax;
D.minCoeff(&evalsMax);
Matrix<double, 3, 1> Z_t = V.col(evalsMax);
if (Z.dot(Z_t) < 0)
{
Z_t = -Z_t;
}
// get T
/// get rotation matrix
Matrix<double, 3, 1> X_a = Y.cross(Z_t);
Matrix<double, 3, 1> X_t = X_a / X_a.norm();
Matrix3d R = Matrix3d::Zero();
R.col(0) = X_t;
R.col(1) = Z_t.cross(X_t);
R.col(2) = Z_t;
///get translate
Vector3d t_t = t + Z_t.dot(mean_p - t) / Z.dot(Z_t)*Z;
/// get final T
T.topLeftCorner(3,3) = R;
T.topRightCorner(3, 1) = Matrix<double, 3, 1>(t_t);
return (t_t - mean_p).norm() < 0.5;
//cout << T << endl;
}
double PCTrajNode::ft(pcl::PointCloud<pcl::PointXYZI>::Ptr kdmap, pcl::KdTreeFLANN<pcl::PointXYZI> kd)
{
// get pitch and roll
Matrix3d t33 = T.topLeftCorner(3, 3);
/*Eigen::Quaternion<double> q(t33);
auto euler = q.toRotationMatrix().eulerAngles(0, 1, 2);
double pitch = euler[1];
double roll = euler[2];
Vector3d ea = t33.eulerAngles(2, 0, 1);
*/
//TODO
double roll = atan2(t33.row(2)[1], hypot(t33.row(1)[1], t33.row(0)[1]));
double pitch = atan2(t33.row(2)[0], hypot(t33.row(1)[0], t33.row(0)[0]));
double pimin = pitch / PR.pitch_min;
double pimax = pitch / PR.pitch_max;
if (pitch<PR.pitch_min || pitch>PR.pitch_max || fabs(roll) > PR.roll_max)
{
// cout << pitch << " " << roll << endl;
return 0;
}
// get rho_cub( see as ball )
/// get box
vector<double> rho;
/*pcl::PointCloud<pcl::PointXYZI>::Ptr box{ new pcl::PointCloud<pcl::PointXYZI> };
pcl::CropBox<pcl::PointXYZI> clipper;
Matrix<double, 4, 1> leftdown(0, 0, -PR.d_rob[2], 1);
Matrix<double, 4, 1> minp = T * leftdown;
Vector4f min_point(minp.col(0)[0], minp.col(0)[1], minp.col(0)[2], minp.col(0)[3]);
Matrix<double, 4, 1> mp = T * PR.d_rob;
Vector4f max_point(mp.col(0)[0], mp.col(0)[1], mp.col(0)[2], mp.col(0)[3]);
clipper.setMin(min_point);
clipper.setMax(max_point);
clipper.setInputCloud(kdmap);
clipper.setNegative(false);
clipper.filter(*box);*/
Matrix<double, 4, 1> cent(PR.d_rob[0]/2, 0, 0, 1);
Matrix<double, 4, 1> mp = T * cent;
pcl::PointXYZI p;
p.x = mp.col(0)[0];
p.y = mp.col(0)[1];
p.z = mp.col(0)[2];
std::vector<int> pointIdxRadiusSearch;
std::vector<float> pointRadiusSquaredDistance;
kd.radiusSearch(p, PR.d_rob[0] / 2.0 * 1.7320508075, pointIdxRadiusSearch, pointRadiusSquaredDistance);
/// get rhos
for (size_t i = 0; i < pointIdxRadiusSearch.size(); ++i)
{
//pcl::StopWatch ti;
pair<bool,double> temp = get_rho(kdmap->points[pointIdxRadiusSearch[i]],kdmap, kd);
//cout << "rho time consume: " << ti.getTime() << "ms" << std::endl;
if (temp.second > PR.rho_max)
{
if (temp.first)
return 0;
else
temp.second = PR.rho_max;
}
rho.push_back(temp.second);
}
double rho_cub = 0;
if (!rho.empty())
{
rho_cub = accumulate(rho.begin(), rho.end(), 0.0);
rho_cub /= (double)rho.size();
}
return 1 - PR.w_rho*rho_cub / PR.rho_max + PR.w_roll*fabs(roll) / PR.roll_max + PR.w_pitch*(pimin > pimax ? pimin : pimax);
}
VectorXd PCTrajNode::get_connect(const PCTrajNode& fromNode, const PCTrajNode& toNode)
{
// through OBVP
VectorXd result = VectorXd::Zero(5);
// get boundary value
double kappa0 =fromNode.kappa;
MatrixXd T_b = fromNode.T.inverse()*toNode.T;
double xf = T_b.row(0)[3];
double yf = T_b.row(1)[3];
if (T_b.row(0)[3] < 0)
{
//cout << "xf is nagetive!" << endl;
return result;
}
double thetaf = atan2(T_b.row(1)[0], T_b.row(0)[0]);
if (fabs(thetaf) > 1)
{
//cout << "delta theta is too high!" << endl;
return result;
}
double kappaf = toNode.kappa;
// close-formed solution
double T1 = xf;
double T2 = T1*T1;
double T3 = T2*T1;
double T4 = T3*T1;
double T5 = T4*T1;
result[0] = kappa0;
result[3] = 10*(kappaf*T2-6*thetaf*T1+12*yf)/T5;
result[2] = -6*(30*yf-14*T1*thetaf-T2*kappa0+2*T2*kappaf)/T4;
result[1] = 3*(20*yf-8*T1*thetaf-2*T2*kappa0+T2*kappaf)/T3;
result[4] = T1;
return result;
// through cubic curvature
// VectorXd result = VectorXd::Zero(5);
// // get boundary value
// double x0 = 0.0;
// double y0 = 0.0;
// double theta0 = 0.0;
// double kappa0 = fromNode.kappa;
// Vector4d init(x0, y0, theta0, kappa0);
// MatrixXd T_b = fromNode.T.inverse()*toNode.T;
// double xf = T_b.row(0)[3];
// double yf = T_b.row(1)[3];
// if (T_b.row(0)[3] < 0)
// {
// //cout << "xf is nagetive!" << endl;
// return result;
// }
// double thetaf = atan2(T_b.row(1)[0], T_b.row(0)[0]);
// if (fabs(thetaf) > 1)
// {
// //cout << "delta theta is too high!" << endl;
// return result;
// }
// double kappaf = toNode.kappa;
// Vector4d ends(xf, yf, thetaf, kappaf);
// //cout << "end=" << ends << endl;
// result[0] = kappa0;
// result.tail(4) = get_cubic_curvature(init, ends);
// if (result.tail(4) == Vector4d::Zero())
// {
// //cout << "cubic curvature failed!" << endl;
// return VectorXd::Zero(5);
// }
// return result;
}
VectorXd PCTrajNode::connect(const PCTrajNode& toNode)
{
t = get_connect(*this, toNode);
return t;
}
vector<PCTrajNode> PCTrajNode::SRT_Generate(const PCTrajNode& fromNode, const PCTrajNode& toNode, double d1)
{
// through cubic curvature
// // initilization
// vector<PCTrajNode> result;
// double x0 = 0.0;
// double y0 = 0.0;
// double theta0 = 0.0;
// double kappa0 = fromNode.kappa;
// Vector4d init(x0, y0, theta0, kappa0);
// MatrixXd T_b = fromNode.T.inverse()*toNode.T;
// double xf = T_b.row(0)[3];
// double yf = T_b.row(1)[3];
// if (T_b.row(0)[3] < 0)
// {
// return result;
// }
// double thetaf = atan2(T_b.row(1)[0], T_b.row(0)[0]);
// if (fabs(thetaf) > 1)
// {
// return result;
// }
// double kappaf = toNode.kappa;
// Vector4d ends(xf, yf, thetaf, kappaf);
// double dsg = hypot(xf, yf);
// if (dsg >= d1)
// {
// return result;
// }
// //cout << "get_cubic_curvature" << endl;
// Vector4d srt = get_cubic_curvature(init, ends);
// if (srt == Vector4d::Zero())
// {
// result.clear();
// return result;
// }
// Vector4d x(srt);
// for (double seg = 0.0; seg < srt[3]; seg+=PR.d_nom)
// {
// x[3] = seg;
// Vector4d path_seg = forward(init, x);
// Matrix4d T_seg = Matrix4d::Identity();
// T_seg.row(0)[0] = T_seg.row(1)[1] = cos(path_seg[2]);
// T_seg.row(0)[1] = -sin(path_seg[2]);
// T_seg.row(1)[0] = sin(path_seg[2]);
// /*if (T_b.row(0)[3] < 0)
// {
// T_seg.row(0)[3] = -path_seg[0];
// T_seg.row(1)[3] = -path_seg[1];
// }
// else
// {*/
// T_seg.row(0)[3] = path_seg[0];
// T_seg.row(1)[3] = path_seg[1];
// //}
// PCTrajNode temp(fromNode.T*T_seg, path_seg[3]);
// if (temp.isTraversable())
// {
// result.push_back(temp);
// }
// else
// {
// result.clear();
// return result;
// }
// }
// result.push_back(toNode);
// through OBVP
// initilization
vector<PCTrajNode> result;
double kappa0 = fromNode.kappa;
MatrixXd T_b = fromNode.T.inverse()*toNode.T;
double xf = T_b.row(0)[3];
double yf = T_b.row(1)[3];
if (T_b.row(0)[3] < 0||fabs(yf/xf)>1)
{
return result;
}
double thetaf = atan2(T_b.row(1)[0], T_b.row(0)[0]);
if (fabs(thetaf) > 1)
{
return result;
}
double kappaf = toNode.kappa;
double dsg = hypot(xf, yf);
if (dsg >= d1)
{
return result;
}
// close-formed solution
double T1 = xf;
double T2 = T1*T1;
double T3 = T2*T1;
double T4 = T3*T1;
double T5 = T4*T1;
Vector4d srt;
srt[2] = 10*(kappaf*T2-6*thetaf*T1+12*yf)/T5;
srt[1] = -6*(30*yf-14*T1*thetaf-T2*kappa0+2*T2*kappaf)/T4;
srt[0] = 3*(20*yf-8*T1*thetaf-2*T2*kappa0+T2*kappaf)/T3;
srt[3] = T1;
if (srt == Vector4d::Zero())
{
result.clear();
return result;
}
// check curvature constraint
double x0, x1,max_kappa=0;
int r = gsl_poly_solve_quadratic(srt[2]*3, srt[1]*2, srt[0],&x0,&x1 );
switch (r)
{
case 0: break;
case 1:
if (x0>0 && x0<srt[3])
{
for (int j = 3; j >=0; j--)
{
max_kappa *= x0;
max_kappa += srt[j];
}
max_kappa = fabs(max_kappa);
}
break;
case 2:
if (x0>0 && x0<srt[3])
{
for (int j = 3; j >=0; j--)
{
max_kappa *= x0;
max_kappa += srt[j];
}
}
if (x1>0 && x1<srt[3])
{
double kap=0;
for (int j = 3; j >=0; j--)
{
kap *= x1;
kap += srt[j];
}
max_kappa = max(fabs(max_kappa), fabs(kap));
}
break;
default: max_kappa = 10; cout<<"gsl error!"<<endl;break;
}
if (max_kappa>PCTrajNode::PR.kappa_max)
{
result.clear();
return result;
}
// forward and cast
Vector4d x(srt);
for (double seg = 0.0; seg < srt[3]; seg+=PR.d_nom)
{
x[3] = seg;
Vector4d path_seg;// = forward(init, x);
double seg2 = seg*seg;
double seg3 = seg*seg2;
double seg4 = seg*seg3;
double seg5 = seg*seg4;
path_seg[0] = seg;
path_seg[1] = kappa0*seg2/2+ srt[0]*seg3/6+srt[1]*seg4/12+srt[2]*seg5/20;
path_seg[2] = kappa0*seg+ srt[0]*seg2/2+srt[1]*seg3/3+srt[2]*seg4/4;
path_seg[3] = kappa0 + srt[0]*seg+srt[1]*seg2+srt[2]*seg3;
Matrix4d T_seg = Matrix4d::Identity();
T_seg.row(0)[0] = T_seg.row(1)[1] = cos(path_seg[2]);
T_seg.row(0)[1] = -sin(path_seg[2]);
T_seg.row(1)[0] = sin(path_seg[2]);
T_seg.row(0)[3] = path_seg[0];
T_seg.row(1)[3] = path_seg[1];
PCTrajNode temp(fromNode.T*T_seg, path_seg[3]);
if (temp.isTraversable())
{
result.push_back(temp);
}
else
{
result.clear();
return result;
}
}
result.push_back(toNode);
// connect and check whether kappa is valid
bool kap_ok = true;
for (size_t i = 0; i < result.size() - 1; i++)
{
VectorXd pol = result[i].connect(result[i + 1]);
if (pol == VectorXd::Zero(5))
{
result.clear();
return result;
}
double x0, x1,max_kappa=0;
int r = gsl_poly_solve_quadratic(pol[3]*3, pol[2]*2,pol[1],&x0,&x1 );
switch (r)
{
case 0: break;
case 1:
if (x0>0 && x0<pol[4])
{
for (int j = 3; j >=0; j--)
{
max_kappa *= x0;
max_kappa += pol[j];
}
max_kappa = fabs(max_kappa);
}
break;
case 2:
if (x0>0 && x0<pol[4])
{
for (int j = 3; j >=0; j--)
{
max_kappa *= x0;
max_kappa += pol[j];
}
}
if (x1>0 && x1<pol[4])
{
double kap=0;
for (int j = 3; j >=0; j--)
{
kap *= x1;
kap += pol[j];
}
max_kappa = max(fabs(max_kappa), fabs(kap));
}
break;
default: max_kappa = 10; cout<<"gsl error!"<<endl;break;
}
if (max_kappa>PCTrajNode::PR.kappa_max)
{
result.clear();
return result;
}
// for (double dist = 0.0; dist < pol[4]; dist += 0.01)
// {
// double kap = 0;
// for (int j = 3; j >=0; j--)
// {
// kap *= dist;
// kap += pol[j];
// }
// if (fabs(kap) > PR.kappa_max)
// {
// //cout << "kappa = " << kap << " to high!" << endl;
// kap_ok = false;
// break;
// }
// }
// if (!kap_ok)
// {
// result.clear();
// return result;
// }
}
// cout<<"xf="<<T1<<endl;
// cout<<"yf="<<yf<<endl;
return result;
}
pair<bool, double> PCTrajNode::get_rho(pcl::PointXYZI& p, pcl::PointCloud<pcl::PointXYZI>::Ptr kdmap, pcl::KdTreeFLANN<pcl::PointXYZI> kd)
{
if (p.intensity != -1)
{
if (p.intensity < 0)
return { true,-p.intensity };
else
return { false,p.intensity };
}
// get near nodes
std::vector<int> pointIdxRadiusSearch;
std::vector<float> pointRadiusSquaredDistance;
kd.radiusSearch(p, PR.r_plane, pointIdxRadiusSearch, pointRadiusSquaredDistance);
Matrix<double, 3, 1> mean_p = Vector3d::Zero();
for (size_t i = 0; i < pointIdxRadiusSearch.size(); ++i)
{
mean_p += Vector3d(kdmap->points[pointIdxRadiusSearch[i]].x, \
kdmap->points[pointIdxRadiusSearch[i]].y, kdmap->points[pointIdxRadiusSearch[i]].z);
}
mean_p /= pointIdxRadiusSearch.size();
// get normal
Matrix3d cov = Matrix3d::Zero();
for (int i = 0; i < pointIdxRadiusSearch.size(); i++)
{
Matrix<double, 3, 1> v = Matrix<double, 3, 1>(kdmap->points[pointIdxRadiusSearch[i]].x, \
kdmap->points[pointIdxRadiusSearch[i]].y, \
kdmap->points[pointIdxRadiusSearch[i]].z) - mean_p;
cov += v * v.transpose();
}
/// opposite PCA
EigenSolver<Matrix3d> es(cov);
Matrix<double, 3, 1> D = es.pseudoEigenvalueMatrix().diagonal();// 特征值
Matrix3d V = es.pseudoEigenvectors(); // 特征向量
MatrixXd::Index evalsMax;
D.minCoeff(&evalsMax);
Matrix<double, 3, 1> n = V.col(evalsMax);
// get rho
std::vector<int> Idx_res;
std::vector<float> Dist_res;
kd.radiusSearch(p, PR.r_res, Idx_res, Dist_res);
vector<double> nears;
for (auto& i : Idx_res)
{
Matrix<double, 3, 1> pi = { kdmap->points[i].x, \
kdmap->points[i].y, \
kdmap->points[i].z };
nears.push_back(n.transpose().dot(pi - mean_p));
}
sort(nears.begin(), nears.end());
size_t a = static_cast<double>(nears.size()*PR.eta / 2.0);
double pd = n.transpose().dot(Matrix<double, 3, 1>{p.x, p.y, p.z} -mean_p);
double d_min = nears[a];
double d_max = nears[nears.size() - 1 - a];
pair<bool, double> result{ false,fabs(d_max - d_min) };
if (d_max <= pd || pd <= d_min)
{
result.first = true;
p.intensity = -result.second;
}
else
{
p.intensity = result.second;
}
return result;
}
void pubProjectedPose(ros::Publisher *pubPtr, PCTrajNode node)
{
geometry_msgs::PoseStamped msg;
msg.header.frame_id="/map";
msg.header.stamp=ros::Time::now();
Vector3d point=node.T.block<3,1>(0,3);
msg.pose.position.x=point(0);
msg.pose.position.y=point(1);
msg.pose.position.z=point(2);
tf::Matrix3x3 R;
for(int i=0; i<3; i++)
{
for (int j=0; j<3; j++)
{
R[i][j]=node.T(i,j);
}
}
tfScalar yaw, pitch,row;
R.getEulerYPR(yaw, pitch, row);
msg.pose.orientation=tf::createQuaternionMsgFromRollPitchYaw(row, pitch, yaw);
pubPtr->publish(msg);
}
| 26.139912 | 139 | 0.585047 | [
"vector"
] |
3de725e195266d9d91a2aef5f3386274b1a66de3 | 386 | cpp | C++ | week02/src/vector_example.cpp | msu-csc232-sp22/lectures | 8066358b93f74ea0cb22068f19a4bea5e7b0dadb | [
"MIT"
] | 7 | 2022-01-18T20:46:57.000Z | 2022-03-02T18:30:39.000Z | week02/src/vector_example.cpp | msu-csc232-sp22/lectures | 8066358b93f74ea0cb22068f19a4bea5e7b0dadb | [
"MIT"
] | null | null | null | week02/src/vector_example.cpp | msu-csc232-sp22/lectures | 8066358b93f74ea0cb22068f19a4bea5e7b0dadb | [
"MIT"
] | 5 | 2022-01-19T00:42:08.000Z | 2022-03-09T18:43:19.000Z | #include <cstdlib>
#include <iostream>
#include <vector>
using std::cout;
using std::endl;
using std::vector;
int main()
{
vector<int> squares( 100 );
for ( int i = 0; i < squares.size( ); ++i )
{
squares[ i ] = i * i;
}
for (int i = 0; i < squares.size( ); ++i )
{
cout << i << " " << squares[ i ] << endl;
}
return EXIT_SUCCESS;
}
| 15.44 | 49 | 0.5 | [
"vector"
] |
3dea4593b6982d3c9f9063059b354d6e2829ea2e | 229 | hpp | C++ | src/nmea-sender/ConfigParser.hpp | open-simulation-platform/sensors-and-senders | 72acf3f5494a14e9eeda684d834ec6944b0e7e0d | [
"MIT"
] | 4 | 2021-04-16T07:28:16.000Z | 2022-03-12T23:00:46.000Z | src/nmea-sender/ConfigParser.hpp | open-simulation-platform/sensors-and-senders | 72acf3f5494a14e9eeda684d834ec6944b0e7e0d | [
"MIT"
] | null | null | null | src/nmea-sender/ConfigParser.hpp | open-simulation-platform/sensors-and-senders | 72acf3f5494a14e9eeda684d834ec6944b0e7e0d | [
"MIT"
] | 2 | 2020-08-05T17:10:55.000Z | 2021-06-03T21:18:32.000Z | #pragma once
#include <vector>
#include "NmeaTelegram.hpp"
struct NmeaConfig {
std::string remoteIp;
int remotePort;
std::vector<Nmea::Telegram> telegrams;
};
NmeaConfig parse_nmea_config(const std::string& path);
| 17.615385 | 54 | 0.724891 | [
"vector"
] |
3df490eb37bdd1dcd4c14b5c693f35ee3dce2395 | 14,874 | cpp | C++ | src/duna.cpp | emepetres/dunaWatchdog | 314e2b96089a23d79a04c0c8d34f65b5199f02e9 | [
"MIT"
] | null | null | null | src/duna.cpp | emepetres/dunaWatchdog | 314e2b96089a23d79a04c0c8d34f65b5199f02e9 | [
"MIT"
] | null | null | null | src/duna.cpp | emepetres/dunaWatchdog | 314e2b96089a23d79a04c0c8d34f65b5199f02e9 | [
"MIT"
] | null | null | null | /*******************************************************************************
The MIT License (MIT)
Copyright (c) 2016 Javier Carnero
This file is part of DunaWatchdog.
Permission is hereby granted, free of charge, to any person obtaining a copy
of DunaWatchdog and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*******************************************************************************/
#include <vector>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#include <iostream>
#include <fstream>
#include "tinyxml2.h"
#include "mail_sender.h"
using namespace std;
using namespace tinyxml2;
#define DTTMFMT "%Y-%m-%d %H:%M:%S "
#define DTTMSZ 21
static char *getDtTm(char *buff) {
time_t t = time(0);
strftime(buff, DTTMSZ, DTTMFMT, localtime(&t));
return buff;
}
char buff[DTTMSZ];
#define toLog(msg) { cout << getDtTm (buff) << msg << endl; log << getDtTm (buff) << msg << endl; }
bool verbose;
bool no_exe;
bool no_recovery;
bool no_mail;
fstream log;
struct _app_t {
const char * name;
const char * exe;
char * shell_exe;
const char * working_directory;
string pid;
float max_mem;
bool screen_log;
vector<const char *> alarm_mails;
int fail_tries;
int success_tries;
};
typedef struct _app_t app_t;
string exec(char* cmd) {
FILE* pipe = popen(cmd, "r");
if (!pipe)
return "ERROR";
char buffer[128];
std::string result = "";
while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
pclose(pipe);
return result;
}
const char* toString(int n) {
stringstream ss;
ss << n;
return ss.str().c_str();
}
int toInt(const char * s) {
stringstream strValue;
strValue << s;
int intValue;
strValue >> intValue;
return intValue;
}
float toFloat(const char * s) {
stringstream strValue;
strValue << s;
float floatValue;
strValue >> floatValue;
return floatValue;
}
const char * formatInteger(const char * s) {
return toString(toInt(s));
}
void formatPath(string & str) {
for (int i = 1;
str[str.length() - i] == '\n' || str[str.length() - i] == '\r'; ++i)
str[str.length() - i] = '\0';
}
bool executeApp(app_t& app) {
if (verbose)
toLog("Ejecutando app " << app.name << "...")
char kill_screens[1024] = "for session in $(screen -ls | grep -o '[0-9]*\\.";
strcat(kill_screens, app.name);
strcat(kill_screens, "'); do screen -S \"${session}\" -X quit; done");
system(kill_screens);
chdir(app.working_directory);
if (verbose)
toLog("--> Directorio de trabajo: " << app.working_directory);
char screen[1024] = "screen -dmS";
if (app.screen_log)
strcat(screen, "L ");
else
strcat(screen, " ");
strcat(screen, app.name);
strcat(screen, " ");
strcat(screen, app.exe);
if (verbose)
toLog("--> Comando screen: " << screen)
system(screen);
char screen_ls[1024] = "screen -ls | grep ";
strcat(screen_ls, app.name);
strcat(screen_ls, " | awk -F\".\" '{print $1}' | awk -F\"\\t\" '{print $2}'");
if (verbose)
toLog("--> Comando screen pid: " << screen_ls)
string screen_pid_str = exec(screen_ls);
formatPath(screen_pid_str);
if (verbose)
toLog("--> Screen pid: " << screen_pid_str)
if (screen_pid_str.length() == 0) {
toLog(
"ERROR: no se pudo obtener el pid del screen al intentar ejecutar la aplicación " << app.name);
return false;
}
char ps[1024] = "ps --ppid ";
strcat(ps, screen_pid_str.c_str());
strcat(ps, " -o pid=");
if (verbose)
toLog("--> Comando app pid: " << ps)
string app_pid_str = exec(ps);
formatPath(app_pid_str);
app.pid.assign(app_pid_str);
if (app.pid[0] == '\0') {
usleep(500000);
app_pid_str = exec(ps);
formatPath(app_pid_str);
app.pid.assign(app_pid_str);
if (app.pid.length() == 0) {
toLog(
"ERROR: no se pudo obtener el pid de la aplicación al intentar ejecutarla (" << app.name << ").")
return false;
}
}
if (verbose) {
toLog("--> App pid: " << app.pid)
toLog("...app ejecutada.")
}
return true;
}
void subsec(const char AString[], char Substring[], int start, int length) {
int b;
for (b = start; b <= length; ++b) {
Substring[b] = AString[b];
}
Substring[b] = '\0';
}
bool isAppRunning(app_t app) {
if (verbose)
toLog("Comprobando ejecución app " << app.name << "...")
char ps[1024] = "ps -p ";
strcat(ps, app.pid.c_str());
strcat(ps, " -o command=");
if (verbose)
toLog("--> Obtener el comando asociado al pid: " << ps)
string cmd_str = exec(ps);
formatPath(cmd_str);
if (verbose) {
toLog(
"\t--> app.exe-> " << app.exe << " ==? " << cmd_str << " <-comando asociado o\n\t\t\t--> app.shell_exe-> " << app.shell_exe << " ==? " << cmd_str << " <-comando asociado")
string res;
if (strcmp(app.exe, cmd_str.c_str()) == 0
|| strcmp(app.shell_exe, cmd_str.c_str()) == 0)
res = "EN EJECUCIÓN";
else
res = "PARADA";
toLog("...resultado de la comprobación: " << res)
}
return strcmp(app.exe, cmd_str.c_str()) == 0
|| strcmp(app.shell_exe, cmd_str.c_str()) == 0;
}
bool isMemLow(app_t app) {
if (app.max_mem == 0)
return true;
if (verbose)
toLog("Comprobando memoria app " << app.name << "...")
char ps[1024] = "ps -p ";
strcat(ps, app.pid.c_str());
strcat(ps, " -o pmem=");
if (verbose)
toLog("--> Obtener la memoria asociada al pid: " << ps)
string mem_str = exec(ps);
formatPath(mem_str);
float mem = toFloat(mem_str.c_str());
if (verbose) {
toLog("--> mem-> " << mem << " <? " << app.max_mem << " <-max mem")
string res;
if (mem < app.max_mem)
res = "POR DEBAJO DEL LIMITE";
else
res = "POR ENCIMA DEL LIMITE";
toLog("...resultado de la comprobación: " << res)
}
return mem < app.max_mem;
}
int main(int argc, char *argv[]) {
verbose = false;
no_exe = false;
no_recovery = false;
no_mail = false;
//leemos parametros de entrada
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--verbose") == 0) {
verbose = true;
} else if (strcmp(argv[i], "--no_exe") == 0) {
no_exe = true;
no_recovery = true;
} else if (strcmp(argv[i], "--no_recovery") == 0) {
no_recovery = true;
} else if (strcmp(argv[i], "--no_mail") == 0) {
no_mail = true;
} else {
toLog("ERROR: Argumento " << argv[i] << " no válido.")
toLog(
"USO: ./dunaWatchdog [--verbose] [--no_exe] [--no_recovery] [--no_mail]")
return 1;
}
}
//cambiamos el directorio de trabajo al nuestro
char buffer[1024];
int len = readlink("/proc/self/exe", buffer, 1024);
if (len != -1) {
buffer[len] = '\0';
} else {
cout
<< "ERROR leyendo el directorio de trabajo del ejecutable dunaWatchdog."
<< endl;
return -1;
}
string full_path_str(buffer);
unsigned found = full_path_str.find_last_of("/\\");
string full_path = full_path_str.substr(0, found);
if (verbose)
toLog("Directorio de trabajo: " << full_path.c_str())
chdir(full_path.c_str());
//backup del archivo de log anterior
system("mv dunaWatchdog.log dunaWatchdog.log.backup");
//creamos el nuevo archivo de log
log.open("dunaWatchdog.log", fstream::out | fstream::app);
char muttrc_path[1024];
muttrc_path[0] = '\0';
strcat(muttrc_path, full_path.c_str());
strcat(muttrc_path, "/etc/muttrc");
if (verbose)
toLog("Archivo muttrc: " << muttrc_path)
MailSender sender(muttrc_path);
char xml_path[1024];
xml_path[0] = '\0';
strcat(xml_path, full_path.c_str());
strcat(xml_path, "/etc/duna.xml");
if (verbose)
toLog("Archivo xml: " << xml_path)
toLog("Iniciando DunaWatchdog...");
///////////////////////////
//leemos la configuración
///////////////////////////
XMLDocument doc;
doc.LoadFile(xml_path);
if (!doc.RootElement()) {
char error_str[2048];
error_str[0] = '\0';
strcat(error_str,
"ERROR: No se ha encontrado el archivo de configuración ");
strcat(error_str, xml_path);
toLog(error_str)
return 1;
}
toLog("Leyendo configuracion...")
vector<app_t> apps;
int check_timeout_uS = toInt(
doc.FirstChildElement("check_timeout_s")->GetText()) * 1000000;
int retries_to_warn = toInt(
doc.FirstChildElement("retries_to_warn")->GetText());
int warn_reminder = toInt(doc.FirstChildElement("warn_reminder")->GetText());
int recover_hysteresis = toInt(
doc.FirstChildElement("recover_hysteresis")->GetText());
XMLElement * app_element = doc.FirstChildElement("app");
while (app_element) {
app_t app;
app.name = app_element->FirstChildElement("name")->GetText();
toLog(app.name)
app.exe = app_element->FirstChildElement("exe")->GetText();
app.shell_exe = new char[1024];
strcpy(app.shell_exe, "/bin/sh ");
strcat(app.shell_exe, app.exe);
toLog(app.exe)
app.working_directory = app_element->FirstChildElement("working_directory")
->GetText();
toLog(app.working_directory)
if (app_element->FirstChildElement("max_mem_percentage")) {
app.max_mem = toFloat(
app_element->FirstChildElement("max_mem_percentage")->GetText());
if (app.max_mem <= 0 || app.max_mem > 100) {
toLog("ERROR: Porcentage máximo de memoria incorrecto.")
return 1;
}
} else
app.max_mem = 0;
app.screen_log = (bool) toInt(
app_element->FirstChildElement("screen_log")->GetText());
if (app.screen_log) {
toLog("Log de screen activado en directorio de trabajo.");
} else
toLog("Log de screen no activado.");
if (app_element->FirstChildElement("alarm")) {
XMLElement * mail_element = app_element->FirstChildElement("alarm")
->FirstChildElement("mail");
while (mail_element) {
app.alarm_mails.push_back(mail_element->GetText());
toLog(mail_element->GetText())
mail_element = mail_element->NextSiblingElement("mail");
}
}
apps.push_back(app);
app_element = app_element->NextSiblingElement("app");
toLog("---------------------");
}
if (apps.size() == 0) {
toLog("No se pudo leer ninguna aplicación en la configuración.")
return 0;
} else {
toLog("...OK.")
}
toLog("DunaWatchdog Iniciado.")
/////////////////////////////
//ejecutamos cada aplicacion en su screen correspondiente
/////////////////////////////
for (uint i = 0; i < apps.size(); ++i) {
if (!no_exe)
executeApp(apps[i]);
apps[i].fail_tries = 0;
apps[i].success_tries = recover_hysteresis;
}
/////////////////////////////
//monitorizamos
/////////////////////////////
while (true) {
usleep(check_timeout_uS);
bool failed = false;
bool send_message = false;
char msg[1024], subject[256];
for (uint i = 0; i < apps.size(); ++i) {
if (!isAppRunning(apps[i])) {
if (!no_recovery)
executeApp(apps[i]);
subject[0] = '\0';
strcat(subject, apps[i].name);
strcat(subject, ": FALLO INESPERADO.");
msg[0] = '\0';
strcat(msg, "La aplicación ");
strcat(msg, apps[i].name);
strcat(msg, " falló inesperadamente, se reinicia.");
failed = true;
} else if (!isMemLow(apps[i])) {
if (!no_recovery)
executeApp(apps[i]);
subject[0] = '\0';
strcat(subject, apps[i].name);
strcat(subject, ": MEMORIA LLENA.");
msg[0] = '\0';
strcat(msg, "La aplicación ");
strcat(msg, apps[i].name);
strcat(msg,
" ocupó el límite máximo de memoria permitido, se reinicia.");
failed = true;
} else {
if (apps[i].success_tries < recover_hysteresis) {
++apps[i].success_tries;
} else if (apps[i].success_tries == recover_hysteresis) {
if (apps[i].fail_tries > retries_to_warn) {
send_message = true;
subject[0] = '\0';
strcat(subject, apps[i].name);
strcat(subject, ": OK.");
msg[0] = '\0';
strcat(msg, "La aplicación ");
strcat(msg, apps[i].name);
strcat(msg, " consiguió reiniciarse.");
}
++apps[i].success_tries;
apps[i].fail_tries = 0;
}
}
if (failed) {
if (apps[i].fail_tries == 0) {
send_message = true;
} else {
if (apps[i].success_tries > 0
&& apps[i].success_tries <= recover_hysteresis)
apps[i].fail_tries += apps[i].success_tries;
if (apps[i].fail_tries == retries_to_warn) {
send_message = true;
subject[0] = '\0';
strcat(subject, apps[i].name);
strcat(subject, ": ERROR GRAVE.");
msg[0] = '\0';
strcat(msg, "La aplicación ");
strcat(msg, apps[i].name);
strcat(
msg,
" no es capaz de reiniciarse, se requiere acción INMEDIATA.");
} else if (apps[i].fail_tries % warn_reminder == 0) {
send_message = true;
subject[0] = '\0';
strcat(subject, apps[i].name);
strcat(subject, ": RECORDATORIO DE ERROR GRAVE.");
msg[0] = '\0';
strcat(msg, "La aplicación ");
strcat(msg, apps[i].name);
strcat(
msg,
" no es capaz de reiniciarse, se requiere acción INMEDIATA.");
}
}
++apps[i].fail_tries;
apps[i].success_tries = 0;
}
if (send_message) {
toLog(subject)
if (!no_mail) {
for (unsigned int j = 0; j < apps[i].alarm_mails.size(); ++j) {
const char * mail = apps[i].alarm_mails[j];
sender.send(mail, subject, msg, 1024);
}
}
}
}
}
log.close();
return 0;
}
| 27.906191 | 179 | 0.585048 | [
"vector"
] |
3dfed127101e21d8e2f4708bcb1f5e2761af18f8 | 491,872 | cpp | C++ | djangoProject1/venv/Lib/site-packages/spacy/symbols.cpp | meddhafer97/Risk-management-khnowledge-based-system | aba86734801a9e0313071e2c9931295e0da08ed0 | [
"MIT"
] | null | null | null | djangoProject1/venv/Lib/site-packages/spacy/symbols.cpp | meddhafer97/Risk-management-khnowledge-based-system | aba86734801a9e0313071e2c9931295e0da08ed0 | [
"MIT"
] | null | null | null | djangoProject1/venv/Lib/site-packages/spacy/symbols.cpp | meddhafer97/Risk-management-khnowledge-based-system | aba86734801a9e0313071e2c9931295e0da08ed0 | [
"MIT"
] | null | null | null | /* Generated by Cython 0.29.24 */
/* BEGIN: Cython Metadata
{
"distutils": {
"extra_compile_args": [
"-std=c++11"
],
"include_dirs": [
"C:\\hostedtoolcache\\windows\\Python\\3.9.7\\x64\\lib\\site-packages\\numpy\\core\\include",
"C:\\hostedtoolcache\\windows\\Python\\3.9.7\\x64\\include"
],
"language": "c++",
"name": "spacy.symbols",
"sources": [
"spacy/symbols.pyx"
]
},
"module_name": "spacy.symbols"
}
END: Cython Metadata */
#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
#error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_24"
#define CYTHON_HEX_VERSION 0x001D18F0
#define CYTHON_FUTURE_DIVISION 0
#include <stddef.h>
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
#ifndef __stdcall
#define __stdcall
#endif
#ifndef __cdecl
#define __cdecl
#endif
#ifndef __fastcall
#define __fastcall
#endif
#endif
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
#define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
#if PY_VERSION_HEX >= 0x02070000
#define HAVE_LONG_LONG
#endif
#endif
#ifndef PY_LONG_LONG
#define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
#define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_PYSTON 0
#define CYTHON_COMPILING_IN_CPYTHON 0
#undef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 0
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#if PY_VERSION_HEX < 0x03050000
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#undef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 0
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#undef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 1
#undef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 0
#undef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 0
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#undef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#undef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_PYSTON 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#undef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#undef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_PYSTON 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#if PY_VERSION_HEX < 0x02070000
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
#define CYTHON_USE_PYTYPE_LOOKUP 1
#endif
#if PY_MAJOR_VERSION < 3
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#if PY_VERSION_HEX < 0x02070000
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#elif !defined(CYTHON_USE_PYLONG_INTERNALS)
#define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#ifndef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 1
#endif
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#if PY_VERSION_HEX < 0x030300F0
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#elif !defined(CYTHON_USE_UNICODE_WRITER)
#define CYTHON_USE_UNICODE_WRITER 1
#endif
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#ifndef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 1
#endif
#ifndef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 1
#endif
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
#endif
#ifndef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
#endif
#ifndef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
#endif
#ifndef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
#endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#undef SHIFT
#undef BASE
#undef MASK
#ifdef SIZEOF_VOID_P
enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
#endif
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
#if defined(__GNUC__)
#define CYTHON_RESTRICT __restrict__
#elif defined(_MSC_VER) && _MSC_VER >= 1400
#define CYTHON_RESTRICT __restrict
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_RESTRICT restrict
#else
#define CYTHON_RESTRICT
#endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
# if defined(__cplusplus)
template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
# else
# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
# define CYTHON_NCP_UNUSED
# else
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
#ifndef _MSC_STDINT_H_
#if _MSC_VER < 1300
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
#else
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
#endif
#endif
#else
#include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
#if defined(__cplusplus) && __cplusplus >= 201103L
#if __has_cpp_attribute(fallthrough)
#define CYTHON_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough)
#define CYTHON_FALLTHROUGH [[clang::fallthrough]]
#elif __has_cpp_attribute(gnu::fallthrough)
#define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
#endif
#endif
#ifndef CYTHON_FALLTHROUGH
#if __has_attribute(fallthrough)
#define CYTHON_FALLTHROUGH __attribute__((fallthrough))
#else
#define CYTHON_FALLTHROUGH
#endif
#endif
#if defined(__clang__ ) && defined(__apple_build_version__)
#if __apple_build_version__ < 7000000
#undef CYTHON_FALLTHROUGH
#define CYTHON_FALLTHROUGH
#endif
#endif
#endif
#ifndef __cplusplus
#error "Cython files generated with the C++ option must be compiled with a C++ compiler."
#endif
#ifndef CYTHON_INLINE
#if defined(__clang__)
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
#else
#define CYTHON_INLINE inline
#endif
#endif
template<typename T>
void __Pyx_call_destructor(T& x) {
x.~T();
}
template<typename T>
class __Pyx_FakeReference {
public:
__Pyx_FakeReference() : ptr(NULL) { }
__Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
T *operator->() { return ptr; }
T *operator&() { return ptr; }
operator T&() { return *ptr; }
template<typename U> bool operator ==(U other) { return *ptr == other; }
template<typename U> bool operator !=(U other) { return *ptr != other; }
private:
T *ptr;
};
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#define __Pyx_DefaultClassType PyClass_Type
#else
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
#define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
#define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
#define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
#define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
#define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
#ifndef METH_FASTCALL
#define METH_FASTCALL 0x80
#endif
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
Py_ssize_t nargs, PyObject *kwnames);
#else
#define __Pyx_PyCFunctionFast _PyCFunctionFast
#define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
#define PyObject_Malloc(s) PyMem_Malloc(s)
#define PyObject_Free(p) PyMem_Free(p)
#define PyObject_Realloc(p) PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
#define PyMem_RawMalloc(n) PyMem_Malloc(n)
#define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
#define PyMem_RawFree(p) PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
#define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
#define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
#define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
#define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
*key = PyThread_create_key();
return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
*key = Py_tss_NEEDS_INIT;
return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
PyThread_delete_key(*key);
*key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n) PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
#else
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
#if defined(PyUnicode_IS_READY)
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
0 : _PyUnicode_Ready((PyObject *)(op)))
#else
#define __Pyx_PyUnicode_READY(op) (0)
#endif
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
#if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
#else
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#endif
#else
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
#endif
#else
#define CYTHON_PEP393_ENABLED 0
#define PyUnicode_1BYTE_KIND 1
#define PyUnicode_2BYTE_KIND 2
#define PyUnicode_4BYTE_KIND 4
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
#else
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
#else
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
#define PyObject_ASCII(o) PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBaseString_Type PyUnicode_Type
#define PyStringObject PyUnicodeObject
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
#ifndef PyObject_Unicode
#define PyObject_Unicode PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
#define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
#define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
#define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
#define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
#define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
#define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
#define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
#else
#define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_Type
#define PyInt_Check(op) PyLong_Check(op)
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
#define PyInt_FromString PyLong_FromString
#define PyInt_FromUnicode PyLong_FromUnicode
#define PyInt_FromLong PyLong_FromLong
#define PyInt_FromSize_t PyLong_FromSize_t
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AS_LONG PyLong_AS_LONG
#define PyInt_AsSsize_t PyLong_AsSsize_t
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#define PyNumber_Int PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBoolObject PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
#ifndef PyUnicode_InternFromString
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
#endif
#endif
#if PY_VERSION_HEX < 0x030200A4
typedef long Py_hash_t;
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
#else
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#else
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#endif
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
typedef struct {
unaryfunc am_await;
unaryfunc am_aiter;
unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#endif
#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
float value;
memset(&value, 0xFF, sizeof(value));
return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif
#define __PYX_MARK_ERR_POS(f_index, lineno) \
{ __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
{ __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
#ifndef __PYX_EXTERN_C
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#endif
#define __PYX_HAVE__spacy__symbols
#define __PYX_HAVE_API__spacy__symbols
/* Early includes */
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
(sizeof(type) < sizeof(Py_ssize_t)) ||\
(sizeof(type) > sizeof(Py_ssize_t) &&\
likely(v < (type)PY_SSIZE_T_MAX ||\
v == (type)PY_SSIZE_T_MAX) &&\
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
v == (type)PY_SSIZE_T_MIN))) ||\
(sizeof(type) == sizeof(Py_ssize_t) &&\
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
v == (type)PY_SSIZE_T_MAX))) )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
#include <cstdlib>
#define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
#define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
#define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
const Py_UNICODE *u_end = u;
while (*u_end++) ;
return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
(likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
PyObject* sys;
PyObject* default_encoding = NULL;
PyObject* ascii_chars_u = NULL;
PyObject* ascii_chars_b = NULL;
const char* default_encoding_c;
sys = PyImport_ImportModule("sys");
if (!sys) goto bad;
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
Py_DECREF(sys);
if (!default_encoding) goto bad;
default_encoding_c = PyBytes_AsString(default_encoding);
if (!default_encoding_c) goto bad;
if (strcmp(default_encoding_c, "ascii") == 0) {
__Pyx_sys_getdefaultencoding_not_ascii = 0;
} else {
char ascii_chars[128];
int c;
for (c = 0; c < 128; c++) {
ascii_chars[c] = c;
}
__Pyx_sys_getdefaultencoding_not_ascii = 1;
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
if (!ascii_chars_u) goto bad;
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
PyErr_Format(
PyExc_ValueError,
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
default_encoding_c);
goto bad;
}
Py_DECREF(ascii_chars_u);
Py_DECREF(ascii_chars_b);
}
Py_DECREF(default_encoding);
return 0;
bad:
Py_XDECREF(default_encoding);
Py_XDECREF(ascii_chars_u);
Py_XDECREF(ascii_chars_b);
return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
PyObject* sys;
PyObject* default_encoding = NULL;
char* default_encoding_c;
sys = PyImport_ImportModule("sys");
if (!sys) goto bad;
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
Py_DECREF(sys);
if (!default_encoding) goto bad;
default_encoding_c = PyBytes_AsString(default_encoding);
if (!default_encoding_c) goto bad;
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
Py_DECREF(default_encoding);
return 0;
bad:
Py_XDECREF(default_encoding);
return -1;
}
#endif
#endif
/* Test for GCC > 2.95 */
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
static const char *__pyx_f[] = {
"spacy\\symbols.pyx",
};
/*--- Type declarations ---*/
/* "spacy/symbols.pxd":1
* cdef enum symbol_t: # <<<<<<<<<<<<<<
* NIL
* IS_ALPHA
*/
enum __pyx_t_5spacy_7symbols_symbol_t {
__pyx_e_5spacy_7symbols_NIL,
__pyx_e_5spacy_7symbols_IS_ALPHA,
__pyx_e_5spacy_7symbols_IS_ASCII,
__pyx_e_5spacy_7symbols_IS_DIGIT,
__pyx_e_5spacy_7symbols_IS_LOWER,
__pyx_e_5spacy_7symbols_IS_PUNCT,
__pyx_e_5spacy_7symbols_IS_SPACE,
__pyx_e_5spacy_7symbols_IS_TITLE,
__pyx_e_5spacy_7symbols_IS_UPPER,
__pyx_e_5spacy_7symbols_LIKE_URL,
__pyx_e_5spacy_7symbols_LIKE_NUM,
__pyx_e_5spacy_7symbols_LIKE_EMAIL,
__pyx_e_5spacy_7symbols_IS_STOP,
__pyx_e_5spacy_7symbols_IS_OOV_DEPRECATED,
__pyx_e_5spacy_7symbols_IS_BRACKET,
__pyx_e_5spacy_7symbols_IS_QUOTE,
__pyx_e_5spacy_7symbols_IS_LEFT_PUNCT,
__pyx_e_5spacy_7symbols_IS_RIGHT_PUNCT,
__pyx_e_5spacy_7symbols_IS_CURRENCY,
__pyx_e_5spacy_7symbols_FLAG19 = 19,
__pyx_e_5spacy_7symbols_FLAG20,
__pyx_e_5spacy_7symbols_FLAG21,
__pyx_e_5spacy_7symbols_FLAG22,
__pyx_e_5spacy_7symbols_FLAG23,
__pyx_e_5spacy_7symbols_FLAG24,
__pyx_e_5spacy_7symbols_FLAG25,
__pyx_e_5spacy_7symbols_FLAG26,
__pyx_e_5spacy_7symbols_FLAG27,
__pyx_e_5spacy_7symbols_FLAG28,
__pyx_e_5spacy_7symbols_FLAG29,
__pyx_e_5spacy_7symbols_FLAG30,
__pyx_e_5spacy_7symbols_FLAG31,
__pyx_e_5spacy_7symbols_FLAG32,
__pyx_e_5spacy_7symbols_FLAG33,
__pyx_e_5spacy_7symbols_FLAG34,
__pyx_e_5spacy_7symbols_FLAG35,
__pyx_e_5spacy_7symbols_FLAG36,
__pyx_e_5spacy_7symbols_FLAG37,
__pyx_e_5spacy_7symbols_FLAG38,
__pyx_e_5spacy_7symbols_FLAG39,
__pyx_e_5spacy_7symbols_FLAG40,
__pyx_e_5spacy_7symbols_FLAG41,
__pyx_e_5spacy_7symbols_FLAG42,
__pyx_e_5spacy_7symbols_FLAG43,
__pyx_e_5spacy_7symbols_FLAG44,
__pyx_e_5spacy_7symbols_FLAG45,
__pyx_e_5spacy_7symbols_FLAG46,
__pyx_e_5spacy_7symbols_FLAG47,
__pyx_e_5spacy_7symbols_FLAG48,
__pyx_e_5spacy_7symbols_FLAG49,
__pyx_e_5spacy_7symbols_FLAG50,
__pyx_e_5spacy_7symbols_FLAG51,
__pyx_e_5spacy_7symbols_FLAG52,
__pyx_e_5spacy_7symbols_FLAG53,
__pyx_e_5spacy_7symbols_FLAG54,
__pyx_e_5spacy_7symbols_FLAG55,
__pyx_e_5spacy_7symbols_FLAG56,
__pyx_e_5spacy_7symbols_FLAG57,
__pyx_e_5spacy_7symbols_FLAG58,
__pyx_e_5spacy_7symbols_FLAG59,
__pyx_e_5spacy_7symbols_FLAG60,
__pyx_e_5spacy_7symbols_FLAG61,
__pyx_e_5spacy_7symbols_FLAG62,
__pyx_e_5spacy_7symbols_FLAG63,
__pyx_e_5spacy_7symbols_ID,
__pyx_e_5spacy_7symbols_ORTH,
__pyx_e_5spacy_7symbols_LOWER,
__pyx_e_5spacy_7symbols_NORM,
__pyx_e_5spacy_7symbols_SHAPE,
__pyx_e_5spacy_7symbols_PREFIX,
__pyx_e_5spacy_7symbols_SUFFIX,
__pyx_e_5spacy_7symbols_LENGTH,
__pyx_e_5spacy_7symbols_CLUSTER,
__pyx_e_5spacy_7symbols_LEMMA,
__pyx_e_5spacy_7symbols_POS,
__pyx_e_5spacy_7symbols_TAG,
__pyx_e_5spacy_7symbols_DEP,
__pyx_e_5spacy_7symbols_ENT_IOB,
__pyx_e_5spacy_7symbols_ENT_TYPE,
__pyx_e_5spacy_7symbols_HEAD,
__pyx_e_5spacy_7symbols_SENT_START,
__pyx_e_5spacy_7symbols_SPACY,
__pyx_e_5spacy_7symbols_PROB,
__pyx_e_5spacy_7symbols_LANG,
__pyx_e_5spacy_7symbols_ADJ,
__pyx_e_5spacy_7symbols_ADP,
__pyx_e_5spacy_7symbols_ADV,
__pyx_e_5spacy_7symbols_AUX,
__pyx_e_5spacy_7symbols_CONJ,
__pyx_e_5spacy_7symbols_CCONJ,
__pyx_e_5spacy_7symbols_DET,
__pyx_e_5spacy_7symbols_INTJ,
__pyx_e_5spacy_7symbols_NOUN,
__pyx_e_5spacy_7symbols_NUM,
__pyx_e_5spacy_7symbols_PART,
__pyx_e_5spacy_7symbols_PRON,
__pyx_e_5spacy_7symbols_PROPN,
__pyx_e_5spacy_7symbols_PUNCT,
__pyx_e_5spacy_7symbols_SCONJ,
__pyx_e_5spacy_7symbols_SYM,
__pyx_e_5spacy_7symbols_VERB,
__pyx_e_5spacy_7symbols_X,
__pyx_e_5spacy_7symbols_EOL,
__pyx_e_5spacy_7symbols_SPACE,
__pyx_e_5spacy_7symbols_DEPRECATED001,
__pyx_e_5spacy_7symbols_DEPRECATED002,
__pyx_e_5spacy_7symbols_DEPRECATED003,
__pyx_e_5spacy_7symbols_DEPRECATED004,
__pyx_e_5spacy_7symbols_DEPRECATED005,
__pyx_e_5spacy_7symbols_DEPRECATED006,
__pyx_e_5spacy_7symbols_DEPRECATED007,
__pyx_e_5spacy_7symbols_DEPRECATED008,
__pyx_e_5spacy_7symbols_DEPRECATED009,
__pyx_e_5spacy_7symbols_DEPRECATED010,
__pyx_e_5spacy_7symbols_DEPRECATED011,
__pyx_e_5spacy_7symbols_DEPRECATED012,
__pyx_e_5spacy_7symbols_DEPRECATED013,
__pyx_e_5spacy_7symbols_DEPRECATED014,
__pyx_e_5spacy_7symbols_DEPRECATED015,
__pyx_e_5spacy_7symbols_DEPRECATED016,
__pyx_e_5spacy_7symbols_DEPRECATED017,
__pyx_e_5spacy_7symbols_DEPRECATED018,
__pyx_e_5spacy_7symbols_DEPRECATED019,
__pyx_e_5spacy_7symbols_DEPRECATED020,
__pyx_e_5spacy_7symbols_DEPRECATED021,
__pyx_e_5spacy_7symbols_DEPRECATED022,
__pyx_e_5spacy_7symbols_DEPRECATED023,
__pyx_e_5spacy_7symbols_DEPRECATED024,
__pyx_e_5spacy_7symbols_DEPRECATED025,
__pyx_e_5spacy_7symbols_DEPRECATED026,
__pyx_e_5spacy_7symbols_DEPRECATED027,
__pyx_e_5spacy_7symbols_DEPRECATED028,
__pyx_e_5spacy_7symbols_DEPRECATED029,
__pyx_e_5spacy_7symbols_DEPRECATED030,
__pyx_e_5spacy_7symbols_DEPRECATED031,
__pyx_e_5spacy_7symbols_DEPRECATED032,
__pyx_e_5spacy_7symbols_DEPRECATED033,
__pyx_e_5spacy_7symbols_DEPRECATED034,
__pyx_e_5spacy_7symbols_DEPRECATED035,
__pyx_e_5spacy_7symbols_DEPRECATED036,
__pyx_e_5spacy_7symbols_DEPRECATED037,
__pyx_e_5spacy_7symbols_DEPRECATED038,
__pyx_e_5spacy_7symbols_DEPRECATED039,
__pyx_e_5spacy_7symbols_DEPRECATED040,
__pyx_e_5spacy_7symbols_DEPRECATED041,
__pyx_e_5spacy_7symbols_DEPRECATED042,
__pyx_e_5spacy_7symbols_DEPRECATED043,
__pyx_e_5spacy_7symbols_DEPRECATED044,
__pyx_e_5spacy_7symbols_DEPRECATED045,
__pyx_e_5spacy_7symbols_DEPRECATED046,
__pyx_e_5spacy_7symbols_DEPRECATED047,
__pyx_e_5spacy_7symbols_DEPRECATED048,
__pyx_e_5spacy_7symbols_DEPRECATED049,
__pyx_e_5spacy_7symbols_DEPRECATED050,
__pyx_e_5spacy_7symbols_DEPRECATED051,
__pyx_e_5spacy_7symbols_DEPRECATED052,
__pyx_e_5spacy_7symbols_DEPRECATED053,
__pyx_e_5spacy_7symbols_DEPRECATED054,
__pyx_e_5spacy_7symbols_DEPRECATED055,
__pyx_e_5spacy_7symbols_DEPRECATED056,
__pyx_e_5spacy_7symbols_DEPRECATED057,
__pyx_e_5spacy_7symbols_DEPRECATED058,
__pyx_e_5spacy_7symbols_DEPRECATED059,
__pyx_e_5spacy_7symbols_DEPRECATED060,
__pyx_e_5spacy_7symbols_DEPRECATED061,
__pyx_e_5spacy_7symbols_DEPRECATED062,
__pyx_e_5spacy_7symbols_DEPRECATED063,
__pyx_e_5spacy_7symbols_DEPRECATED064,
__pyx_e_5spacy_7symbols_DEPRECATED065,
__pyx_e_5spacy_7symbols_DEPRECATED066,
__pyx_e_5spacy_7symbols_DEPRECATED067,
__pyx_e_5spacy_7symbols_DEPRECATED068,
__pyx_e_5spacy_7symbols_DEPRECATED069,
__pyx_e_5spacy_7symbols_DEPRECATED070,
__pyx_e_5spacy_7symbols_DEPRECATED071,
__pyx_e_5spacy_7symbols_DEPRECATED072,
__pyx_e_5spacy_7symbols_DEPRECATED073,
__pyx_e_5spacy_7symbols_DEPRECATED074,
__pyx_e_5spacy_7symbols_DEPRECATED075,
__pyx_e_5spacy_7symbols_DEPRECATED076,
__pyx_e_5spacy_7symbols_DEPRECATED077,
__pyx_e_5spacy_7symbols_DEPRECATED078,
__pyx_e_5spacy_7symbols_DEPRECATED079,
__pyx_e_5spacy_7symbols_DEPRECATED080,
__pyx_e_5spacy_7symbols_DEPRECATED081,
__pyx_e_5spacy_7symbols_DEPRECATED082,
__pyx_e_5spacy_7symbols_DEPRECATED083,
__pyx_e_5spacy_7symbols_DEPRECATED084,
__pyx_e_5spacy_7symbols_DEPRECATED085,
__pyx_e_5spacy_7symbols_DEPRECATED086,
__pyx_e_5spacy_7symbols_DEPRECATED087,
__pyx_e_5spacy_7symbols_DEPRECATED088,
__pyx_e_5spacy_7symbols_DEPRECATED089,
__pyx_e_5spacy_7symbols_DEPRECATED090,
__pyx_e_5spacy_7symbols_DEPRECATED091,
__pyx_e_5spacy_7symbols_DEPRECATED092,
__pyx_e_5spacy_7symbols_DEPRECATED093,
__pyx_e_5spacy_7symbols_DEPRECATED094,
__pyx_e_5spacy_7symbols_DEPRECATED095,
__pyx_e_5spacy_7symbols_DEPRECATED096,
__pyx_e_5spacy_7symbols_DEPRECATED097,
__pyx_e_5spacy_7symbols_DEPRECATED098,
__pyx_e_5spacy_7symbols_DEPRECATED099,
__pyx_e_5spacy_7symbols_DEPRECATED100,
__pyx_e_5spacy_7symbols_DEPRECATED101,
__pyx_e_5spacy_7symbols_DEPRECATED102,
__pyx_e_5spacy_7symbols_DEPRECATED103,
__pyx_e_5spacy_7symbols_DEPRECATED104,
__pyx_e_5spacy_7symbols_DEPRECATED105,
__pyx_e_5spacy_7symbols_DEPRECATED106,
__pyx_e_5spacy_7symbols_DEPRECATED107,
__pyx_e_5spacy_7symbols_DEPRECATED108,
__pyx_e_5spacy_7symbols_DEPRECATED109,
__pyx_e_5spacy_7symbols_DEPRECATED110,
__pyx_e_5spacy_7symbols_DEPRECATED111,
__pyx_e_5spacy_7symbols_DEPRECATED112,
__pyx_e_5spacy_7symbols_DEPRECATED113,
__pyx_e_5spacy_7symbols_DEPRECATED114,
__pyx_e_5spacy_7symbols_DEPRECATED115,
__pyx_e_5spacy_7symbols_DEPRECATED116,
__pyx_e_5spacy_7symbols_DEPRECATED117,
__pyx_e_5spacy_7symbols_DEPRECATED118,
__pyx_e_5spacy_7symbols_DEPRECATED119,
__pyx_e_5spacy_7symbols_DEPRECATED120,
__pyx_e_5spacy_7symbols_DEPRECATED121,
__pyx_e_5spacy_7symbols_DEPRECATED122,
__pyx_e_5spacy_7symbols_DEPRECATED123,
__pyx_e_5spacy_7symbols_DEPRECATED124,
__pyx_e_5spacy_7symbols_DEPRECATED125,
__pyx_e_5spacy_7symbols_DEPRECATED126,
__pyx_e_5spacy_7symbols_DEPRECATED127,
__pyx_e_5spacy_7symbols_DEPRECATED128,
__pyx_e_5spacy_7symbols_DEPRECATED129,
__pyx_e_5spacy_7symbols_DEPRECATED130,
__pyx_e_5spacy_7symbols_DEPRECATED131,
__pyx_e_5spacy_7symbols_DEPRECATED132,
__pyx_e_5spacy_7symbols_DEPRECATED133,
__pyx_e_5spacy_7symbols_DEPRECATED134,
__pyx_e_5spacy_7symbols_DEPRECATED135,
__pyx_e_5spacy_7symbols_DEPRECATED136,
__pyx_e_5spacy_7symbols_DEPRECATED137,
__pyx_e_5spacy_7symbols_DEPRECATED138,
__pyx_e_5spacy_7symbols_DEPRECATED139,
__pyx_e_5spacy_7symbols_DEPRECATED140,
__pyx_e_5spacy_7symbols_DEPRECATED141,
__pyx_e_5spacy_7symbols_DEPRECATED142,
__pyx_e_5spacy_7symbols_DEPRECATED143,
__pyx_e_5spacy_7symbols_DEPRECATED144,
__pyx_e_5spacy_7symbols_DEPRECATED145,
__pyx_e_5spacy_7symbols_DEPRECATED146,
__pyx_e_5spacy_7symbols_DEPRECATED147,
__pyx_e_5spacy_7symbols_DEPRECATED148,
__pyx_e_5spacy_7symbols_DEPRECATED149,
__pyx_e_5spacy_7symbols_DEPRECATED150,
__pyx_e_5spacy_7symbols_DEPRECATED151,
__pyx_e_5spacy_7symbols_DEPRECATED152,
__pyx_e_5spacy_7symbols_DEPRECATED153,
__pyx_e_5spacy_7symbols_DEPRECATED154,
__pyx_e_5spacy_7symbols_DEPRECATED155,
__pyx_e_5spacy_7symbols_DEPRECATED156,
__pyx_e_5spacy_7symbols_DEPRECATED157,
__pyx_e_5spacy_7symbols_DEPRECATED158,
__pyx_e_5spacy_7symbols_DEPRECATED159,
__pyx_e_5spacy_7symbols_DEPRECATED160,
__pyx_e_5spacy_7symbols_DEPRECATED161,
__pyx_e_5spacy_7symbols_DEPRECATED162,
__pyx_e_5spacy_7symbols_DEPRECATED163,
__pyx_e_5spacy_7symbols_DEPRECATED164,
__pyx_e_5spacy_7symbols_DEPRECATED165,
__pyx_e_5spacy_7symbols_DEPRECATED166,
__pyx_e_5spacy_7symbols_DEPRECATED167,
__pyx_e_5spacy_7symbols_DEPRECATED168,
__pyx_e_5spacy_7symbols_DEPRECATED169,
__pyx_e_5spacy_7symbols_DEPRECATED170,
__pyx_e_5spacy_7symbols_DEPRECATED171,
__pyx_e_5spacy_7symbols_DEPRECATED172,
__pyx_e_5spacy_7symbols_DEPRECATED173,
__pyx_e_5spacy_7symbols_DEPRECATED174,
__pyx_e_5spacy_7symbols_DEPRECATED175,
__pyx_e_5spacy_7symbols_DEPRECATED176,
__pyx_e_5spacy_7symbols_DEPRECATED177,
__pyx_e_5spacy_7symbols_DEPRECATED178,
__pyx_e_5spacy_7symbols_DEPRECATED179,
__pyx_e_5spacy_7symbols_DEPRECATED180,
__pyx_e_5spacy_7symbols_DEPRECATED181,
__pyx_e_5spacy_7symbols_DEPRECATED182,
__pyx_e_5spacy_7symbols_DEPRECATED183,
__pyx_e_5spacy_7symbols_DEPRECATED184,
__pyx_e_5spacy_7symbols_DEPRECATED185,
__pyx_e_5spacy_7symbols_DEPRECATED186,
__pyx_e_5spacy_7symbols_DEPRECATED187,
__pyx_e_5spacy_7symbols_DEPRECATED188,
__pyx_e_5spacy_7symbols_DEPRECATED189,
__pyx_e_5spacy_7symbols_DEPRECATED190,
__pyx_e_5spacy_7symbols_DEPRECATED191,
__pyx_e_5spacy_7symbols_DEPRECATED192,
__pyx_e_5spacy_7symbols_DEPRECATED193,
__pyx_e_5spacy_7symbols_DEPRECATED194,
__pyx_e_5spacy_7symbols_DEPRECATED195,
__pyx_e_5spacy_7symbols_DEPRECATED196,
__pyx_e_5spacy_7symbols_DEPRECATED197,
__pyx_e_5spacy_7symbols_DEPRECATED198,
__pyx_e_5spacy_7symbols_DEPRECATED199,
__pyx_e_5spacy_7symbols_DEPRECATED200,
__pyx_e_5spacy_7symbols_DEPRECATED201,
__pyx_e_5spacy_7symbols_DEPRECATED202,
__pyx_e_5spacy_7symbols_DEPRECATED203,
__pyx_e_5spacy_7symbols_DEPRECATED204,
__pyx_e_5spacy_7symbols_DEPRECATED205,
__pyx_e_5spacy_7symbols_DEPRECATED206,
__pyx_e_5spacy_7symbols_DEPRECATED207,
__pyx_e_5spacy_7symbols_DEPRECATED208,
__pyx_e_5spacy_7symbols_DEPRECATED209,
__pyx_e_5spacy_7symbols_DEPRECATED210,
__pyx_e_5spacy_7symbols_DEPRECATED211,
__pyx_e_5spacy_7symbols_DEPRECATED212,
__pyx_e_5spacy_7symbols_DEPRECATED213,
__pyx_e_5spacy_7symbols_DEPRECATED214,
__pyx_e_5spacy_7symbols_DEPRECATED215,
__pyx_e_5spacy_7symbols_DEPRECATED216,
__pyx_e_5spacy_7symbols_DEPRECATED217,
__pyx_e_5spacy_7symbols_DEPRECATED218,
__pyx_e_5spacy_7symbols_DEPRECATED219,
__pyx_e_5spacy_7symbols_DEPRECATED220,
__pyx_e_5spacy_7symbols_DEPRECATED221,
__pyx_e_5spacy_7symbols_DEPRECATED222,
__pyx_e_5spacy_7symbols_DEPRECATED223,
__pyx_e_5spacy_7symbols_DEPRECATED224,
__pyx_e_5spacy_7symbols_DEPRECATED225,
__pyx_e_5spacy_7symbols_DEPRECATED226,
__pyx_e_5spacy_7symbols_DEPRECATED227,
__pyx_e_5spacy_7symbols_DEPRECATED228,
__pyx_e_5spacy_7symbols_DEPRECATED229,
__pyx_e_5spacy_7symbols_DEPRECATED230,
__pyx_e_5spacy_7symbols_DEPRECATED231,
__pyx_e_5spacy_7symbols_DEPRECATED232,
__pyx_e_5spacy_7symbols_DEPRECATED233,
__pyx_e_5spacy_7symbols_DEPRECATED234,
__pyx_e_5spacy_7symbols_DEPRECATED235,
__pyx_e_5spacy_7symbols_DEPRECATED236,
__pyx_e_5spacy_7symbols_DEPRECATED237,
__pyx_e_5spacy_7symbols_DEPRECATED238,
__pyx_e_5spacy_7symbols_DEPRECATED239,
__pyx_e_5spacy_7symbols_DEPRECATED240,
__pyx_e_5spacy_7symbols_DEPRECATED241,
__pyx_e_5spacy_7symbols_DEPRECATED242,
__pyx_e_5spacy_7symbols_DEPRECATED243,
__pyx_e_5spacy_7symbols_DEPRECATED244,
__pyx_e_5spacy_7symbols_DEPRECATED245,
__pyx_e_5spacy_7symbols_DEPRECATED246,
__pyx_e_5spacy_7symbols_DEPRECATED247,
__pyx_e_5spacy_7symbols_DEPRECATED248,
__pyx_e_5spacy_7symbols_DEPRECATED249,
__pyx_e_5spacy_7symbols_DEPRECATED250,
__pyx_e_5spacy_7symbols_DEPRECATED251,
__pyx_e_5spacy_7symbols_DEPRECATED252,
__pyx_e_5spacy_7symbols_DEPRECATED253,
__pyx_e_5spacy_7symbols_DEPRECATED254,
__pyx_e_5spacy_7symbols_DEPRECATED255,
__pyx_e_5spacy_7symbols_DEPRECATED256,
__pyx_e_5spacy_7symbols_DEPRECATED257,
__pyx_e_5spacy_7symbols_DEPRECATED258,
__pyx_e_5spacy_7symbols_DEPRECATED259,
__pyx_e_5spacy_7symbols_DEPRECATED260,
__pyx_e_5spacy_7symbols_DEPRECATED261,
__pyx_e_5spacy_7symbols_DEPRECATED262,
__pyx_e_5spacy_7symbols_DEPRECATED263,
__pyx_e_5spacy_7symbols_DEPRECATED264,
__pyx_e_5spacy_7symbols_DEPRECATED265,
__pyx_e_5spacy_7symbols_DEPRECATED266,
__pyx_e_5spacy_7symbols_DEPRECATED267,
__pyx_e_5spacy_7symbols_DEPRECATED268,
__pyx_e_5spacy_7symbols_DEPRECATED269,
__pyx_e_5spacy_7symbols_DEPRECATED270,
__pyx_e_5spacy_7symbols_DEPRECATED271,
__pyx_e_5spacy_7symbols_DEPRECATED272,
__pyx_e_5spacy_7symbols_DEPRECATED273,
__pyx_e_5spacy_7symbols_DEPRECATED274,
__pyx_e_5spacy_7symbols_DEPRECATED275,
__pyx_e_5spacy_7symbols_DEPRECATED276,
__pyx_e_5spacy_7symbols_PERSON,
__pyx_e_5spacy_7symbols_NORP,
__pyx_e_5spacy_7symbols_FACILITY,
__pyx_e_5spacy_7symbols_ORG,
__pyx_e_5spacy_7symbols_GPE,
__pyx_e_5spacy_7symbols_LOC,
__pyx_e_5spacy_7symbols_PRODUCT,
__pyx_e_5spacy_7symbols_EVENT,
__pyx_e_5spacy_7symbols_WORK_OF_ART,
__pyx_e_5spacy_7symbols_LANGUAGE,
__pyx_e_5spacy_7symbols_LAW,
__pyx_e_5spacy_7symbols_DATE,
__pyx_e_5spacy_7symbols_TIME,
__pyx_e_5spacy_7symbols_PERCENT,
__pyx_e_5spacy_7symbols_MONEY,
__pyx_e_5spacy_7symbols_QUANTITY,
__pyx_e_5spacy_7symbols_ORDINAL,
__pyx_e_5spacy_7symbols_CARDINAL,
__pyx_e_5spacy_7symbols_acomp,
__pyx_e_5spacy_7symbols_advcl,
__pyx_e_5spacy_7symbols_advmod,
__pyx_e_5spacy_7symbols_agent,
__pyx_e_5spacy_7symbols_amod,
__pyx_e_5spacy_7symbols_appos,
__pyx_e_5spacy_7symbols_attr,
__pyx_e_5spacy_7symbols_aux,
__pyx_e_5spacy_7symbols_auxpass,
__pyx_e_5spacy_7symbols_cc,
__pyx_e_5spacy_7symbols_ccomp,
__pyx_e_5spacy_7symbols_complm,
__pyx_e_5spacy_7symbols_conj,
__pyx_e_5spacy_7symbols_cop,
__pyx_e_5spacy_7symbols_csubj,
__pyx_e_5spacy_7symbols_csubjpass,
__pyx_e_5spacy_7symbols_dep,
__pyx_e_5spacy_7symbols_det,
__pyx_e_5spacy_7symbols_dobj,
__pyx_e_5spacy_7symbols_expl,
__pyx_e_5spacy_7symbols_hmod,
__pyx_e_5spacy_7symbols_hyph,
__pyx_e_5spacy_7symbols_infmod,
__pyx_e_5spacy_7symbols_intj,
__pyx_e_5spacy_7symbols_iobj,
__pyx_e_5spacy_7symbols_mark,
__pyx_e_5spacy_7symbols_meta,
__pyx_e_5spacy_7symbols_neg,
__pyx_e_5spacy_7symbols_nmod,
__pyx_e_5spacy_7symbols_nn,
__pyx_e_5spacy_7symbols_npadvmod,
__pyx_e_5spacy_7symbols_nsubj,
__pyx_e_5spacy_7symbols_nsubjpass,
__pyx_e_5spacy_7symbols_num,
__pyx_e_5spacy_7symbols_number,
__pyx_e_5spacy_7symbols_oprd,
__pyx_e_5spacy_7symbols_obj,
__pyx_e_5spacy_7symbols_obl,
__pyx_e_5spacy_7symbols_parataxis,
__pyx_e_5spacy_7symbols_partmod,
__pyx_e_5spacy_7symbols_pcomp,
__pyx_e_5spacy_7symbols_pobj,
__pyx_e_5spacy_7symbols_poss,
__pyx_e_5spacy_7symbols_possessive,
__pyx_e_5spacy_7symbols_preconj,
__pyx_e_5spacy_7symbols_prep,
__pyx_e_5spacy_7symbols_prt,
__pyx_e_5spacy_7symbols_punct,
__pyx_e_5spacy_7symbols_quantmod,
__pyx_e_5spacy_7symbols_relcl,
__pyx_e_5spacy_7symbols_rcmod,
__pyx_e_5spacy_7symbols_root,
__pyx_e_5spacy_7symbols_xcomp,
__pyx_e_5spacy_7symbols_acl,
__pyx_e_5spacy_7symbols_ENT_KB_ID,
__pyx_e_5spacy_7symbols_MORPH,
__pyx_e_5spacy_7symbols_ENT_ID,
__pyx_e_5spacy_7symbols_IDX,
__pyx_e_5spacy_7symbols__
};
/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
#define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
typedef struct {
void (*INCREF)(void*, PyObject*, int);
void (*DECREF)(void*, PyObject*, int);
void (*GOTREF)(void*, PyObject*, int);
void (*GIVEREF)(void*, PyObject*, int);
void* (*SetupContext)(const char*, int, const char*);
void (*FinishContext)(void**);
} __Pyx_RefNannyAPIStruct;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
if (acquire_gil) {\
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
PyGILState_Release(__pyx_gilstate_save);\
} else {\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
}
#else
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
#define __Pyx_RefNannyFinishContext()\
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
#define __Pyx_RefNannyDeclarations
#define __Pyx_RefNannySetupContext(name, acquire_gil)
#define __Pyx_RefNannyFinishContext()
#define __Pyx_INCREF(r) Py_INCREF(r)
#define __Pyx_DECREF(r) Py_DECREF(r)
#define __Pyx_GOTREF(r)
#define __Pyx_GIVEREF(r)
#define __Pyx_XINCREF(r) Py_XINCREF(r)
#define __Pyx_XDECREF(r) Py_XDECREF(r)
#define __Pyx_XGOTREF(r)
#define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
PyObject *tmp = (PyObject *) r;\
r = v; __Pyx_XDECREF(tmp);\
} while (0)
#define __Pyx_DECREF_SET(r, v) do {\
PyObject *tmp = (PyObject *) r;\
r = v; __Pyx_DECREF(tmp);\
} while (0)
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif
/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
(is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
__Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
(PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
(PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
int is_list, int wraparound, int boundscheck);
/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
(version_var) = __PYX_GET_DICT_VERSION(dict);\
(cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
static PY_UINT64_T __pyx_dict_version = 0;\
static PyObject *__pyx_dict_cached_value = NULL;\
if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
(VAR) = __pyx_dict_cached_value;\
} else {\
(VAR) = __pyx_dict_cached_value = (LOOKUP);\
__pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
}\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict) (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
#endif
/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name) {\
static PY_UINT64_T __pyx_dict_version = 0;\
static PyObject *__pyx_dict_cached_value = NULL;\
(var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
(likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
__Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name) {\
PY_UINT64_T __pyx_dict_version;\
PyObject *__pyx_dict_cached_value;\
(var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif
/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
__Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
(sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
static size_t __pyx_pyframe_localsplus_offset = 0;
#include "frameobject.h"
#define __Pxy_PyFrame_Initialize_Offsets()\
((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
(void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
#define __Pyx_PyFrame_GetLocalsplus(frame)\
(assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif
/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif
/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif
/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif
/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
PyListObject* L = (PyListObject*) list;
Py_ssize_t len = Py_SIZE(list);
if (likely(L->allocated > len)) {
Py_INCREF(x);
PyList_SET_ITEM(list, len, x);
__Pyx_SET_SIZE(list, len + 1);
return 0;
}
return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif
/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
#endif
/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred() PyErr_Occurred()
#endif
/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
#endif
/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif
/* CodeObjectCache.proto */
typedef struct {
PyCodeObject* code_object;
int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
int count;
int max_count;
__Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename);
/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(enum __pyx_t_5spacy_7symbols_symbol_t value);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
/* Globals.proto */
static PyObject* __Pyx_Globals(void);
/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);
/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
/* Module declarations from 'spacy.symbols' */
#define __Pyx_MODULE_NAME "spacy.symbols"
extern int __pyx_module_is_main_spacy__symbols;
int __pyx_module_is_main_spacy__symbols = 0;
/* Implementation of 'spacy.symbols' */
static PyObject *__pyx_builtin_sorted;
static const char __pyx_k_[] = "";
static const char __pyx_k_X[] = "X";
static const char __pyx_k_x[] = "x";
static const char __pyx_k_ID[] = "ID";
static const char __pyx_k__2[] = "_";
static const char __pyx_k_cc[] = "cc";
static const char __pyx_k_it[] = "it";
static const char __pyx_k_nn[] = "nn";
static const char __pyx_k_ADJ[] = "ADJ";
static const char __pyx_k_ADP[] = "ADP";
static const char __pyx_k_ADV[] = "ADV";
static const char __pyx_k_AUX[] = "AUX";
static const char __pyx_k_DEP[] = "DEP";
static const char __pyx_k_DET[] = "DET";
static const char __pyx_k_EOL[] = "EOL";
static const char __pyx_k_GPE[] = "GPE";
static const char __pyx_k_IDS[] = "IDS";
static const char __pyx_k_IDX[] = "IDX";
static const char __pyx_k_LAW[] = "LAW";
static const char __pyx_k_LOC[] = "LOC";
static const char __pyx_k_NUM[] = "NUM";
static const char __pyx_k_ORG[] = "ORG";
static const char __pyx_k_POS[] = "POS";
static const char __pyx_k_SYM[] = "SYM";
static const char __pyx_k_TAG[] = "TAG";
static const char __pyx_k_acl[] = "acl";
static const char __pyx_k_aux[] = "aux";
static const char __pyx_k_cop[] = "cop";
static const char __pyx_k_dep[] = "dep";
static const char __pyx_k_det[] = "det";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_neg[] = "neg";
static const char __pyx_k_num[] = "num";
static const char __pyx_k_obj[] = "obj";
static const char __pyx_k_obl[] = "obl";
static const char __pyx_k_prt[] = "prt";
static const char __pyx_k_CONJ[] = "CONJ";
static const char __pyx_k_DATE[] = "DATE";
static const char __pyx_k_HEAD[] = "HEAD";
static const char __pyx_k_INTJ[] = "INTJ";
static const char __pyx_k_LANG[] = "LANG";
static const char __pyx_k_NORM[] = "NORM";
static const char __pyx_k_NORP[] = "NORP";
static const char __pyx_k_NOUN[] = "NOUN";
static const char __pyx_k_ORTH[] = "ORTH";
static const char __pyx_k_PART[] = "PART";
static const char __pyx_k_PROB[] = "PROB";
static const char __pyx_k_PRON[] = "PRON";
static const char __pyx_k_TIME[] = "TIME";
static const char __pyx_k_VERB[] = "VERB";
static const char __pyx_k_amod[] = "amod";
static const char __pyx_k_attr[] = "attr";
static const char __pyx_k_conj[] = "conj";
static const char __pyx_k_dobj[] = "dobj";
static const char __pyx_k_expl[] = "expl";
static const char __pyx_k_hmod[] = "hmod";
static const char __pyx_k_hyph[] = "hyph";
static const char __pyx_k_intj[] = "intj";
static const char __pyx_k_iobj[] = "iobj";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mark[] = "mark";
static const char __pyx_k_meta[] = "meta";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_nmod[] = "nmod";
static const char __pyx_k_oprd[] = "oprd";
static const char __pyx_k_pobj[] = "pobj";
static const char __pyx_k_poss[] = "poss";
static const char __pyx_k_prep[] = "prep";
static const char __pyx_k_root[] = "root";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_CCONJ[] = "CCONJ";
static const char __pyx_k_EVENT[] = "EVENT";
static const char __pyx_k_LEMMA[] = "LEMMA";
static const char __pyx_k_LOWER[] = "LOWER";
static const char __pyx_k_MONEY[] = "MONEY";
static const char __pyx_k_MORPH[] = "MORPH";
static const char __pyx_k_NAMES[] = "NAMES";
static const char __pyx_k_PROPN[] = "PROPN";
static const char __pyx_k_PUNCT[] = "PUNCT";
static const char __pyx_k_SCONJ[] = "SCONJ";
static const char __pyx_k_SHAPE[] = "SHAPE";
static const char __pyx_k_SPACE[] = "SPACE";
static const char __pyx_k_SPACY[] = "SPACY";
static const char __pyx_k_acomp[] = "acomp";
static const char __pyx_k_advcl[] = "advcl";
static const char __pyx_k_agent[] = "agent";
static const char __pyx_k_appos[] = "appos";
static const char __pyx_k_ccomp[] = "ccomp";
static const char __pyx_k_csubj[] = "csubj";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_nsubj[] = "nsubj";
static const char __pyx_k_pcomp[] = "pcomp";
static const char __pyx_k_punct[] = "punct";
static const char __pyx_k_rcmod[] = "rcmod";
static const char __pyx_k_relcl[] = "relcl";
static const char __pyx_k_xcomp[] = "xcomp";
static const char __pyx_k_ENT_ID[] = "ENT_ID";
static const char __pyx_k_FLAG19[] = "FLAG19";
static const char __pyx_k_FLAG20[] = "FLAG20";
static const char __pyx_k_FLAG21[] = "FLAG21";
static const char __pyx_k_FLAG22[] = "FLAG22";
static const char __pyx_k_FLAG23[] = "FLAG23";
static const char __pyx_k_FLAG24[] = "FLAG24";
static const char __pyx_k_FLAG25[] = "FLAG25";
static const char __pyx_k_FLAG26[] = "FLAG26";
static const char __pyx_k_FLAG27[] = "FLAG27";
static const char __pyx_k_FLAG28[] = "FLAG28";
static const char __pyx_k_FLAG29[] = "FLAG29";
static const char __pyx_k_FLAG30[] = "FLAG30";
static const char __pyx_k_FLAG31[] = "FLAG31";
static const char __pyx_k_FLAG32[] = "FLAG32";
static const char __pyx_k_FLAG33[] = "FLAG33";
static const char __pyx_k_FLAG34[] = "FLAG34";
static const char __pyx_k_FLAG35[] = "FLAG35";
static const char __pyx_k_FLAG36[] = "FLAG36";
static const char __pyx_k_FLAG37[] = "FLAG37";
static const char __pyx_k_FLAG38[] = "FLAG38";
static const char __pyx_k_FLAG39[] = "FLAG39";
static const char __pyx_k_FLAG40[] = "FLAG40";
static const char __pyx_k_FLAG41[] = "FLAG41";
static const char __pyx_k_FLAG42[] = "FLAG42";
static const char __pyx_k_FLAG43[] = "FLAG43";
static const char __pyx_k_FLAG44[] = "FLAG44";
static const char __pyx_k_FLAG45[] = "FLAG45";
static const char __pyx_k_FLAG46[] = "FLAG46";
static const char __pyx_k_FLAG47[] = "FLAG47";
static const char __pyx_k_FLAG48[] = "FLAG48";
static const char __pyx_k_FLAG49[] = "FLAG49";
static const char __pyx_k_FLAG50[] = "FLAG50";
static const char __pyx_k_FLAG51[] = "FLAG51";
static const char __pyx_k_FLAG52[] = "FLAG52";
static const char __pyx_k_FLAG53[] = "FLAG53";
static const char __pyx_k_FLAG54[] = "FLAG54";
static const char __pyx_k_FLAG55[] = "FLAG55";
static const char __pyx_k_FLAG56[] = "FLAG56";
static const char __pyx_k_FLAG57[] = "FLAG57";
static const char __pyx_k_FLAG58[] = "FLAG58";
static const char __pyx_k_FLAG59[] = "FLAG59";
static const char __pyx_k_FLAG60[] = "FLAG60";
static const char __pyx_k_FLAG61[] = "FLAG61";
static const char __pyx_k_FLAG62[] = "FLAG62";
static const char __pyx_k_FLAG63[] = "FLAG63";
static const char __pyx_k_LENGTH[] = "LENGTH";
static const char __pyx_k_PERSON[] = "PERSON";
static const char __pyx_k_PREFIX[] = "PREFIX";
static const char __pyx_k_SUFFIX[] = "SUFFIX";
static const char __pyx_k_advmod[] = "advmod";
static const char __pyx_k_complm[] = "complm";
static const char __pyx_k_infmod[] = "infmod";
static const char __pyx_k_number[] = "number";
static const char __pyx_k_sorted[] = "sorted";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_CLUSTER[] = "CLUSTER";
static const char __pyx_k_ENT_IOB[] = "ENT_IOB";
static const char __pyx_k_IS_STOP[] = "IS_STOP";
static const char __pyx_k_ORDINAL[] = "ORDINAL";
static const char __pyx_k_PERCENT[] = "PERCENT";
static const char __pyx_k_PRODUCT[] = "PRODUCT";
static const char __pyx_k_auxpass[] = "auxpass";
static const char __pyx_k_partmod[] = "partmod";
static const char __pyx_k_preconj[] = "preconj";
static const char __pyx_k_CARDINAL[] = "CARDINAL";
static const char __pyx_k_ENT_TYPE[] = "ENT_TYPE";
static const char __pyx_k_FACILITY[] = "FACILITY";
static const char __pyx_k_IS_ALPHA[] = "IS_ALPHA";
static const char __pyx_k_IS_ASCII[] = "IS_ASCII";
static const char __pyx_k_IS_DIGIT[] = "IS_DIGIT";
static const char __pyx_k_IS_LOWER[] = "IS_LOWER";
static const char __pyx_k_IS_PUNCT[] = "IS_PUNCT";
static const char __pyx_k_IS_QUOTE[] = "IS_QUOTE";
static const char __pyx_k_IS_SPACE[] = "IS_SPACE";
static const char __pyx_k_IS_TITLE[] = "IS_TITLE";
static const char __pyx_k_IS_UPPER[] = "IS_UPPER";
static const char __pyx_k_LANGUAGE[] = "LANGUAGE";
static const char __pyx_k_LIKE_NUM[] = "LIKE_NUM";
static const char __pyx_k_LIKE_URL[] = "LIKE_URL";
static const char __pyx_k_QUANTITY[] = "QUANTITY";
static const char __pyx_k_npadvmod[] = "npadvmod";
static const char __pyx_k_quantmod[] = "quantmod";
static const char __pyx_k_ENT_KB_ID[] = "ENT_KB_ID";
static const char __pyx_k_csubjpass[] = "csubjpass";
static const char __pyx_k_nsubjpass[] = "nsubjpass";
static const char __pyx_k_parataxis[] = "parataxis";
static const char __pyx_k_sort_nums[] = "sort_nums";
static const char __pyx_k_IS_BRACKET[] = "IS_BRACKET";
static const char __pyx_k_LIKE_EMAIL[] = "LIKE_EMAIL";
static const char __pyx_k_SENT_START[] = "SENT_START";
static const char __pyx_k_possessive[] = "possessive";
static const char __pyx_k_IS_CURRENCY[] = "IS_CURRENCY";
static const char __pyx_k_WORK_OF_ART[] = "WORK_OF_ART";
static const char __pyx_k_DEPRECATED001[] = "DEPRECATED001";
static const char __pyx_k_DEPRECATED002[] = "DEPRECATED002";
static const char __pyx_k_DEPRECATED003[] = "DEPRECATED003";
static const char __pyx_k_DEPRECATED004[] = "DEPRECATED004";
static const char __pyx_k_DEPRECATED005[] = "DEPRECATED005";
static const char __pyx_k_DEPRECATED006[] = "DEPRECATED006";
static const char __pyx_k_DEPRECATED007[] = "DEPRECATED007";
static const char __pyx_k_DEPRECATED008[] = "DEPRECATED008";
static const char __pyx_k_DEPRECATED009[] = "DEPRECATED009";
static const char __pyx_k_DEPRECATED010[] = "DEPRECATED010";
static const char __pyx_k_DEPRECATED011[] = "DEPRECATED011";
static const char __pyx_k_DEPRECATED012[] = "DEPRECATED012";
static const char __pyx_k_DEPRECATED013[] = "DEPRECATED013";
static const char __pyx_k_DEPRECATED014[] = "DEPRECATED014";
static const char __pyx_k_DEPRECATED015[] = "DEPRECATED015";
static const char __pyx_k_DEPRECATED016[] = "DEPRECATED016";
static const char __pyx_k_DEPRECATED017[] = "DEPRECATED017";
static const char __pyx_k_DEPRECATED018[] = "DEPRECATED018";
static const char __pyx_k_DEPRECATED019[] = "DEPRECATED019";
static const char __pyx_k_DEPRECATED020[] = "DEPRECATED020";
static const char __pyx_k_DEPRECATED021[] = "DEPRECATED021";
static const char __pyx_k_DEPRECATED022[] = "DEPRECATED022";
static const char __pyx_k_DEPRECATED023[] = "DEPRECATED023";
static const char __pyx_k_DEPRECATED024[] = "DEPRECATED024";
static const char __pyx_k_DEPRECATED025[] = "DEPRECATED025";
static const char __pyx_k_DEPRECATED026[] = "DEPRECATED026";
static const char __pyx_k_DEPRECATED027[] = "DEPRECATED027";
static const char __pyx_k_DEPRECATED028[] = "DEPRECATED028";
static const char __pyx_k_DEPRECATED029[] = "DEPRECATED029";
static const char __pyx_k_DEPRECATED030[] = "DEPRECATED030";
static const char __pyx_k_DEPRECATED031[] = "DEPRECATED031";
static const char __pyx_k_DEPRECATED032[] = "DEPRECATED032";
static const char __pyx_k_DEPRECATED033[] = "DEPRECATED033";
static const char __pyx_k_DEPRECATED034[] = "DEPRECATED034";
static const char __pyx_k_DEPRECATED035[] = "DEPRECATED035";
static const char __pyx_k_DEPRECATED036[] = "DEPRECATED036";
static const char __pyx_k_DEPRECATED037[] = "DEPRECATED037";
static const char __pyx_k_DEPRECATED038[] = "DEPRECATED038";
static const char __pyx_k_DEPRECATED039[] = "DEPRECATED039";
static const char __pyx_k_DEPRECATED040[] = "DEPRECATED040";
static const char __pyx_k_DEPRECATED041[] = "DEPRECATED041";
static const char __pyx_k_DEPRECATED042[] = "DEPRECATED042";
static const char __pyx_k_DEPRECATED043[] = "DEPRECATED043";
static const char __pyx_k_DEPRECATED044[] = "DEPRECATED044";
static const char __pyx_k_DEPRECATED045[] = "DEPRECATED045";
static const char __pyx_k_DEPRECATED046[] = "DEPRECATED046";
static const char __pyx_k_DEPRECATED047[] = "DEPRECATED047";
static const char __pyx_k_DEPRECATED048[] = "DEPRECATED048";
static const char __pyx_k_DEPRECATED049[] = "DEPRECATED049";
static const char __pyx_k_DEPRECATED050[] = "DEPRECATED050";
static const char __pyx_k_DEPRECATED051[] = "DEPRECATED051";
static const char __pyx_k_DEPRECATED052[] = "DEPRECATED052";
static const char __pyx_k_DEPRECATED053[] = "DEPRECATED053";
static const char __pyx_k_DEPRECATED054[] = "DEPRECATED054";
static const char __pyx_k_DEPRECATED055[] = "DEPRECATED055";
static const char __pyx_k_DEPRECATED056[] = "DEPRECATED056";
static const char __pyx_k_DEPRECATED057[] = "DEPRECATED057";
static const char __pyx_k_DEPRECATED058[] = "DEPRECATED058";
static const char __pyx_k_DEPRECATED059[] = "DEPRECATED059";
static const char __pyx_k_DEPRECATED060[] = "DEPRECATED060";
static const char __pyx_k_DEPRECATED061[] = "DEPRECATED061";
static const char __pyx_k_DEPRECATED062[] = "DEPRECATED062";
static const char __pyx_k_DEPRECATED063[] = "DEPRECATED063";
static const char __pyx_k_DEPRECATED064[] = "DEPRECATED064";
static const char __pyx_k_DEPRECATED065[] = "DEPRECATED065";
static const char __pyx_k_DEPRECATED066[] = "DEPRECATED066";
static const char __pyx_k_DEPRECATED067[] = "DEPRECATED067";
static const char __pyx_k_DEPRECATED068[] = "DEPRECATED068";
static const char __pyx_k_DEPRECATED069[] = "DEPRECATED069";
static const char __pyx_k_DEPRECATED070[] = "DEPRECATED070";
static const char __pyx_k_DEPRECATED071[] = "DEPRECATED071";
static const char __pyx_k_DEPRECATED072[] = "DEPRECATED072";
static const char __pyx_k_DEPRECATED073[] = "DEPRECATED073";
static const char __pyx_k_DEPRECATED074[] = "DEPRECATED074";
static const char __pyx_k_DEPRECATED075[] = "DEPRECATED075";
static const char __pyx_k_DEPRECATED076[] = "DEPRECATED076";
static const char __pyx_k_DEPRECATED077[] = "DEPRECATED077";
static const char __pyx_k_DEPRECATED078[] = "DEPRECATED078";
static const char __pyx_k_DEPRECATED079[] = "DEPRECATED079";
static const char __pyx_k_DEPRECATED080[] = "DEPRECATED080";
static const char __pyx_k_DEPRECATED081[] = "DEPRECATED081";
static const char __pyx_k_DEPRECATED082[] = "DEPRECATED082";
static const char __pyx_k_DEPRECATED083[] = "DEPRECATED083";
static const char __pyx_k_DEPRECATED084[] = "DEPRECATED084";
static const char __pyx_k_DEPRECATED085[] = "DEPRECATED085";
static const char __pyx_k_DEPRECATED086[] = "DEPRECATED086";
static const char __pyx_k_DEPRECATED087[] = "DEPRECATED087";
static const char __pyx_k_DEPRECATED088[] = "DEPRECATED088";
static const char __pyx_k_DEPRECATED089[] = "DEPRECATED089";
static const char __pyx_k_DEPRECATED090[] = "DEPRECATED090";
static const char __pyx_k_DEPRECATED091[] = "DEPRECATED091";
static const char __pyx_k_DEPRECATED092[] = "DEPRECATED092";
static const char __pyx_k_DEPRECATED093[] = "DEPRECATED093";
static const char __pyx_k_DEPRECATED094[] = "DEPRECATED094";
static const char __pyx_k_DEPRECATED095[] = "DEPRECATED095";
static const char __pyx_k_DEPRECATED096[] = "DEPRECATED096";
static const char __pyx_k_DEPRECATED097[] = "DEPRECATED097";
static const char __pyx_k_DEPRECATED098[] = "DEPRECATED098";
static const char __pyx_k_DEPRECATED099[] = "DEPRECATED099";
static const char __pyx_k_DEPRECATED100[] = "DEPRECATED100";
static const char __pyx_k_DEPRECATED101[] = "DEPRECATED101";
static const char __pyx_k_DEPRECATED102[] = "DEPRECATED102";
static const char __pyx_k_DEPRECATED103[] = "DEPRECATED103";
static const char __pyx_k_DEPRECATED104[] = "DEPRECATED104";
static const char __pyx_k_DEPRECATED105[] = "DEPRECATED105";
static const char __pyx_k_DEPRECATED106[] = "DEPRECATED106";
static const char __pyx_k_DEPRECATED107[] = "DEPRECATED107";
static const char __pyx_k_DEPRECATED108[] = "DEPRECATED108";
static const char __pyx_k_DEPRECATED109[] = "DEPRECATED109";
static const char __pyx_k_DEPRECATED110[] = "DEPRECATED110";
static const char __pyx_k_DEPRECATED111[] = "DEPRECATED111";
static const char __pyx_k_DEPRECATED112[] = "DEPRECATED112";
static const char __pyx_k_DEPRECATED113[] = "DEPRECATED113";
static const char __pyx_k_DEPRECATED114[] = "DEPRECATED114";
static const char __pyx_k_DEPRECATED115[] = "DEPRECATED115";
static const char __pyx_k_DEPRECATED116[] = "DEPRECATED116";
static const char __pyx_k_DEPRECATED117[] = "DEPRECATED117";
static const char __pyx_k_DEPRECATED118[] = "DEPRECATED118";
static const char __pyx_k_DEPRECATED119[] = "DEPRECATED119";
static const char __pyx_k_DEPRECATED120[] = "DEPRECATED120";
static const char __pyx_k_DEPRECATED121[] = "DEPRECATED121";
static const char __pyx_k_DEPRECATED122[] = "DEPRECATED122";
static const char __pyx_k_DEPRECATED123[] = "DEPRECATED123";
static const char __pyx_k_DEPRECATED124[] = "DEPRECATED124";
static const char __pyx_k_DEPRECATED125[] = "DEPRECATED125";
static const char __pyx_k_DEPRECATED126[] = "DEPRECATED126";
static const char __pyx_k_DEPRECATED127[] = "DEPRECATED127";
static const char __pyx_k_DEPRECATED128[] = "DEPRECATED128";
static const char __pyx_k_DEPRECATED129[] = "DEPRECATED129";
static const char __pyx_k_DEPRECATED130[] = "DEPRECATED130";
static const char __pyx_k_DEPRECATED131[] = "DEPRECATED131";
static const char __pyx_k_DEPRECATED132[] = "DEPRECATED132";
static const char __pyx_k_DEPRECATED133[] = "DEPRECATED133";
static const char __pyx_k_DEPRECATED134[] = "DEPRECATED134";
static const char __pyx_k_DEPRECATED135[] = "DEPRECATED135";
static const char __pyx_k_DEPRECATED136[] = "DEPRECATED136";
static const char __pyx_k_DEPRECATED137[] = "DEPRECATED137";
static const char __pyx_k_DEPRECATED138[] = "DEPRECATED138";
static const char __pyx_k_DEPRECATED139[] = "DEPRECATED139";
static const char __pyx_k_DEPRECATED140[] = "DEPRECATED140";
static const char __pyx_k_DEPRECATED141[] = "DEPRECATED141";
static const char __pyx_k_DEPRECATED142[] = "DEPRECATED142";
static const char __pyx_k_DEPRECATED143[] = "DEPRECATED143";
static const char __pyx_k_DEPRECATED144[] = "DEPRECATED144";
static const char __pyx_k_DEPRECATED145[] = "DEPRECATED145";
static const char __pyx_k_DEPRECATED146[] = "DEPRECATED146";
static const char __pyx_k_DEPRECATED147[] = "DEPRECATED147";
static const char __pyx_k_DEPRECATED148[] = "DEPRECATED148";
static const char __pyx_k_DEPRECATED149[] = "DEPRECATED149";
static const char __pyx_k_DEPRECATED150[] = "DEPRECATED150";
static const char __pyx_k_DEPRECATED151[] = "DEPRECATED151";
static const char __pyx_k_DEPRECATED152[] = "DEPRECATED152";
static const char __pyx_k_DEPRECATED153[] = "DEPRECATED153";
static const char __pyx_k_DEPRECATED154[] = "DEPRECATED154";
static const char __pyx_k_DEPRECATED155[] = "DEPRECATED155";
static const char __pyx_k_DEPRECATED156[] = "DEPRECATED156";
static const char __pyx_k_DEPRECATED157[] = "DEPRECATED157";
static const char __pyx_k_DEPRECATED158[] = "DEPRECATED158";
static const char __pyx_k_DEPRECATED159[] = "DEPRECATED159";
static const char __pyx_k_DEPRECATED160[] = "DEPRECATED160";
static const char __pyx_k_DEPRECATED161[] = "DEPRECATED161";
static const char __pyx_k_DEPRECATED162[] = "DEPRECATED162";
static const char __pyx_k_DEPRECATED163[] = "DEPRECATED163";
static const char __pyx_k_DEPRECATED164[] = "DEPRECATED164";
static const char __pyx_k_DEPRECATED165[] = "DEPRECATED165";
static const char __pyx_k_DEPRECATED166[] = "DEPRECATED166";
static const char __pyx_k_DEPRECATED167[] = "DEPRECATED167";
static const char __pyx_k_DEPRECATED168[] = "DEPRECATED168";
static const char __pyx_k_DEPRECATED169[] = "DEPRECATED169";
static const char __pyx_k_DEPRECATED170[] = "DEPRECATED170";
static const char __pyx_k_DEPRECATED171[] = "DEPRECATED171";
static const char __pyx_k_DEPRECATED172[] = "DEPRECATED172";
static const char __pyx_k_DEPRECATED173[] = "DEPRECATED173";
static const char __pyx_k_DEPRECATED174[] = "DEPRECATED174";
static const char __pyx_k_DEPRECATED175[] = "DEPRECATED175";
static const char __pyx_k_DEPRECATED176[] = "DEPRECATED176";
static const char __pyx_k_DEPRECATED177[] = "DEPRECATED177";
static const char __pyx_k_DEPRECATED178[] = "DEPRECATED178";
static const char __pyx_k_DEPRECATED179[] = "DEPRECATED179";
static const char __pyx_k_DEPRECATED180[] = "DEPRECATED180";
static const char __pyx_k_DEPRECATED181[] = "DEPRECATED181";
static const char __pyx_k_DEPRECATED182[] = "DEPRECATED182";
static const char __pyx_k_DEPRECATED183[] = "DEPRECATED183";
static const char __pyx_k_DEPRECATED184[] = "DEPRECATED184";
static const char __pyx_k_DEPRECATED185[] = "DEPRECATED185";
static const char __pyx_k_DEPRECATED186[] = "DEPRECATED186";
static const char __pyx_k_DEPRECATED187[] = "DEPRECATED187";
static const char __pyx_k_DEPRECATED188[] = "DEPRECATED188";
static const char __pyx_k_DEPRECATED189[] = "DEPRECATED189";
static const char __pyx_k_DEPRECATED190[] = "DEPRECATED190";
static const char __pyx_k_DEPRECATED191[] = "DEPRECATED191";
static const char __pyx_k_DEPRECATED192[] = "DEPRECATED192";
static const char __pyx_k_DEPRECATED193[] = "DEPRECATED193";
static const char __pyx_k_DEPRECATED194[] = "DEPRECATED194";
static const char __pyx_k_DEPRECATED195[] = "DEPRECATED195";
static const char __pyx_k_DEPRECATED196[] = "DEPRECATED196";
static const char __pyx_k_DEPRECATED197[] = "DEPRECATED197";
static const char __pyx_k_DEPRECATED198[] = "DEPRECATED198";
static const char __pyx_k_DEPRECATED199[] = "DEPRECATED199";
static const char __pyx_k_DEPRECATED200[] = "DEPRECATED200";
static const char __pyx_k_DEPRECATED201[] = "DEPRECATED201";
static const char __pyx_k_DEPRECATED202[] = "DEPRECATED202";
static const char __pyx_k_DEPRECATED203[] = "DEPRECATED203";
static const char __pyx_k_DEPRECATED204[] = "DEPRECATED204";
static const char __pyx_k_DEPRECATED205[] = "DEPRECATED205";
static const char __pyx_k_DEPRECATED206[] = "DEPRECATED206";
static const char __pyx_k_DEPRECATED207[] = "DEPRECATED207";
static const char __pyx_k_DEPRECATED208[] = "DEPRECATED208";
static const char __pyx_k_DEPRECATED209[] = "DEPRECATED209";
static const char __pyx_k_DEPRECATED210[] = "DEPRECATED210";
static const char __pyx_k_DEPRECATED211[] = "DEPRECATED211";
static const char __pyx_k_DEPRECATED212[] = "DEPRECATED212";
static const char __pyx_k_DEPRECATED213[] = "DEPRECATED213";
static const char __pyx_k_DEPRECATED214[] = "DEPRECATED214";
static const char __pyx_k_DEPRECATED215[] = "DEPRECATED215";
static const char __pyx_k_DEPRECATED216[] = "DEPRECATED216";
static const char __pyx_k_DEPRECATED217[] = "DEPRECATED217";
static const char __pyx_k_DEPRECATED218[] = "DEPRECATED218";
static const char __pyx_k_DEPRECATED219[] = "DEPRECATED219";
static const char __pyx_k_DEPRECATED220[] = "DEPRECATED220";
static const char __pyx_k_DEPRECATED221[] = "DEPRECATED221";
static const char __pyx_k_DEPRECATED222[] = "DEPRECATED222";
static const char __pyx_k_DEPRECATED223[] = "DEPRECATED223";
static const char __pyx_k_DEPRECATED224[] = "DEPRECATED224";
static const char __pyx_k_DEPRECATED225[] = "DEPRECATED225";
static const char __pyx_k_DEPRECATED226[] = "DEPRECATED226";
static const char __pyx_k_DEPRECATED227[] = "DEPRECATED227";
static const char __pyx_k_DEPRECATED228[] = "DEPRECATED228";
static const char __pyx_k_DEPRECATED229[] = "DEPRECATED229";
static const char __pyx_k_DEPRECATED230[] = "DEPRECATED230";
static const char __pyx_k_DEPRECATED231[] = "DEPRECATED231";
static const char __pyx_k_DEPRECATED232[] = "DEPRECATED232";
static const char __pyx_k_DEPRECATED233[] = "DEPRECATED233";
static const char __pyx_k_DEPRECATED234[] = "DEPRECATED234";
static const char __pyx_k_DEPRECATED235[] = "DEPRECATED235";
static const char __pyx_k_DEPRECATED236[] = "DEPRECATED236";
static const char __pyx_k_DEPRECATED237[] = "DEPRECATED237";
static const char __pyx_k_DEPRECATED238[] = "DEPRECATED238";
static const char __pyx_k_DEPRECATED239[] = "DEPRECATED239";
static const char __pyx_k_DEPRECATED240[] = "DEPRECATED240";
static const char __pyx_k_DEPRECATED241[] = "DEPRECATED241";
static const char __pyx_k_DEPRECATED242[] = "DEPRECATED242";
static const char __pyx_k_DEPRECATED243[] = "DEPRECATED243";
static const char __pyx_k_DEPRECATED244[] = "DEPRECATED244";
static const char __pyx_k_DEPRECATED245[] = "DEPRECATED245";
static const char __pyx_k_DEPRECATED246[] = "DEPRECATED246";
static const char __pyx_k_DEPRECATED247[] = "DEPRECATED247";
static const char __pyx_k_DEPRECATED248[] = "DEPRECATED248";
static const char __pyx_k_DEPRECATED249[] = "DEPRECATED249";
static const char __pyx_k_DEPRECATED250[] = "DEPRECATED250";
static const char __pyx_k_DEPRECATED251[] = "DEPRECATED251";
static const char __pyx_k_DEPRECATED252[] = "DEPRECATED252";
static const char __pyx_k_DEPRECATED253[] = "DEPRECATED253";
static const char __pyx_k_DEPRECATED254[] = "DEPRECATED254";
static const char __pyx_k_DEPRECATED255[] = "DEPRECATED255";
static const char __pyx_k_DEPRECATED256[] = "DEPRECATED256";
static const char __pyx_k_DEPRECATED257[] = "DEPRECATED257";
static const char __pyx_k_DEPRECATED258[] = "DEPRECATED258";
static const char __pyx_k_DEPRECATED259[] = "DEPRECATED259";
static const char __pyx_k_DEPRECATED260[] = "DEPRECATED260";
static const char __pyx_k_DEPRECATED261[] = "DEPRECATED261";
static const char __pyx_k_DEPRECATED262[] = "DEPRECATED262";
static const char __pyx_k_DEPRECATED263[] = "DEPRECATED263";
static const char __pyx_k_DEPRECATED264[] = "DEPRECATED264";
static const char __pyx_k_DEPRECATED265[] = "DEPRECATED265";
static const char __pyx_k_DEPRECATED266[] = "DEPRECATED266";
static const char __pyx_k_DEPRECATED267[] = "DEPRECATED267";
static const char __pyx_k_DEPRECATED268[] = "DEPRECATED268";
static const char __pyx_k_DEPRECATED269[] = "DEPRECATED269";
static const char __pyx_k_DEPRECATED270[] = "DEPRECATED270";
static const char __pyx_k_DEPRECATED271[] = "DEPRECATED271";
static const char __pyx_k_DEPRECATED272[] = "DEPRECATED272";
static const char __pyx_k_DEPRECATED273[] = "DEPRECATED273";
static const char __pyx_k_DEPRECATED274[] = "DEPRECATED274";
static const char __pyx_k_DEPRECATED275[] = "DEPRECATED275";
static const char __pyx_k_DEPRECATED276[] = "DEPRECATED276";
static const char __pyx_k_IS_LEFT_PUNCT[] = "IS_LEFT_PUNCT";
static const char __pyx_k_spacy_symbols[] = "spacy.symbols";
static const char __pyx_k_IS_RIGHT_PUNCT[] = "IS_RIGHT_PUNCT";
static const char __pyx_k_IS_OOV_DEPRECATED[] = "IS_OOV_DEPRECATED";
static const char __pyx_k_spacy_symbols_pyx[] = "spacy\\symbols.pyx";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static PyObject *__pyx_kp_s_;
static PyObject *__pyx_n_s_ADJ;
static PyObject *__pyx_n_s_ADP;
static PyObject *__pyx_n_s_ADV;
static PyObject *__pyx_n_s_AUX;
static PyObject *__pyx_n_s_CARDINAL;
static PyObject *__pyx_n_s_CCONJ;
static PyObject *__pyx_n_s_CLUSTER;
static PyObject *__pyx_n_s_CONJ;
static PyObject *__pyx_n_s_DATE;
static PyObject *__pyx_n_s_DEP;
static PyObject *__pyx_n_s_DEPRECATED001;
static PyObject *__pyx_n_s_DEPRECATED002;
static PyObject *__pyx_n_s_DEPRECATED003;
static PyObject *__pyx_n_s_DEPRECATED004;
static PyObject *__pyx_n_s_DEPRECATED005;
static PyObject *__pyx_n_s_DEPRECATED006;
static PyObject *__pyx_n_s_DEPRECATED007;
static PyObject *__pyx_n_s_DEPRECATED008;
static PyObject *__pyx_n_s_DEPRECATED009;
static PyObject *__pyx_n_s_DEPRECATED010;
static PyObject *__pyx_n_s_DEPRECATED011;
static PyObject *__pyx_n_s_DEPRECATED012;
static PyObject *__pyx_n_s_DEPRECATED013;
static PyObject *__pyx_n_s_DEPRECATED014;
static PyObject *__pyx_n_s_DEPRECATED015;
static PyObject *__pyx_n_s_DEPRECATED016;
static PyObject *__pyx_n_s_DEPRECATED017;
static PyObject *__pyx_n_s_DEPRECATED018;
static PyObject *__pyx_n_s_DEPRECATED019;
static PyObject *__pyx_n_s_DEPRECATED020;
static PyObject *__pyx_n_s_DEPRECATED021;
static PyObject *__pyx_n_s_DEPRECATED022;
static PyObject *__pyx_n_s_DEPRECATED023;
static PyObject *__pyx_n_s_DEPRECATED024;
static PyObject *__pyx_n_s_DEPRECATED025;
static PyObject *__pyx_n_s_DEPRECATED026;
static PyObject *__pyx_n_s_DEPRECATED027;
static PyObject *__pyx_n_s_DEPRECATED028;
static PyObject *__pyx_n_s_DEPRECATED029;
static PyObject *__pyx_n_s_DEPRECATED030;
static PyObject *__pyx_n_s_DEPRECATED031;
static PyObject *__pyx_n_s_DEPRECATED032;
static PyObject *__pyx_n_s_DEPRECATED033;
static PyObject *__pyx_n_s_DEPRECATED034;
static PyObject *__pyx_n_s_DEPRECATED035;
static PyObject *__pyx_n_s_DEPRECATED036;
static PyObject *__pyx_n_s_DEPRECATED037;
static PyObject *__pyx_n_s_DEPRECATED038;
static PyObject *__pyx_n_s_DEPRECATED039;
static PyObject *__pyx_n_s_DEPRECATED040;
static PyObject *__pyx_n_s_DEPRECATED041;
static PyObject *__pyx_n_s_DEPRECATED042;
static PyObject *__pyx_n_s_DEPRECATED043;
static PyObject *__pyx_n_s_DEPRECATED044;
static PyObject *__pyx_n_s_DEPRECATED045;
static PyObject *__pyx_n_s_DEPRECATED046;
static PyObject *__pyx_n_s_DEPRECATED047;
static PyObject *__pyx_n_s_DEPRECATED048;
static PyObject *__pyx_n_s_DEPRECATED049;
static PyObject *__pyx_n_s_DEPRECATED050;
static PyObject *__pyx_n_s_DEPRECATED051;
static PyObject *__pyx_n_s_DEPRECATED052;
static PyObject *__pyx_n_s_DEPRECATED053;
static PyObject *__pyx_n_s_DEPRECATED054;
static PyObject *__pyx_n_s_DEPRECATED055;
static PyObject *__pyx_n_s_DEPRECATED056;
static PyObject *__pyx_n_s_DEPRECATED057;
static PyObject *__pyx_n_s_DEPRECATED058;
static PyObject *__pyx_n_s_DEPRECATED059;
static PyObject *__pyx_n_s_DEPRECATED060;
static PyObject *__pyx_n_s_DEPRECATED061;
static PyObject *__pyx_n_s_DEPRECATED062;
static PyObject *__pyx_n_s_DEPRECATED063;
static PyObject *__pyx_n_s_DEPRECATED064;
static PyObject *__pyx_n_s_DEPRECATED065;
static PyObject *__pyx_n_s_DEPRECATED066;
static PyObject *__pyx_n_s_DEPRECATED067;
static PyObject *__pyx_n_s_DEPRECATED068;
static PyObject *__pyx_n_s_DEPRECATED069;
static PyObject *__pyx_n_s_DEPRECATED070;
static PyObject *__pyx_n_s_DEPRECATED071;
static PyObject *__pyx_n_s_DEPRECATED072;
static PyObject *__pyx_n_s_DEPRECATED073;
static PyObject *__pyx_n_s_DEPRECATED074;
static PyObject *__pyx_n_s_DEPRECATED075;
static PyObject *__pyx_n_s_DEPRECATED076;
static PyObject *__pyx_n_s_DEPRECATED077;
static PyObject *__pyx_n_s_DEPRECATED078;
static PyObject *__pyx_n_s_DEPRECATED079;
static PyObject *__pyx_n_s_DEPRECATED080;
static PyObject *__pyx_n_s_DEPRECATED081;
static PyObject *__pyx_n_s_DEPRECATED082;
static PyObject *__pyx_n_s_DEPRECATED083;
static PyObject *__pyx_n_s_DEPRECATED084;
static PyObject *__pyx_n_s_DEPRECATED085;
static PyObject *__pyx_n_s_DEPRECATED086;
static PyObject *__pyx_n_s_DEPRECATED087;
static PyObject *__pyx_n_s_DEPRECATED088;
static PyObject *__pyx_n_s_DEPRECATED089;
static PyObject *__pyx_n_s_DEPRECATED090;
static PyObject *__pyx_n_s_DEPRECATED091;
static PyObject *__pyx_n_s_DEPRECATED092;
static PyObject *__pyx_n_s_DEPRECATED093;
static PyObject *__pyx_n_s_DEPRECATED094;
static PyObject *__pyx_n_s_DEPRECATED095;
static PyObject *__pyx_n_s_DEPRECATED096;
static PyObject *__pyx_n_s_DEPRECATED097;
static PyObject *__pyx_n_s_DEPRECATED098;
static PyObject *__pyx_n_s_DEPRECATED099;
static PyObject *__pyx_n_s_DEPRECATED100;
static PyObject *__pyx_n_s_DEPRECATED101;
static PyObject *__pyx_n_s_DEPRECATED102;
static PyObject *__pyx_n_s_DEPRECATED103;
static PyObject *__pyx_n_s_DEPRECATED104;
static PyObject *__pyx_n_s_DEPRECATED105;
static PyObject *__pyx_n_s_DEPRECATED106;
static PyObject *__pyx_n_s_DEPRECATED107;
static PyObject *__pyx_n_s_DEPRECATED108;
static PyObject *__pyx_n_s_DEPRECATED109;
static PyObject *__pyx_n_s_DEPRECATED110;
static PyObject *__pyx_n_s_DEPRECATED111;
static PyObject *__pyx_n_s_DEPRECATED112;
static PyObject *__pyx_n_s_DEPRECATED113;
static PyObject *__pyx_n_s_DEPRECATED114;
static PyObject *__pyx_n_s_DEPRECATED115;
static PyObject *__pyx_n_s_DEPRECATED116;
static PyObject *__pyx_n_s_DEPRECATED117;
static PyObject *__pyx_n_s_DEPRECATED118;
static PyObject *__pyx_n_s_DEPRECATED119;
static PyObject *__pyx_n_s_DEPRECATED120;
static PyObject *__pyx_n_s_DEPRECATED121;
static PyObject *__pyx_n_s_DEPRECATED122;
static PyObject *__pyx_n_s_DEPRECATED123;
static PyObject *__pyx_n_s_DEPRECATED124;
static PyObject *__pyx_n_s_DEPRECATED125;
static PyObject *__pyx_n_s_DEPRECATED126;
static PyObject *__pyx_n_s_DEPRECATED127;
static PyObject *__pyx_n_s_DEPRECATED128;
static PyObject *__pyx_n_s_DEPRECATED129;
static PyObject *__pyx_n_s_DEPRECATED130;
static PyObject *__pyx_n_s_DEPRECATED131;
static PyObject *__pyx_n_s_DEPRECATED132;
static PyObject *__pyx_n_s_DEPRECATED133;
static PyObject *__pyx_n_s_DEPRECATED134;
static PyObject *__pyx_n_s_DEPRECATED135;
static PyObject *__pyx_n_s_DEPRECATED136;
static PyObject *__pyx_n_s_DEPRECATED137;
static PyObject *__pyx_n_s_DEPRECATED138;
static PyObject *__pyx_n_s_DEPRECATED139;
static PyObject *__pyx_n_s_DEPRECATED140;
static PyObject *__pyx_n_s_DEPRECATED141;
static PyObject *__pyx_n_s_DEPRECATED142;
static PyObject *__pyx_n_s_DEPRECATED143;
static PyObject *__pyx_n_s_DEPRECATED144;
static PyObject *__pyx_n_s_DEPRECATED145;
static PyObject *__pyx_n_s_DEPRECATED146;
static PyObject *__pyx_n_s_DEPRECATED147;
static PyObject *__pyx_n_s_DEPRECATED148;
static PyObject *__pyx_n_s_DEPRECATED149;
static PyObject *__pyx_n_s_DEPRECATED150;
static PyObject *__pyx_n_s_DEPRECATED151;
static PyObject *__pyx_n_s_DEPRECATED152;
static PyObject *__pyx_n_s_DEPRECATED153;
static PyObject *__pyx_n_s_DEPRECATED154;
static PyObject *__pyx_n_s_DEPRECATED155;
static PyObject *__pyx_n_s_DEPRECATED156;
static PyObject *__pyx_n_s_DEPRECATED157;
static PyObject *__pyx_n_s_DEPRECATED158;
static PyObject *__pyx_n_s_DEPRECATED159;
static PyObject *__pyx_n_s_DEPRECATED160;
static PyObject *__pyx_n_s_DEPRECATED161;
static PyObject *__pyx_n_s_DEPRECATED162;
static PyObject *__pyx_n_s_DEPRECATED163;
static PyObject *__pyx_n_s_DEPRECATED164;
static PyObject *__pyx_n_s_DEPRECATED165;
static PyObject *__pyx_n_s_DEPRECATED166;
static PyObject *__pyx_n_s_DEPRECATED167;
static PyObject *__pyx_n_s_DEPRECATED168;
static PyObject *__pyx_n_s_DEPRECATED169;
static PyObject *__pyx_n_s_DEPRECATED170;
static PyObject *__pyx_n_s_DEPRECATED171;
static PyObject *__pyx_n_s_DEPRECATED172;
static PyObject *__pyx_n_s_DEPRECATED173;
static PyObject *__pyx_n_s_DEPRECATED174;
static PyObject *__pyx_n_s_DEPRECATED175;
static PyObject *__pyx_n_s_DEPRECATED176;
static PyObject *__pyx_n_s_DEPRECATED177;
static PyObject *__pyx_n_s_DEPRECATED178;
static PyObject *__pyx_n_s_DEPRECATED179;
static PyObject *__pyx_n_s_DEPRECATED180;
static PyObject *__pyx_n_s_DEPRECATED181;
static PyObject *__pyx_n_s_DEPRECATED182;
static PyObject *__pyx_n_s_DEPRECATED183;
static PyObject *__pyx_n_s_DEPRECATED184;
static PyObject *__pyx_n_s_DEPRECATED185;
static PyObject *__pyx_n_s_DEPRECATED186;
static PyObject *__pyx_n_s_DEPRECATED187;
static PyObject *__pyx_n_s_DEPRECATED188;
static PyObject *__pyx_n_s_DEPRECATED189;
static PyObject *__pyx_n_s_DEPRECATED190;
static PyObject *__pyx_n_s_DEPRECATED191;
static PyObject *__pyx_n_s_DEPRECATED192;
static PyObject *__pyx_n_s_DEPRECATED193;
static PyObject *__pyx_n_s_DEPRECATED194;
static PyObject *__pyx_n_s_DEPRECATED195;
static PyObject *__pyx_n_s_DEPRECATED196;
static PyObject *__pyx_n_s_DEPRECATED197;
static PyObject *__pyx_n_s_DEPRECATED198;
static PyObject *__pyx_n_s_DEPRECATED199;
static PyObject *__pyx_n_s_DEPRECATED200;
static PyObject *__pyx_n_s_DEPRECATED201;
static PyObject *__pyx_n_s_DEPRECATED202;
static PyObject *__pyx_n_s_DEPRECATED203;
static PyObject *__pyx_n_s_DEPRECATED204;
static PyObject *__pyx_n_s_DEPRECATED205;
static PyObject *__pyx_n_s_DEPRECATED206;
static PyObject *__pyx_n_s_DEPRECATED207;
static PyObject *__pyx_n_s_DEPRECATED208;
static PyObject *__pyx_n_s_DEPRECATED209;
static PyObject *__pyx_n_s_DEPRECATED210;
static PyObject *__pyx_n_s_DEPRECATED211;
static PyObject *__pyx_n_s_DEPRECATED212;
static PyObject *__pyx_n_s_DEPRECATED213;
static PyObject *__pyx_n_s_DEPRECATED214;
static PyObject *__pyx_n_s_DEPRECATED215;
static PyObject *__pyx_n_s_DEPRECATED216;
static PyObject *__pyx_n_s_DEPRECATED217;
static PyObject *__pyx_n_s_DEPRECATED218;
static PyObject *__pyx_n_s_DEPRECATED219;
static PyObject *__pyx_n_s_DEPRECATED220;
static PyObject *__pyx_n_s_DEPRECATED221;
static PyObject *__pyx_n_s_DEPRECATED222;
static PyObject *__pyx_n_s_DEPRECATED223;
static PyObject *__pyx_n_s_DEPRECATED224;
static PyObject *__pyx_n_s_DEPRECATED225;
static PyObject *__pyx_n_s_DEPRECATED226;
static PyObject *__pyx_n_s_DEPRECATED227;
static PyObject *__pyx_n_s_DEPRECATED228;
static PyObject *__pyx_n_s_DEPRECATED229;
static PyObject *__pyx_n_s_DEPRECATED230;
static PyObject *__pyx_n_s_DEPRECATED231;
static PyObject *__pyx_n_s_DEPRECATED232;
static PyObject *__pyx_n_s_DEPRECATED233;
static PyObject *__pyx_n_s_DEPRECATED234;
static PyObject *__pyx_n_s_DEPRECATED235;
static PyObject *__pyx_n_s_DEPRECATED236;
static PyObject *__pyx_n_s_DEPRECATED237;
static PyObject *__pyx_n_s_DEPRECATED238;
static PyObject *__pyx_n_s_DEPRECATED239;
static PyObject *__pyx_n_s_DEPRECATED240;
static PyObject *__pyx_n_s_DEPRECATED241;
static PyObject *__pyx_n_s_DEPRECATED242;
static PyObject *__pyx_n_s_DEPRECATED243;
static PyObject *__pyx_n_s_DEPRECATED244;
static PyObject *__pyx_n_s_DEPRECATED245;
static PyObject *__pyx_n_s_DEPRECATED246;
static PyObject *__pyx_n_s_DEPRECATED247;
static PyObject *__pyx_n_s_DEPRECATED248;
static PyObject *__pyx_n_s_DEPRECATED249;
static PyObject *__pyx_n_s_DEPRECATED250;
static PyObject *__pyx_n_s_DEPRECATED251;
static PyObject *__pyx_n_s_DEPRECATED252;
static PyObject *__pyx_n_s_DEPRECATED253;
static PyObject *__pyx_n_s_DEPRECATED254;
static PyObject *__pyx_n_s_DEPRECATED255;
static PyObject *__pyx_n_s_DEPRECATED256;
static PyObject *__pyx_n_s_DEPRECATED257;
static PyObject *__pyx_n_s_DEPRECATED258;
static PyObject *__pyx_n_s_DEPRECATED259;
static PyObject *__pyx_n_s_DEPRECATED260;
static PyObject *__pyx_n_s_DEPRECATED261;
static PyObject *__pyx_n_s_DEPRECATED262;
static PyObject *__pyx_n_s_DEPRECATED263;
static PyObject *__pyx_n_s_DEPRECATED264;
static PyObject *__pyx_n_s_DEPRECATED265;
static PyObject *__pyx_n_s_DEPRECATED266;
static PyObject *__pyx_n_s_DEPRECATED267;
static PyObject *__pyx_n_s_DEPRECATED268;
static PyObject *__pyx_n_s_DEPRECATED269;
static PyObject *__pyx_n_s_DEPRECATED270;
static PyObject *__pyx_n_s_DEPRECATED271;
static PyObject *__pyx_n_s_DEPRECATED272;
static PyObject *__pyx_n_s_DEPRECATED273;
static PyObject *__pyx_n_s_DEPRECATED274;
static PyObject *__pyx_n_s_DEPRECATED275;
static PyObject *__pyx_n_s_DEPRECATED276;
static PyObject *__pyx_n_s_DET;
static PyObject *__pyx_n_s_ENT_ID;
static PyObject *__pyx_n_s_ENT_IOB;
static PyObject *__pyx_n_s_ENT_KB_ID;
static PyObject *__pyx_n_s_ENT_TYPE;
static PyObject *__pyx_n_s_EOL;
static PyObject *__pyx_n_s_EVENT;
static PyObject *__pyx_n_s_FACILITY;
static PyObject *__pyx_n_s_FLAG19;
static PyObject *__pyx_n_s_FLAG20;
static PyObject *__pyx_n_s_FLAG21;
static PyObject *__pyx_n_s_FLAG22;
static PyObject *__pyx_n_s_FLAG23;
static PyObject *__pyx_n_s_FLAG24;
static PyObject *__pyx_n_s_FLAG25;
static PyObject *__pyx_n_s_FLAG26;
static PyObject *__pyx_n_s_FLAG27;
static PyObject *__pyx_n_s_FLAG28;
static PyObject *__pyx_n_s_FLAG29;
static PyObject *__pyx_n_s_FLAG30;
static PyObject *__pyx_n_s_FLAG31;
static PyObject *__pyx_n_s_FLAG32;
static PyObject *__pyx_n_s_FLAG33;
static PyObject *__pyx_n_s_FLAG34;
static PyObject *__pyx_n_s_FLAG35;
static PyObject *__pyx_n_s_FLAG36;
static PyObject *__pyx_n_s_FLAG37;
static PyObject *__pyx_n_s_FLAG38;
static PyObject *__pyx_n_s_FLAG39;
static PyObject *__pyx_n_s_FLAG40;
static PyObject *__pyx_n_s_FLAG41;
static PyObject *__pyx_n_s_FLAG42;
static PyObject *__pyx_n_s_FLAG43;
static PyObject *__pyx_n_s_FLAG44;
static PyObject *__pyx_n_s_FLAG45;
static PyObject *__pyx_n_s_FLAG46;
static PyObject *__pyx_n_s_FLAG47;
static PyObject *__pyx_n_s_FLAG48;
static PyObject *__pyx_n_s_FLAG49;
static PyObject *__pyx_n_s_FLAG50;
static PyObject *__pyx_n_s_FLAG51;
static PyObject *__pyx_n_s_FLAG52;
static PyObject *__pyx_n_s_FLAG53;
static PyObject *__pyx_n_s_FLAG54;
static PyObject *__pyx_n_s_FLAG55;
static PyObject *__pyx_n_s_FLAG56;
static PyObject *__pyx_n_s_FLAG57;
static PyObject *__pyx_n_s_FLAG58;
static PyObject *__pyx_n_s_FLAG59;
static PyObject *__pyx_n_s_FLAG60;
static PyObject *__pyx_n_s_FLAG61;
static PyObject *__pyx_n_s_FLAG62;
static PyObject *__pyx_n_s_FLAG63;
static PyObject *__pyx_n_s_GPE;
static PyObject *__pyx_n_s_HEAD;
static PyObject *__pyx_n_s_ID;
static PyObject *__pyx_n_s_IDS;
static PyObject *__pyx_n_s_IDX;
static PyObject *__pyx_n_s_INTJ;
static PyObject *__pyx_n_s_IS_ALPHA;
static PyObject *__pyx_n_s_IS_ASCII;
static PyObject *__pyx_n_s_IS_BRACKET;
static PyObject *__pyx_n_s_IS_CURRENCY;
static PyObject *__pyx_n_s_IS_DIGIT;
static PyObject *__pyx_n_s_IS_LEFT_PUNCT;
static PyObject *__pyx_n_s_IS_LOWER;
static PyObject *__pyx_n_s_IS_OOV_DEPRECATED;
static PyObject *__pyx_n_s_IS_PUNCT;
static PyObject *__pyx_n_s_IS_QUOTE;
static PyObject *__pyx_n_s_IS_RIGHT_PUNCT;
static PyObject *__pyx_n_s_IS_SPACE;
static PyObject *__pyx_n_s_IS_STOP;
static PyObject *__pyx_n_s_IS_TITLE;
static PyObject *__pyx_n_s_IS_UPPER;
static PyObject *__pyx_n_s_LANG;
static PyObject *__pyx_n_s_LANGUAGE;
static PyObject *__pyx_n_s_LAW;
static PyObject *__pyx_n_s_LEMMA;
static PyObject *__pyx_n_s_LENGTH;
static PyObject *__pyx_n_s_LIKE_EMAIL;
static PyObject *__pyx_n_s_LIKE_NUM;
static PyObject *__pyx_n_s_LIKE_URL;
static PyObject *__pyx_n_s_LOC;
static PyObject *__pyx_n_s_LOWER;
static PyObject *__pyx_n_s_MONEY;
static PyObject *__pyx_n_s_MORPH;
static PyObject *__pyx_n_s_NAMES;
static PyObject *__pyx_n_s_NORM;
static PyObject *__pyx_n_s_NORP;
static PyObject *__pyx_n_s_NOUN;
static PyObject *__pyx_n_s_NUM;
static PyObject *__pyx_n_s_ORDINAL;
static PyObject *__pyx_n_s_ORG;
static PyObject *__pyx_n_s_ORTH;
static PyObject *__pyx_n_s_PART;
static PyObject *__pyx_n_s_PERCENT;
static PyObject *__pyx_n_s_PERSON;
static PyObject *__pyx_n_s_POS;
static PyObject *__pyx_n_s_PREFIX;
static PyObject *__pyx_n_s_PROB;
static PyObject *__pyx_n_s_PRODUCT;
static PyObject *__pyx_n_s_PRON;
static PyObject *__pyx_n_s_PROPN;
static PyObject *__pyx_n_s_PUNCT;
static PyObject *__pyx_n_s_QUANTITY;
static PyObject *__pyx_n_s_SCONJ;
static PyObject *__pyx_n_s_SENT_START;
static PyObject *__pyx_n_s_SHAPE;
static PyObject *__pyx_n_s_SPACE;
static PyObject *__pyx_n_s_SPACY;
static PyObject *__pyx_n_s_SUFFIX;
static PyObject *__pyx_n_s_SYM;
static PyObject *__pyx_n_s_TAG;
static PyObject *__pyx_n_s_TIME;
static PyObject *__pyx_n_s_VERB;
static PyObject *__pyx_n_s_WORK_OF_ART;
static PyObject *__pyx_n_s_X;
static PyObject *__pyx_n_s__2;
static PyObject *__pyx_n_s_acl;
static PyObject *__pyx_n_s_acomp;
static PyObject *__pyx_n_s_advcl;
static PyObject *__pyx_n_s_advmod;
static PyObject *__pyx_n_s_agent;
static PyObject *__pyx_n_s_amod;
static PyObject *__pyx_n_s_appos;
static PyObject *__pyx_n_s_attr;
static PyObject *__pyx_n_s_aux;
static PyObject *__pyx_n_s_auxpass;
static PyObject *__pyx_n_s_cc;
static PyObject *__pyx_n_s_ccomp;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_complm;
static PyObject *__pyx_n_s_conj;
static PyObject *__pyx_n_s_cop;
static PyObject *__pyx_n_s_csubj;
static PyObject *__pyx_n_s_csubjpass;
static PyObject *__pyx_n_s_dep;
static PyObject *__pyx_n_s_det;
static PyObject *__pyx_n_s_dobj;
static PyObject *__pyx_n_s_expl;
static PyObject *__pyx_n_s_hmod;
static PyObject *__pyx_n_s_hyph;
static PyObject *__pyx_n_s_infmod;
static PyObject *__pyx_n_s_intj;
static PyObject *__pyx_n_s_iobj;
static PyObject *__pyx_n_s_it;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_mark;
static PyObject *__pyx_n_s_meta;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_neg;
static PyObject *__pyx_n_s_nmod;
static PyObject *__pyx_n_s_nn;
static PyObject *__pyx_n_s_npadvmod;
static PyObject *__pyx_n_s_nsubj;
static PyObject *__pyx_n_s_nsubjpass;
static PyObject *__pyx_n_s_num;
static PyObject *__pyx_n_s_number;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_n_s_obl;
static PyObject *__pyx_n_s_oprd;
static PyObject *__pyx_n_s_parataxis;
static PyObject *__pyx_n_s_partmod;
static PyObject *__pyx_n_s_pcomp;
static PyObject *__pyx_n_s_pobj;
static PyObject *__pyx_n_s_poss;
static PyObject *__pyx_n_s_possessive;
static PyObject *__pyx_n_s_preconj;
static PyObject *__pyx_n_s_prep;
static PyObject *__pyx_n_s_prt;
static PyObject *__pyx_n_s_punct;
static PyObject *__pyx_n_s_quantmod;
static PyObject *__pyx_n_s_rcmod;
static PyObject *__pyx_n_s_relcl;
static PyObject *__pyx_n_s_root;
static PyObject *__pyx_n_s_sort_nums;
static PyObject *__pyx_n_s_sorted;
static PyObject *__pyx_n_s_spacy_symbols;
static PyObject *__pyx_kp_s_spacy_symbols_pyx;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_n_s_xcomp;
static PyObject *__pyx_pf_5spacy_7symbols_sort_nums(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_codeobj__4;
/* Late includes */
/* "spacy/symbols.pyx":472
*
*
* def sort_nums(x): # <<<<<<<<<<<<<<
* return x[1]
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_5spacy_7symbols_1sort_nums(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_5spacy_7symbols_sort_nums[] = "sort_nums(x)";
static PyMethodDef __pyx_mdef_5spacy_7symbols_1sort_nums = {"sort_nums", (PyCFunction)__pyx_pw_5spacy_7symbols_1sort_nums, METH_O, __pyx_doc_5spacy_7symbols_sort_nums};
static PyObject *__pyx_pw_5spacy_7symbols_1sort_nums(PyObject *__pyx_self, PyObject *__pyx_v_x) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("sort_nums (wrapper)", 0);
__pyx_r = __pyx_pf_5spacy_7symbols_sort_nums(__pyx_self, ((PyObject *)__pyx_v_x));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_5spacy_7symbols_sort_nums(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("sort_nums", 0);
/* "spacy/symbols.pyx":473
*
* def sort_nums(x):
* return x[1] # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_GetItemInt(__pyx_v_x, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 473, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "spacy/symbols.pyx":472
*
*
* def sort_nums(x): # <<<<<<<<<<<<<<
* return x[1]
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("spacy.symbols.sort_nums", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyMethodDef __pyx_methods[] = {
{0, 0, 0, 0}
};
#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_symbols(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
{Py_mod_create, (void*)__pyx_pymod_create},
{Py_mod_exec, (void*)__pyx_pymod_exec_symbols},
{0, NULL}
};
#endif
static struct PyModuleDef __pyx_moduledef = {
PyModuleDef_HEAD_INIT,
"symbols",
0, /* m_doc */
#if CYTHON_PEP489_MULTI_PHASE_INIT
0, /* m_size */
#else
-1, /* m_size */
#endif
__pyx_methods /* m_methods */,
#if CYTHON_PEP489_MULTI_PHASE_INIT
__pyx_moduledef_slots, /* m_slots */
#else
NULL, /* m_reload */
#endif
NULL, /* m_traverse */
NULL, /* m_clear */
NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
#define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#define CYTHON_SMALL_CODE __attribute__((cold))
#else
#define CYTHON_SMALL_CODE
#endif
#endif
static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
{&__pyx_n_s_ADJ, __pyx_k_ADJ, sizeof(__pyx_k_ADJ), 0, 0, 1, 1},
{&__pyx_n_s_ADP, __pyx_k_ADP, sizeof(__pyx_k_ADP), 0, 0, 1, 1},
{&__pyx_n_s_ADV, __pyx_k_ADV, sizeof(__pyx_k_ADV), 0, 0, 1, 1},
{&__pyx_n_s_AUX, __pyx_k_AUX, sizeof(__pyx_k_AUX), 0, 0, 1, 1},
{&__pyx_n_s_CARDINAL, __pyx_k_CARDINAL, sizeof(__pyx_k_CARDINAL), 0, 0, 1, 1},
{&__pyx_n_s_CCONJ, __pyx_k_CCONJ, sizeof(__pyx_k_CCONJ), 0, 0, 1, 1},
{&__pyx_n_s_CLUSTER, __pyx_k_CLUSTER, sizeof(__pyx_k_CLUSTER), 0, 0, 1, 1},
{&__pyx_n_s_CONJ, __pyx_k_CONJ, sizeof(__pyx_k_CONJ), 0, 0, 1, 1},
{&__pyx_n_s_DATE, __pyx_k_DATE, sizeof(__pyx_k_DATE), 0, 0, 1, 1},
{&__pyx_n_s_DEP, __pyx_k_DEP, sizeof(__pyx_k_DEP), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED001, __pyx_k_DEPRECATED001, sizeof(__pyx_k_DEPRECATED001), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED002, __pyx_k_DEPRECATED002, sizeof(__pyx_k_DEPRECATED002), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED003, __pyx_k_DEPRECATED003, sizeof(__pyx_k_DEPRECATED003), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED004, __pyx_k_DEPRECATED004, sizeof(__pyx_k_DEPRECATED004), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED005, __pyx_k_DEPRECATED005, sizeof(__pyx_k_DEPRECATED005), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED006, __pyx_k_DEPRECATED006, sizeof(__pyx_k_DEPRECATED006), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED007, __pyx_k_DEPRECATED007, sizeof(__pyx_k_DEPRECATED007), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED008, __pyx_k_DEPRECATED008, sizeof(__pyx_k_DEPRECATED008), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED009, __pyx_k_DEPRECATED009, sizeof(__pyx_k_DEPRECATED009), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED010, __pyx_k_DEPRECATED010, sizeof(__pyx_k_DEPRECATED010), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED011, __pyx_k_DEPRECATED011, sizeof(__pyx_k_DEPRECATED011), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED012, __pyx_k_DEPRECATED012, sizeof(__pyx_k_DEPRECATED012), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED013, __pyx_k_DEPRECATED013, sizeof(__pyx_k_DEPRECATED013), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED014, __pyx_k_DEPRECATED014, sizeof(__pyx_k_DEPRECATED014), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED015, __pyx_k_DEPRECATED015, sizeof(__pyx_k_DEPRECATED015), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED016, __pyx_k_DEPRECATED016, sizeof(__pyx_k_DEPRECATED016), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED017, __pyx_k_DEPRECATED017, sizeof(__pyx_k_DEPRECATED017), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED018, __pyx_k_DEPRECATED018, sizeof(__pyx_k_DEPRECATED018), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED019, __pyx_k_DEPRECATED019, sizeof(__pyx_k_DEPRECATED019), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED020, __pyx_k_DEPRECATED020, sizeof(__pyx_k_DEPRECATED020), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED021, __pyx_k_DEPRECATED021, sizeof(__pyx_k_DEPRECATED021), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED022, __pyx_k_DEPRECATED022, sizeof(__pyx_k_DEPRECATED022), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED023, __pyx_k_DEPRECATED023, sizeof(__pyx_k_DEPRECATED023), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED024, __pyx_k_DEPRECATED024, sizeof(__pyx_k_DEPRECATED024), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED025, __pyx_k_DEPRECATED025, sizeof(__pyx_k_DEPRECATED025), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED026, __pyx_k_DEPRECATED026, sizeof(__pyx_k_DEPRECATED026), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED027, __pyx_k_DEPRECATED027, sizeof(__pyx_k_DEPRECATED027), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED028, __pyx_k_DEPRECATED028, sizeof(__pyx_k_DEPRECATED028), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED029, __pyx_k_DEPRECATED029, sizeof(__pyx_k_DEPRECATED029), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED030, __pyx_k_DEPRECATED030, sizeof(__pyx_k_DEPRECATED030), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED031, __pyx_k_DEPRECATED031, sizeof(__pyx_k_DEPRECATED031), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED032, __pyx_k_DEPRECATED032, sizeof(__pyx_k_DEPRECATED032), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED033, __pyx_k_DEPRECATED033, sizeof(__pyx_k_DEPRECATED033), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED034, __pyx_k_DEPRECATED034, sizeof(__pyx_k_DEPRECATED034), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED035, __pyx_k_DEPRECATED035, sizeof(__pyx_k_DEPRECATED035), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED036, __pyx_k_DEPRECATED036, sizeof(__pyx_k_DEPRECATED036), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED037, __pyx_k_DEPRECATED037, sizeof(__pyx_k_DEPRECATED037), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED038, __pyx_k_DEPRECATED038, sizeof(__pyx_k_DEPRECATED038), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED039, __pyx_k_DEPRECATED039, sizeof(__pyx_k_DEPRECATED039), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED040, __pyx_k_DEPRECATED040, sizeof(__pyx_k_DEPRECATED040), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED041, __pyx_k_DEPRECATED041, sizeof(__pyx_k_DEPRECATED041), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED042, __pyx_k_DEPRECATED042, sizeof(__pyx_k_DEPRECATED042), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED043, __pyx_k_DEPRECATED043, sizeof(__pyx_k_DEPRECATED043), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED044, __pyx_k_DEPRECATED044, sizeof(__pyx_k_DEPRECATED044), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED045, __pyx_k_DEPRECATED045, sizeof(__pyx_k_DEPRECATED045), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED046, __pyx_k_DEPRECATED046, sizeof(__pyx_k_DEPRECATED046), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED047, __pyx_k_DEPRECATED047, sizeof(__pyx_k_DEPRECATED047), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED048, __pyx_k_DEPRECATED048, sizeof(__pyx_k_DEPRECATED048), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED049, __pyx_k_DEPRECATED049, sizeof(__pyx_k_DEPRECATED049), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED050, __pyx_k_DEPRECATED050, sizeof(__pyx_k_DEPRECATED050), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED051, __pyx_k_DEPRECATED051, sizeof(__pyx_k_DEPRECATED051), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED052, __pyx_k_DEPRECATED052, sizeof(__pyx_k_DEPRECATED052), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED053, __pyx_k_DEPRECATED053, sizeof(__pyx_k_DEPRECATED053), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED054, __pyx_k_DEPRECATED054, sizeof(__pyx_k_DEPRECATED054), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED055, __pyx_k_DEPRECATED055, sizeof(__pyx_k_DEPRECATED055), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED056, __pyx_k_DEPRECATED056, sizeof(__pyx_k_DEPRECATED056), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED057, __pyx_k_DEPRECATED057, sizeof(__pyx_k_DEPRECATED057), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED058, __pyx_k_DEPRECATED058, sizeof(__pyx_k_DEPRECATED058), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED059, __pyx_k_DEPRECATED059, sizeof(__pyx_k_DEPRECATED059), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED060, __pyx_k_DEPRECATED060, sizeof(__pyx_k_DEPRECATED060), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED061, __pyx_k_DEPRECATED061, sizeof(__pyx_k_DEPRECATED061), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED062, __pyx_k_DEPRECATED062, sizeof(__pyx_k_DEPRECATED062), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED063, __pyx_k_DEPRECATED063, sizeof(__pyx_k_DEPRECATED063), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED064, __pyx_k_DEPRECATED064, sizeof(__pyx_k_DEPRECATED064), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED065, __pyx_k_DEPRECATED065, sizeof(__pyx_k_DEPRECATED065), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED066, __pyx_k_DEPRECATED066, sizeof(__pyx_k_DEPRECATED066), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED067, __pyx_k_DEPRECATED067, sizeof(__pyx_k_DEPRECATED067), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED068, __pyx_k_DEPRECATED068, sizeof(__pyx_k_DEPRECATED068), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED069, __pyx_k_DEPRECATED069, sizeof(__pyx_k_DEPRECATED069), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED070, __pyx_k_DEPRECATED070, sizeof(__pyx_k_DEPRECATED070), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED071, __pyx_k_DEPRECATED071, sizeof(__pyx_k_DEPRECATED071), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED072, __pyx_k_DEPRECATED072, sizeof(__pyx_k_DEPRECATED072), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED073, __pyx_k_DEPRECATED073, sizeof(__pyx_k_DEPRECATED073), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED074, __pyx_k_DEPRECATED074, sizeof(__pyx_k_DEPRECATED074), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED075, __pyx_k_DEPRECATED075, sizeof(__pyx_k_DEPRECATED075), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED076, __pyx_k_DEPRECATED076, sizeof(__pyx_k_DEPRECATED076), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED077, __pyx_k_DEPRECATED077, sizeof(__pyx_k_DEPRECATED077), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED078, __pyx_k_DEPRECATED078, sizeof(__pyx_k_DEPRECATED078), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED079, __pyx_k_DEPRECATED079, sizeof(__pyx_k_DEPRECATED079), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED080, __pyx_k_DEPRECATED080, sizeof(__pyx_k_DEPRECATED080), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED081, __pyx_k_DEPRECATED081, sizeof(__pyx_k_DEPRECATED081), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED082, __pyx_k_DEPRECATED082, sizeof(__pyx_k_DEPRECATED082), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED083, __pyx_k_DEPRECATED083, sizeof(__pyx_k_DEPRECATED083), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED084, __pyx_k_DEPRECATED084, sizeof(__pyx_k_DEPRECATED084), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED085, __pyx_k_DEPRECATED085, sizeof(__pyx_k_DEPRECATED085), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED086, __pyx_k_DEPRECATED086, sizeof(__pyx_k_DEPRECATED086), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED087, __pyx_k_DEPRECATED087, sizeof(__pyx_k_DEPRECATED087), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED088, __pyx_k_DEPRECATED088, sizeof(__pyx_k_DEPRECATED088), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED089, __pyx_k_DEPRECATED089, sizeof(__pyx_k_DEPRECATED089), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED090, __pyx_k_DEPRECATED090, sizeof(__pyx_k_DEPRECATED090), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED091, __pyx_k_DEPRECATED091, sizeof(__pyx_k_DEPRECATED091), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED092, __pyx_k_DEPRECATED092, sizeof(__pyx_k_DEPRECATED092), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED093, __pyx_k_DEPRECATED093, sizeof(__pyx_k_DEPRECATED093), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED094, __pyx_k_DEPRECATED094, sizeof(__pyx_k_DEPRECATED094), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED095, __pyx_k_DEPRECATED095, sizeof(__pyx_k_DEPRECATED095), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED096, __pyx_k_DEPRECATED096, sizeof(__pyx_k_DEPRECATED096), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED097, __pyx_k_DEPRECATED097, sizeof(__pyx_k_DEPRECATED097), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED098, __pyx_k_DEPRECATED098, sizeof(__pyx_k_DEPRECATED098), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED099, __pyx_k_DEPRECATED099, sizeof(__pyx_k_DEPRECATED099), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED100, __pyx_k_DEPRECATED100, sizeof(__pyx_k_DEPRECATED100), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED101, __pyx_k_DEPRECATED101, sizeof(__pyx_k_DEPRECATED101), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED102, __pyx_k_DEPRECATED102, sizeof(__pyx_k_DEPRECATED102), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED103, __pyx_k_DEPRECATED103, sizeof(__pyx_k_DEPRECATED103), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED104, __pyx_k_DEPRECATED104, sizeof(__pyx_k_DEPRECATED104), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED105, __pyx_k_DEPRECATED105, sizeof(__pyx_k_DEPRECATED105), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED106, __pyx_k_DEPRECATED106, sizeof(__pyx_k_DEPRECATED106), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED107, __pyx_k_DEPRECATED107, sizeof(__pyx_k_DEPRECATED107), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED108, __pyx_k_DEPRECATED108, sizeof(__pyx_k_DEPRECATED108), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED109, __pyx_k_DEPRECATED109, sizeof(__pyx_k_DEPRECATED109), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED110, __pyx_k_DEPRECATED110, sizeof(__pyx_k_DEPRECATED110), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED111, __pyx_k_DEPRECATED111, sizeof(__pyx_k_DEPRECATED111), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED112, __pyx_k_DEPRECATED112, sizeof(__pyx_k_DEPRECATED112), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED113, __pyx_k_DEPRECATED113, sizeof(__pyx_k_DEPRECATED113), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED114, __pyx_k_DEPRECATED114, sizeof(__pyx_k_DEPRECATED114), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED115, __pyx_k_DEPRECATED115, sizeof(__pyx_k_DEPRECATED115), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED116, __pyx_k_DEPRECATED116, sizeof(__pyx_k_DEPRECATED116), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED117, __pyx_k_DEPRECATED117, sizeof(__pyx_k_DEPRECATED117), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED118, __pyx_k_DEPRECATED118, sizeof(__pyx_k_DEPRECATED118), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED119, __pyx_k_DEPRECATED119, sizeof(__pyx_k_DEPRECATED119), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED120, __pyx_k_DEPRECATED120, sizeof(__pyx_k_DEPRECATED120), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED121, __pyx_k_DEPRECATED121, sizeof(__pyx_k_DEPRECATED121), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED122, __pyx_k_DEPRECATED122, sizeof(__pyx_k_DEPRECATED122), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED123, __pyx_k_DEPRECATED123, sizeof(__pyx_k_DEPRECATED123), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED124, __pyx_k_DEPRECATED124, sizeof(__pyx_k_DEPRECATED124), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED125, __pyx_k_DEPRECATED125, sizeof(__pyx_k_DEPRECATED125), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED126, __pyx_k_DEPRECATED126, sizeof(__pyx_k_DEPRECATED126), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED127, __pyx_k_DEPRECATED127, sizeof(__pyx_k_DEPRECATED127), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED128, __pyx_k_DEPRECATED128, sizeof(__pyx_k_DEPRECATED128), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED129, __pyx_k_DEPRECATED129, sizeof(__pyx_k_DEPRECATED129), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED130, __pyx_k_DEPRECATED130, sizeof(__pyx_k_DEPRECATED130), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED131, __pyx_k_DEPRECATED131, sizeof(__pyx_k_DEPRECATED131), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED132, __pyx_k_DEPRECATED132, sizeof(__pyx_k_DEPRECATED132), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED133, __pyx_k_DEPRECATED133, sizeof(__pyx_k_DEPRECATED133), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED134, __pyx_k_DEPRECATED134, sizeof(__pyx_k_DEPRECATED134), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED135, __pyx_k_DEPRECATED135, sizeof(__pyx_k_DEPRECATED135), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED136, __pyx_k_DEPRECATED136, sizeof(__pyx_k_DEPRECATED136), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED137, __pyx_k_DEPRECATED137, sizeof(__pyx_k_DEPRECATED137), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED138, __pyx_k_DEPRECATED138, sizeof(__pyx_k_DEPRECATED138), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED139, __pyx_k_DEPRECATED139, sizeof(__pyx_k_DEPRECATED139), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED140, __pyx_k_DEPRECATED140, sizeof(__pyx_k_DEPRECATED140), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED141, __pyx_k_DEPRECATED141, sizeof(__pyx_k_DEPRECATED141), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED142, __pyx_k_DEPRECATED142, sizeof(__pyx_k_DEPRECATED142), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED143, __pyx_k_DEPRECATED143, sizeof(__pyx_k_DEPRECATED143), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED144, __pyx_k_DEPRECATED144, sizeof(__pyx_k_DEPRECATED144), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED145, __pyx_k_DEPRECATED145, sizeof(__pyx_k_DEPRECATED145), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED146, __pyx_k_DEPRECATED146, sizeof(__pyx_k_DEPRECATED146), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED147, __pyx_k_DEPRECATED147, sizeof(__pyx_k_DEPRECATED147), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED148, __pyx_k_DEPRECATED148, sizeof(__pyx_k_DEPRECATED148), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED149, __pyx_k_DEPRECATED149, sizeof(__pyx_k_DEPRECATED149), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED150, __pyx_k_DEPRECATED150, sizeof(__pyx_k_DEPRECATED150), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED151, __pyx_k_DEPRECATED151, sizeof(__pyx_k_DEPRECATED151), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED152, __pyx_k_DEPRECATED152, sizeof(__pyx_k_DEPRECATED152), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED153, __pyx_k_DEPRECATED153, sizeof(__pyx_k_DEPRECATED153), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED154, __pyx_k_DEPRECATED154, sizeof(__pyx_k_DEPRECATED154), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED155, __pyx_k_DEPRECATED155, sizeof(__pyx_k_DEPRECATED155), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED156, __pyx_k_DEPRECATED156, sizeof(__pyx_k_DEPRECATED156), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED157, __pyx_k_DEPRECATED157, sizeof(__pyx_k_DEPRECATED157), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED158, __pyx_k_DEPRECATED158, sizeof(__pyx_k_DEPRECATED158), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED159, __pyx_k_DEPRECATED159, sizeof(__pyx_k_DEPRECATED159), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED160, __pyx_k_DEPRECATED160, sizeof(__pyx_k_DEPRECATED160), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED161, __pyx_k_DEPRECATED161, sizeof(__pyx_k_DEPRECATED161), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED162, __pyx_k_DEPRECATED162, sizeof(__pyx_k_DEPRECATED162), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED163, __pyx_k_DEPRECATED163, sizeof(__pyx_k_DEPRECATED163), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED164, __pyx_k_DEPRECATED164, sizeof(__pyx_k_DEPRECATED164), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED165, __pyx_k_DEPRECATED165, sizeof(__pyx_k_DEPRECATED165), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED166, __pyx_k_DEPRECATED166, sizeof(__pyx_k_DEPRECATED166), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED167, __pyx_k_DEPRECATED167, sizeof(__pyx_k_DEPRECATED167), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED168, __pyx_k_DEPRECATED168, sizeof(__pyx_k_DEPRECATED168), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED169, __pyx_k_DEPRECATED169, sizeof(__pyx_k_DEPRECATED169), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED170, __pyx_k_DEPRECATED170, sizeof(__pyx_k_DEPRECATED170), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED171, __pyx_k_DEPRECATED171, sizeof(__pyx_k_DEPRECATED171), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED172, __pyx_k_DEPRECATED172, sizeof(__pyx_k_DEPRECATED172), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED173, __pyx_k_DEPRECATED173, sizeof(__pyx_k_DEPRECATED173), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED174, __pyx_k_DEPRECATED174, sizeof(__pyx_k_DEPRECATED174), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED175, __pyx_k_DEPRECATED175, sizeof(__pyx_k_DEPRECATED175), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED176, __pyx_k_DEPRECATED176, sizeof(__pyx_k_DEPRECATED176), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED177, __pyx_k_DEPRECATED177, sizeof(__pyx_k_DEPRECATED177), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED178, __pyx_k_DEPRECATED178, sizeof(__pyx_k_DEPRECATED178), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED179, __pyx_k_DEPRECATED179, sizeof(__pyx_k_DEPRECATED179), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED180, __pyx_k_DEPRECATED180, sizeof(__pyx_k_DEPRECATED180), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED181, __pyx_k_DEPRECATED181, sizeof(__pyx_k_DEPRECATED181), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED182, __pyx_k_DEPRECATED182, sizeof(__pyx_k_DEPRECATED182), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED183, __pyx_k_DEPRECATED183, sizeof(__pyx_k_DEPRECATED183), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED184, __pyx_k_DEPRECATED184, sizeof(__pyx_k_DEPRECATED184), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED185, __pyx_k_DEPRECATED185, sizeof(__pyx_k_DEPRECATED185), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED186, __pyx_k_DEPRECATED186, sizeof(__pyx_k_DEPRECATED186), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED187, __pyx_k_DEPRECATED187, sizeof(__pyx_k_DEPRECATED187), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED188, __pyx_k_DEPRECATED188, sizeof(__pyx_k_DEPRECATED188), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED189, __pyx_k_DEPRECATED189, sizeof(__pyx_k_DEPRECATED189), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED190, __pyx_k_DEPRECATED190, sizeof(__pyx_k_DEPRECATED190), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED191, __pyx_k_DEPRECATED191, sizeof(__pyx_k_DEPRECATED191), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED192, __pyx_k_DEPRECATED192, sizeof(__pyx_k_DEPRECATED192), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED193, __pyx_k_DEPRECATED193, sizeof(__pyx_k_DEPRECATED193), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED194, __pyx_k_DEPRECATED194, sizeof(__pyx_k_DEPRECATED194), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED195, __pyx_k_DEPRECATED195, sizeof(__pyx_k_DEPRECATED195), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED196, __pyx_k_DEPRECATED196, sizeof(__pyx_k_DEPRECATED196), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED197, __pyx_k_DEPRECATED197, sizeof(__pyx_k_DEPRECATED197), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED198, __pyx_k_DEPRECATED198, sizeof(__pyx_k_DEPRECATED198), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED199, __pyx_k_DEPRECATED199, sizeof(__pyx_k_DEPRECATED199), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED200, __pyx_k_DEPRECATED200, sizeof(__pyx_k_DEPRECATED200), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED201, __pyx_k_DEPRECATED201, sizeof(__pyx_k_DEPRECATED201), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED202, __pyx_k_DEPRECATED202, sizeof(__pyx_k_DEPRECATED202), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED203, __pyx_k_DEPRECATED203, sizeof(__pyx_k_DEPRECATED203), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED204, __pyx_k_DEPRECATED204, sizeof(__pyx_k_DEPRECATED204), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED205, __pyx_k_DEPRECATED205, sizeof(__pyx_k_DEPRECATED205), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED206, __pyx_k_DEPRECATED206, sizeof(__pyx_k_DEPRECATED206), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED207, __pyx_k_DEPRECATED207, sizeof(__pyx_k_DEPRECATED207), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED208, __pyx_k_DEPRECATED208, sizeof(__pyx_k_DEPRECATED208), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED209, __pyx_k_DEPRECATED209, sizeof(__pyx_k_DEPRECATED209), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED210, __pyx_k_DEPRECATED210, sizeof(__pyx_k_DEPRECATED210), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED211, __pyx_k_DEPRECATED211, sizeof(__pyx_k_DEPRECATED211), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED212, __pyx_k_DEPRECATED212, sizeof(__pyx_k_DEPRECATED212), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED213, __pyx_k_DEPRECATED213, sizeof(__pyx_k_DEPRECATED213), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED214, __pyx_k_DEPRECATED214, sizeof(__pyx_k_DEPRECATED214), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED215, __pyx_k_DEPRECATED215, sizeof(__pyx_k_DEPRECATED215), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED216, __pyx_k_DEPRECATED216, sizeof(__pyx_k_DEPRECATED216), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED217, __pyx_k_DEPRECATED217, sizeof(__pyx_k_DEPRECATED217), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED218, __pyx_k_DEPRECATED218, sizeof(__pyx_k_DEPRECATED218), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED219, __pyx_k_DEPRECATED219, sizeof(__pyx_k_DEPRECATED219), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED220, __pyx_k_DEPRECATED220, sizeof(__pyx_k_DEPRECATED220), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED221, __pyx_k_DEPRECATED221, sizeof(__pyx_k_DEPRECATED221), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED222, __pyx_k_DEPRECATED222, sizeof(__pyx_k_DEPRECATED222), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED223, __pyx_k_DEPRECATED223, sizeof(__pyx_k_DEPRECATED223), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED224, __pyx_k_DEPRECATED224, sizeof(__pyx_k_DEPRECATED224), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED225, __pyx_k_DEPRECATED225, sizeof(__pyx_k_DEPRECATED225), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED226, __pyx_k_DEPRECATED226, sizeof(__pyx_k_DEPRECATED226), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED227, __pyx_k_DEPRECATED227, sizeof(__pyx_k_DEPRECATED227), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED228, __pyx_k_DEPRECATED228, sizeof(__pyx_k_DEPRECATED228), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED229, __pyx_k_DEPRECATED229, sizeof(__pyx_k_DEPRECATED229), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED230, __pyx_k_DEPRECATED230, sizeof(__pyx_k_DEPRECATED230), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED231, __pyx_k_DEPRECATED231, sizeof(__pyx_k_DEPRECATED231), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED232, __pyx_k_DEPRECATED232, sizeof(__pyx_k_DEPRECATED232), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED233, __pyx_k_DEPRECATED233, sizeof(__pyx_k_DEPRECATED233), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED234, __pyx_k_DEPRECATED234, sizeof(__pyx_k_DEPRECATED234), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED235, __pyx_k_DEPRECATED235, sizeof(__pyx_k_DEPRECATED235), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED236, __pyx_k_DEPRECATED236, sizeof(__pyx_k_DEPRECATED236), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED237, __pyx_k_DEPRECATED237, sizeof(__pyx_k_DEPRECATED237), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED238, __pyx_k_DEPRECATED238, sizeof(__pyx_k_DEPRECATED238), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED239, __pyx_k_DEPRECATED239, sizeof(__pyx_k_DEPRECATED239), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED240, __pyx_k_DEPRECATED240, sizeof(__pyx_k_DEPRECATED240), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED241, __pyx_k_DEPRECATED241, sizeof(__pyx_k_DEPRECATED241), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED242, __pyx_k_DEPRECATED242, sizeof(__pyx_k_DEPRECATED242), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED243, __pyx_k_DEPRECATED243, sizeof(__pyx_k_DEPRECATED243), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED244, __pyx_k_DEPRECATED244, sizeof(__pyx_k_DEPRECATED244), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED245, __pyx_k_DEPRECATED245, sizeof(__pyx_k_DEPRECATED245), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED246, __pyx_k_DEPRECATED246, sizeof(__pyx_k_DEPRECATED246), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED247, __pyx_k_DEPRECATED247, sizeof(__pyx_k_DEPRECATED247), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED248, __pyx_k_DEPRECATED248, sizeof(__pyx_k_DEPRECATED248), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED249, __pyx_k_DEPRECATED249, sizeof(__pyx_k_DEPRECATED249), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED250, __pyx_k_DEPRECATED250, sizeof(__pyx_k_DEPRECATED250), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED251, __pyx_k_DEPRECATED251, sizeof(__pyx_k_DEPRECATED251), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED252, __pyx_k_DEPRECATED252, sizeof(__pyx_k_DEPRECATED252), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED253, __pyx_k_DEPRECATED253, sizeof(__pyx_k_DEPRECATED253), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED254, __pyx_k_DEPRECATED254, sizeof(__pyx_k_DEPRECATED254), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED255, __pyx_k_DEPRECATED255, sizeof(__pyx_k_DEPRECATED255), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED256, __pyx_k_DEPRECATED256, sizeof(__pyx_k_DEPRECATED256), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED257, __pyx_k_DEPRECATED257, sizeof(__pyx_k_DEPRECATED257), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED258, __pyx_k_DEPRECATED258, sizeof(__pyx_k_DEPRECATED258), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED259, __pyx_k_DEPRECATED259, sizeof(__pyx_k_DEPRECATED259), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED260, __pyx_k_DEPRECATED260, sizeof(__pyx_k_DEPRECATED260), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED261, __pyx_k_DEPRECATED261, sizeof(__pyx_k_DEPRECATED261), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED262, __pyx_k_DEPRECATED262, sizeof(__pyx_k_DEPRECATED262), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED263, __pyx_k_DEPRECATED263, sizeof(__pyx_k_DEPRECATED263), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED264, __pyx_k_DEPRECATED264, sizeof(__pyx_k_DEPRECATED264), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED265, __pyx_k_DEPRECATED265, sizeof(__pyx_k_DEPRECATED265), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED266, __pyx_k_DEPRECATED266, sizeof(__pyx_k_DEPRECATED266), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED267, __pyx_k_DEPRECATED267, sizeof(__pyx_k_DEPRECATED267), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED268, __pyx_k_DEPRECATED268, sizeof(__pyx_k_DEPRECATED268), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED269, __pyx_k_DEPRECATED269, sizeof(__pyx_k_DEPRECATED269), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED270, __pyx_k_DEPRECATED270, sizeof(__pyx_k_DEPRECATED270), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED271, __pyx_k_DEPRECATED271, sizeof(__pyx_k_DEPRECATED271), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED272, __pyx_k_DEPRECATED272, sizeof(__pyx_k_DEPRECATED272), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED273, __pyx_k_DEPRECATED273, sizeof(__pyx_k_DEPRECATED273), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED274, __pyx_k_DEPRECATED274, sizeof(__pyx_k_DEPRECATED274), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED275, __pyx_k_DEPRECATED275, sizeof(__pyx_k_DEPRECATED275), 0, 0, 1, 1},
{&__pyx_n_s_DEPRECATED276, __pyx_k_DEPRECATED276, sizeof(__pyx_k_DEPRECATED276), 0, 0, 1, 1},
{&__pyx_n_s_DET, __pyx_k_DET, sizeof(__pyx_k_DET), 0, 0, 1, 1},
{&__pyx_n_s_ENT_ID, __pyx_k_ENT_ID, sizeof(__pyx_k_ENT_ID), 0, 0, 1, 1},
{&__pyx_n_s_ENT_IOB, __pyx_k_ENT_IOB, sizeof(__pyx_k_ENT_IOB), 0, 0, 1, 1},
{&__pyx_n_s_ENT_KB_ID, __pyx_k_ENT_KB_ID, sizeof(__pyx_k_ENT_KB_ID), 0, 0, 1, 1},
{&__pyx_n_s_ENT_TYPE, __pyx_k_ENT_TYPE, sizeof(__pyx_k_ENT_TYPE), 0, 0, 1, 1},
{&__pyx_n_s_EOL, __pyx_k_EOL, sizeof(__pyx_k_EOL), 0, 0, 1, 1},
{&__pyx_n_s_EVENT, __pyx_k_EVENT, sizeof(__pyx_k_EVENT), 0, 0, 1, 1},
{&__pyx_n_s_FACILITY, __pyx_k_FACILITY, sizeof(__pyx_k_FACILITY), 0, 0, 1, 1},
{&__pyx_n_s_FLAG19, __pyx_k_FLAG19, sizeof(__pyx_k_FLAG19), 0, 0, 1, 1},
{&__pyx_n_s_FLAG20, __pyx_k_FLAG20, sizeof(__pyx_k_FLAG20), 0, 0, 1, 1},
{&__pyx_n_s_FLAG21, __pyx_k_FLAG21, sizeof(__pyx_k_FLAG21), 0, 0, 1, 1},
{&__pyx_n_s_FLAG22, __pyx_k_FLAG22, sizeof(__pyx_k_FLAG22), 0, 0, 1, 1},
{&__pyx_n_s_FLAG23, __pyx_k_FLAG23, sizeof(__pyx_k_FLAG23), 0, 0, 1, 1},
{&__pyx_n_s_FLAG24, __pyx_k_FLAG24, sizeof(__pyx_k_FLAG24), 0, 0, 1, 1},
{&__pyx_n_s_FLAG25, __pyx_k_FLAG25, sizeof(__pyx_k_FLAG25), 0, 0, 1, 1},
{&__pyx_n_s_FLAG26, __pyx_k_FLAG26, sizeof(__pyx_k_FLAG26), 0, 0, 1, 1},
{&__pyx_n_s_FLAG27, __pyx_k_FLAG27, sizeof(__pyx_k_FLAG27), 0, 0, 1, 1},
{&__pyx_n_s_FLAG28, __pyx_k_FLAG28, sizeof(__pyx_k_FLAG28), 0, 0, 1, 1},
{&__pyx_n_s_FLAG29, __pyx_k_FLAG29, sizeof(__pyx_k_FLAG29), 0, 0, 1, 1},
{&__pyx_n_s_FLAG30, __pyx_k_FLAG30, sizeof(__pyx_k_FLAG30), 0, 0, 1, 1},
{&__pyx_n_s_FLAG31, __pyx_k_FLAG31, sizeof(__pyx_k_FLAG31), 0, 0, 1, 1},
{&__pyx_n_s_FLAG32, __pyx_k_FLAG32, sizeof(__pyx_k_FLAG32), 0, 0, 1, 1},
{&__pyx_n_s_FLAG33, __pyx_k_FLAG33, sizeof(__pyx_k_FLAG33), 0, 0, 1, 1},
{&__pyx_n_s_FLAG34, __pyx_k_FLAG34, sizeof(__pyx_k_FLAG34), 0, 0, 1, 1},
{&__pyx_n_s_FLAG35, __pyx_k_FLAG35, sizeof(__pyx_k_FLAG35), 0, 0, 1, 1},
{&__pyx_n_s_FLAG36, __pyx_k_FLAG36, sizeof(__pyx_k_FLAG36), 0, 0, 1, 1},
{&__pyx_n_s_FLAG37, __pyx_k_FLAG37, sizeof(__pyx_k_FLAG37), 0, 0, 1, 1},
{&__pyx_n_s_FLAG38, __pyx_k_FLAG38, sizeof(__pyx_k_FLAG38), 0, 0, 1, 1},
{&__pyx_n_s_FLAG39, __pyx_k_FLAG39, sizeof(__pyx_k_FLAG39), 0, 0, 1, 1},
{&__pyx_n_s_FLAG40, __pyx_k_FLAG40, sizeof(__pyx_k_FLAG40), 0, 0, 1, 1},
{&__pyx_n_s_FLAG41, __pyx_k_FLAG41, sizeof(__pyx_k_FLAG41), 0, 0, 1, 1},
{&__pyx_n_s_FLAG42, __pyx_k_FLAG42, sizeof(__pyx_k_FLAG42), 0, 0, 1, 1},
{&__pyx_n_s_FLAG43, __pyx_k_FLAG43, sizeof(__pyx_k_FLAG43), 0, 0, 1, 1},
{&__pyx_n_s_FLAG44, __pyx_k_FLAG44, sizeof(__pyx_k_FLAG44), 0, 0, 1, 1},
{&__pyx_n_s_FLAG45, __pyx_k_FLAG45, sizeof(__pyx_k_FLAG45), 0, 0, 1, 1},
{&__pyx_n_s_FLAG46, __pyx_k_FLAG46, sizeof(__pyx_k_FLAG46), 0, 0, 1, 1},
{&__pyx_n_s_FLAG47, __pyx_k_FLAG47, sizeof(__pyx_k_FLAG47), 0, 0, 1, 1},
{&__pyx_n_s_FLAG48, __pyx_k_FLAG48, sizeof(__pyx_k_FLAG48), 0, 0, 1, 1},
{&__pyx_n_s_FLAG49, __pyx_k_FLAG49, sizeof(__pyx_k_FLAG49), 0, 0, 1, 1},
{&__pyx_n_s_FLAG50, __pyx_k_FLAG50, sizeof(__pyx_k_FLAG50), 0, 0, 1, 1},
{&__pyx_n_s_FLAG51, __pyx_k_FLAG51, sizeof(__pyx_k_FLAG51), 0, 0, 1, 1},
{&__pyx_n_s_FLAG52, __pyx_k_FLAG52, sizeof(__pyx_k_FLAG52), 0, 0, 1, 1},
{&__pyx_n_s_FLAG53, __pyx_k_FLAG53, sizeof(__pyx_k_FLAG53), 0, 0, 1, 1},
{&__pyx_n_s_FLAG54, __pyx_k_FLAG54, sizeof(__pyx_k_FLAG54), 0, 0, 1, 1},
{&__pyx_n_s_FLAG55, __pyx_k_FLAG55, sizeof(__pyx_k_FLAG55), 0, 0, 1, 1},
{&__pyx_n_s_FLAG56, __pyx_k_FLAG56, sizeof(__pyx_k_FLAG56), 0, 0, 1, 1},
{&__pyx_n_s_FLAG57, __pyx_k_FLAG57, sizeof(__pyx_k_FLAG57), 0, 0, 1, 1},
{&__pyx_n_s_FLAG58, __pyx_k_FLAG58, sizeof(__pyx_k_FLAG58), 0, 0, 1, 1},
{&__pyx_n_s_FLAG59, __pyx_k_FLAG59, sizeof(__pyx_k_FLAG59), 0, 0, 1, 1},
{&__pyx_n_s_FLAG60, __pyx_k_FLAG60, sizeof(__pyx_k_FLAG60), 0, 0, 1, 1},
{&__pyx_n_s_FLAG61, __pyx_k_FLAG61, sizeof(__pyx_k_FLAG61), 0, 0, 1, 1},
{&__pyx_n_s_FLAG62, __pyx_k_FLAG62, sizeof(__pyx_k_FLAG62), 0, 0, 1, 1},
{&__pyx_n_s_FLAG63, __pyx_k_FLAG63, sizeof(__pyx_k_FLAG63), 0, 0, 1, 1},
{&__pyx_n_s_GPE, __pyx_k_GPE, sizeof(__pyx_k_GPE), 0, 0, 1, 1},
{&__pyx_n_s_HEAD, __pyx_k_HEAD, sizeof(__pyx_k_HEAD), 0, 0, 1, 1},
{&__pyx_n_s_ID, __pyx_k_ID, sizeof(__pyx_k_ID), 0, 0, 1, 1},
{&__pyx_n_s_IDS, __pyx_k_IDS, sizeof(__pyx_k_IDS), 0, 0, 1, 1},
{&__pyx_n_s_IDX, __pyx_k_IDX, sizeof(__pyx_k_IDX), 0, 0, 1, 1},
{&__pyx_n_s_INTJ, __pyx_k_INTJ, sizeof(__pyx_k_INTJ), 0, 0, 1, 1},
{&__pyx_n_s_IS_ALPHA, __pyx_k_IS_ALPHA, sizeof(__pyx_k_IS_ALPHA), 0, 0, 1, 1},
{&__pyx_n_s_IS_ASCII, __pyx_k_IS_ASCII, sizeof(__pyx_k_IS_ASCII), 0, 0, 1, 1},
{&__pyx_n_s_IS_BRACKET, __pyx_k_IS_BRACKET, sizeof(__pyx_k_IS_BRACKET), 0, 0, 1, 1},
{&__pyx_n_s_IS_CURRENCY, __pyx_k_IS_CURRENCY, sizeof(__pyx_k_IS_CURRENCY), 0, 0, 1, 1},
{&__pyx_n_s_IS_DIGIT, __pyx_k_IS_DIGIT, sizeof(__pyx_k_IS_DIGIT), 0, 0, 1, 1},
{&__pyx_n_s_IS_LEFT_PUNCT, __pyx_k_IS_LEFT_PUNCT, sizeof(__pyx_k_IS_LEFT_PUNCT), 0, 0, 1, 1},
{&__pyx_n_s_IS_LOWER, __pyx_k_IS_LOWER, sizeof(__pyx_k_IS_LOWER), 0, 0, 1, 1},
{&__pyx_n_s_IS_OOV_DEPRECATED, __pyx_k_IS_OOV_DEPRECATED, sizeof(__pyx_k_IS_OOV_DEPRECATED), 0, 0, 1, 1},
{&__pyx_n_s_IS_PUNCT, __pyx_k_IS_PUNCT, sizeof(__pyx_k_IS_PUNCT), 0, 0, 1, 1},
{&__pyx_n_s_IS_QUOTE, __pyx_k_IS_QUOTE, sizeof(__pyx_k_IS_QUOTE), 0, 0, 1, 1},
{&__pyx_n_s_IS_RIGHT_PUNCT, __pyx_k_IS_RIGHT_PUNCT, sizeof(__pyx_k_IS_RIGHT_PUNCT), 0, 0, 1, 1},
{&__pyx_n_s_IS_SPACE, __pyx_k_IS_SPACE, sizeof(__pyx_k_IS_SPACE), 0, 0, 1, 1},
{&__pyx_n_s_IS_STOP, __pyx_k_IS_STOP, sizeof(__pyx_k_IS_STOP), 0, 0, 1, 1},
{&__pyx_n_s_IS_TITLE, __pyx_k_IS_TITLE, sizeof(__pyx_k_IS_TITLE), 0, 0, 1, 1},
{&__pyx_n_s_IS_UPPER, __pyx_k_IS_UPPER, sizeof(__pyx_k_IS_UPPER), 0, 0, 1, 1},
{&__pyx_n_s_LANG, __pyx_k_LANG, sizeof(__pyx_k_LANG), 0, 0, 1, 1},
{&__pyx_n_s_LANGUAGE, __pyx_k_LANGUAGE, sizeof(__pyx_k_LANGUAGE), 0, 0, 1, 1},
{&__pyx_n_s_LAW, __pyx_k_LAW, sizeof(__pyx_k_LAW), 0, 0, 1, 1},
{&__pyx_n_s_LEMMA, __pyx_k_LEMMA, sizeof(__pyx_k_LEMMA), 0, 0, 1, 1},
{&__pyx_n_s_LENGTH, __pyx_k_LENGTH, sizeof(__pyx_k_LENGTH), 0, 0, 1, 1},
{&__pyx_n_s_LIKE_EMAIL, __pyx_k_LIKE_EMAIL, sizeof(__pyx_k_LIKE_EMAIL), 0, 0, 1, 1},
{&__pyx_n_s_LIKE_NUM, __pyx_k_LIKE_NUM, sizeof(__pyx_k_LIKE_NUM), 0, 0, 1, 1},
{&__pyx_n_s_LIKE_URL, __pyx_k_LIKE_URL, sizeof(__pyx_k_LIKE_URL), 0, 0, 1, 1},
{&__pyx_n_s_LOC, __pyx_k_LOC, sizeof(__pyx_k_LOC), 0, 0, 1, 1},
{&__pyx_n_s_LOWER, __pyx_k_LOWER, sizeof(__pyx_k_LOWER), 0, 0, 1, 1},
{&__pyx_n_s_MONEY, __pyx_k_MONEY, sizeof(__pyx_k_MONEY), 0, 0, 1, 1},
{&__pyx_n_s_MORPH, __pyx_k_MORPH, sizeof(__pyx_k_MORPH), 0, 0, 1, 1},
{&__pyx_n_s_NAMES, __pyx_k_NAMES, sizeof(__pyx_k_NAMES), 0, 0, 1, 1},
{&__pyx_n_s_NORM, __pyx_k_NORM, sizeof(__pyx_k_NORM), 0, 0, 1, 1},
{&__pyx_n_s_NORP, __pyx_k_NORP, sizeof(__pyx_k_NORP), 0, 0, 1, 1},
{&__pyx_n_s_NOUN, __pyx_k_NOUN, sizeof(__pyx_k_NOUN), 0, 0, 1, 1},
{&__pyx_n_s_NUM, __pyx_k_NUM, sizeof(__pyx_k_NUM), 0, 0, 1, 1},
{&__pyx_n_s_ORDINAL, __pyx_k_ORDINAL, sizeof(__pyx_k_ORDINAL), 0, 0, 1, 1},
{&__pyx_n_s_ORG, __pyx_k_ORG, sizeof(__pyx_k_ORG), 0, 0, 1, 1},
{&__pyx_n_s_ORTH, __pyx_k_ORTH, sizeof(__pyx_k_ORTH), 0, 0, 1, 1},
{&__pyx_n_s_PART, __pyx_k_PART, sizeof(__pyx_k_PART), 0, 0, 1, 1},
{&__pyx_n_s_PERCENT, __pyx_k_PERCENT, sizeof(__pyx_k_PERCENT), 0, 0, 1, 1},
{&__pyx_n_s_PERSON, __pyx_k_PERSON, sizeof(__pyx_k_PERSON), 0, 0, 1, 1},
{&__pyx_n_s_POS, __pyx_k_POS, sizeof(__pyx_k_POS), 0, 0, 1, 1},
{&__pyx_n_s_PREFIX, __pyx_k_PREFIX, sizeof(__pyx_k_PREFIX), 0, 0, 1, 1},
{&__pyx_n_s_PROB, __pyx_k_PROB, sizeof(__pyx_k_PROB), 0, 0, 1, 1},
{&__pyx_n_s_PRODUCT, __pyx_k_PRODUCT, sizeof(__pyx_k_PRODUCT), 0, 0, 1, 1},
{&__pyx_n_s_PRON, __pyx_k_PRON, sizeof(__pyx_k_PRON), 0, 0, 1, 1},
{&__pyx_n_s_PROPN, __pyx_k_PROPN, sizeof(__pyx_k_PROPN), 0, 0, 1, 1},
{&__pyx_n_s_PUNCT, __pyx_k_PUNCT, sizeof(__pyx_k_PUNCT), 0, 0, 1, 1},
{&__pyx_n_s_QUANTITY, __pyx_k_QUANTITY, sizeof(__pyx_k_QUANTITY), 0, 0, 1, 1},
{&__pyx_n_s_SCONJ, __pyx_k_SCONJ, sizeof(__pyx_k_SCONJ), 0, 0, 1, 1},
{&__pyx_n_s_SENT_START, __pyx_k_SENT_START, sizeof(__pyx_k_SENT_START), 0, 0, 1, 1},
{&__pyx_n_s_SHAPE, __pyx_k_SHAPE, sizeof(__pyx_k_SHAPE), 0, 0, 1, 1},
{&__pyx_n_s_SPACE, __pyx_k_SPACE, sizeof(__pyx_k_SPACE), 0, 0, 1, 1},
{&__pyx_n_s_SPACY, __pyx_k_SPACY, sizeof(__pyx_k_SPACY), 0, 0, 1, 1},
{&__pyx_n_s_SUFFIX, __pyx_k_SUFFIX, sizeof(__pyx_k_SUFFIX), 0, 0, 1, 1},
{&__pyx_n_s_SYM, __pyx_k_SYM, sizeof(__pyx_k_SYM), 0, 0, 1, 1},
{&__pyx_n_s_TAG, __pyx_k_TAG, sizeof(__pyx_k_TAG), 0, 0, 1, 1},
{&__pyx_n_s_TIME, __pyx_k_TIME, sizeof(__pyx_k_TIME), 0, 0, 1, 1},
{&__pyx_n_s_VERB, __pyx_k_VERB, sizeof(__pyx_k_VERB), 0, 0, 1, 1},
{&__pyx_n_s_WORK_OF_ART, __pyx_k_WORK_OF_ART, sizeof(__pyx_k_WORK_OF_ART), 0, 0, 1, 1},
{&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1},
{&__pyx_n_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 1},
{&__pyx_n_s_acl, __pyx_k_acl, sizeof(__pyx_k_acl), 0, 0, 1, 1},
{&__pyx_n_s_acomp, __pyx_k_acomp, sizeof(__pyx_k_acomp), 0, 0, 1, 1},
{&__pyx_n_s_advcl, __pyx_k_advcl, sizeof(__pyx_k_advcl), 0, 0, 1, 1},
{&__pyx_n_s_advmod, __pyx_k_advmod, sizeof(__pyx_k_advmod), 0, 0, 1, 1},
{&__pyx_n_s_agent, __pyx_k_agent, sizeof(__pyx_k_agent), 0, 0, 1, 1},
{&__pyx_n_s_amod, __pyx_k_amod, sizeof(__pyx_k_amod), 0, 0, 1, 1},
{&__pyx_n_s_appos, __pyx_k_appos, sizeof(__pyx_k_appos), 0, 0, 1, 1},
{&__pyx_n_s_attr, __pyx_k_attr, sizeof(__pyx_k_attr), 0, 0, 1, 1},
{&__pyx_n_s_aux, __pyx_k_aux, sizeof(__pyx_k_aux), 0, 0, 1, 1},
{&__pyx_n_s_auxpass, __pyx_k_auxpass, sizeof(__pyx_k_auxpass), 0, 0, 1, 1},
{&__pyx_n_s_cc, __pyx_k_cc, sizeof(__pyx_k_cc), 0, 0, 1, 1},
{&__pyx_n_s_ccomp, __pyx_k_ccomp, sizeof(__pyx_k_ccomp), 0, 0, 1, 1},
{&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
{&__pyx_n_s_complm, __pyx_k_complm, sizeof(__pyx_k_complm), 0, 0, 1, 1},
{&__pyx_n_s_conj, __pyx_k_conj, sizeof(__pyx_k_conj), 0, 0, 1, 1},
{&__pyx_n_s_cop, __pyx_k_cop, sizeof(__pyx_k_cop), 0, 0, 1, 1},
{&__pyx_n_s_csubj, __pyx_k_csubj, sizeof(__pyx_k_csubj), 0, 0, 1, 1},
{&__pyx_n_s_csubjpass, __pyx_k_csubjpass, sizeof(__pyx_k_csubjpass), 0, 0, 1, 1},
{&__pyx_n_s_dep, __pyx_k_dep, sizeof(__pyx_k_dep), 0, 0, 1, 1},
{&__pyx_n_s_det, __pyx_k_det, sizeof(__pyx_k_det), 0, 0, 1, 1},
{&__pyx_n_s_dobj, __pyx_k_dobj, sizeof(__pyx_k_dobj), 0, 0, 1, 1},
{&__pyx_n_s_expl, __pyx_k_expl, sizeof(__pyx_k_expl), 0, 0, 1, 1},
{&__pyx_n_s_hmod, __pyx_k_hmod, sizeof(__pyx_k_hmod), 0, 0, 1, 1},
{&__pyx_n_s_hyph, __pyx_k_hyph, sizeof(__pyx_k_hyph), 0, 0, 1, 1},
{&__pyx_n_s_infmod, __pyx_k_infmod, sizeof(__pyx_k_infmod), 0, 0, 1, 1},
{&__pyx_n_s_intj, __pyx_k_intj, sizeof(__pyx_k_intj), 0, 0, 1, 1},
{&__pyx_n_s_iobj, __pyx_k_iobj, sizeof(__pyx_k_iobj), 0, 0, 1, 1},
{&__pyx_n_s_it, __pyx_k_it, sizeof(__pyx_k_it), 0, 0, 1, 1},
{&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
{&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
{&__pyx_n_s_mark, __pyx_k_mark, sizeof(__pyx_k_mark), 0, 0, 1, 1},
{&__pyx_n_s_meta, __pyx_k_meta, sizeof(__pyx_k_meta), 0, 0, 1, 1},
{&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
{&__pyx_n_s_neg, __pyx_k_neg, sizeof(__pyx_k_neg), 0, 0, 1, 1},
{&__pyx_n_s_nmod, __pyx_k_nmod, sizeof(__pyx_k_nmod), 0, 0, 1, 1},
{&__pyx_n_s_nn, __pyx_k_nn, sizeof(__pyx_k_nn), 0, 0, 1, 1},
{&__pyx_n_s_npadvmod, __pyx_k_npadvmod, sizeof(__pyx_k_npadvmod), 0, 0, 1, 1},
{&__pyx_n_s_nsubj, __pyx_k_nsubj, sizeof(__pyx_k_nsubj), 0, 0, 1, 1},
{&__pyx_n_s_nsubjpass, __pyx_k_nsubjpass, sizeof(__pyx_k_nsubjpass), 0, 0, 1, 1},
{&__pyx_n_s_num, __pyx_k_num, sizeof(__pyx_k_num), 0, 0, 1, 1},
{&__pyx_n_s_number, __pyx_k_number, sizeof(__pyx_k_number), 0, 0, 1, 1},
{&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
{&__pyx_n_s_obl, __pyx_k_obl, sizeof(__pyx_k_obl), 0, 0, 1, 1},
{&__pyx_n_s_oprd, __pyx_k_oprd, sizeof(__pyx_k_oprd), 0, 0, 1, 1},
{&__pyx_n_s_parataxis, __pyx_k_parataxis, sizeof(__pyx_k_parataxis), 0, 0, 1, 1},
{&__pyx_n_s_partmod, __pyx_k_partmod, sizeof(__pyx_k_partmod), 0, 0, 1, 1},
{&__pyx_n_s_pcomp, __pyx_k_pcomp, sizeof(__pyx_k_pcomp), 0, 0, 1, 1},
{&__pyx_n_s_pobj, __pyx_k_pobj, sizeof(__pyx_k_pobj), 0, 0, 1, 1},
{&__pyx_n_s_poss, __pyx_k_poss, sizeof(__pyx_k_poss), 0, 0, 1, 1},
{&__pyx_n_s_possessive, __pyx_k_possessive, sizeof(__pyx_k_possessive), 0, 0, 1, 1},
{&__pyx_n_s_preconj, __pyx_k_preconj, sizeof(__pyx_k_preconj), 0, 0, 1, 1},
{&__pyx_n_s_prep, __pyx_k_prep, sizeof(__pyx_k_prep), 0, 0, 1, 1},
{&__pyx_n_s_prt, __pyx_k_prt, sizeof(__pyx_k_prt), 0, 0, 1, 1},
{&__pyx_n_s_punct, __pyx_k_punct, sizeof(__pyx_k_punct), 0, 0, 1, 1},
{&__pyx_n_s_quantmod, __pyx_k_quantmod, sizeof(__pyx_k_quantmod), 0, 0, 1, 1},
{&__pyx_n_s_rcmod, __pyx_k_rcmod, sizeof(__pyx_k_rcmod), 0, 0, 1, 1},
{&__pyx_n_s_relcl, __pyx_k_relcl, sizeof(__pyx_k_relcl), 0, 0, 1, 1},
{&__pyx_n_s_root, __pyx_k_root, sizeof(__pyx_k_root), 0, 0, 1, 1},
{&__pyx_n_s_sort_nums, __pyx_k_sort_nums, sizeof(__pyx_k_sort_nums), 0, 0, 1, 1},
{&__pyx_n_s_sorted, __pyx_k_sorted, sizeof(__pyx_k_sorted), 0, 0, 1, 1},
{&__pyx_n_s_spacy_symbols, __pyx_k_spacy_symbols, sizeof(__pyx_k_spacy_symbols), 0, 0, 1, 1},
{&__pyx_kp_s_spacy_symbols_pyx, __pyx_k_spacy_symbols_pyx, sizeof(__pyx_k_spacy_symbols_pyx), 0, 0, 1, 0},
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
{&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
{&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
{&__pyx_n_s_xcomp, __pyx_k_xcomp, sizeof(__pyx_k_xcomp), 0, 0, 1, 1},
{0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_sorted = __Pyx_GetBuiltinName(__pyx_n_s_sorted); if (!__pyx_builtin_sorted) __PYX_ERR(0, 476, __pyx_L1_error)
return 0;
__pyx_L1_error:;
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
/* "spacy/symbols.pyx":472
*
*
* def sort_nums(x): # <<<<<<<<<<<<<<
* return x[1]
*
*/
__pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_x); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 472, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__3);
__Pyx_GIVEREF(__pyx_tuple__3);
__pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_spacy_symbols_pyx, __pyx_n_s_sort_nums, 472, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 472, __pyx_L1_error)
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
__Pyx_RefNannyFinishContext();
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
return 0;
__pyx_L1_error:;
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
static int __Pyx_modinit_global_init_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
/*--- Global init code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_variable_export_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
/*--- Variable export code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_function_export_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
/*--- Function export code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_type_init_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
/*--- Type init code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_type_import_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
/*--- Type import code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_variable_import_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
/*--- Variable import code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_function_import_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
/*--- Function import code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif
#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initsymbols(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initsymbols(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_symbols(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_symbols(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
#if PY_VERSION_HEX >= 0x030700A1
static PY_INT64_T main_interpreter_id = -1;
PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
if (main_interpreter_id == -1) {
main_interpreter_id = current_id;
return (unlikely(current_id == -1)) ? -1 : 0;
} else if (unlikely(main_interpreter_id != current_id))
#else
static PyInterpreterState *main_interpreter = NULL;
PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
if (!main_interpreter) {
main_interpreter = current_interpreter;
} else if (unlikely(main_interpreter != current_interpreter))
#endif
{
PyErr_SetString(
PyExc_ImportError,
"Interpreter change detected - this module can only be loaded into one interpreter per process.");
return -1;
}
return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
PyObject *value = PyObject_GetAttrString(spec, from_name);
int result = 0;
if (likely(value)) {
if (allow_none || value != Py_None) {
result = PyDict_SetItemString(moddict, to_name, value);
}
Py_DECREF(value);
} else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Clear();
} else {
result = -1;
}
return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
PyObject *module = NULL, *moddict, *modname;
if (__Pyx_check_single_interpreter())
return NULL;
if (__pyx_m)
return __Pyx_NewRef(__pyx_m);
modname = PyObject_GetAttrString(spec, "name");
if (unlikely(!modname)) goto bad;
module = PyModule_NewObject(modname);
Py_DECREF(modname);
if (unlikely(!module)) goto bad;
moddict = PyModule_GetDict(module);
if (unlikely(!moddict)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
return module;
bad:
Py_XDECREF(module);
return NULL;
}
static CYTHON_SMALL_CODE int __pyx_pymod_exec_symbols(PyObject *__pyx_pyinit_module)
#endif
#endif
{
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
Py_ssize_t __pyx_t_5;
PyObject *(*__pyx_t_6)(PyObject *);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannyDeclarations
#if CYTHON_PEP489_MULTI_PHASE_INIT
if (__pyx_m) {
if (__pyx_m == __pyx_pyinit_module) return 0;
PyErr_SetString(PyExc_RuntimeError, "Module 'symbols' has already been imported. Re-initialisation is not supported.");
return -1;
}
#elif PY_MAJOR_VERSION >= 3
if (__pyx_m) return __Pyx_NewRef(__pyx_m);
#endif
#if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
PyErr_Clear();
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
if (!__Pyx_RefNanny)
Py_FatalError("failed to import 'refnanny' module");
}
#endif
__Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_symbols(void)", 0);
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#ifdef __Pxy_PyFrame_Initialize_Offsets
__Pxy_PyFrame_Initialize_Offsets();
#endif
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
#ifdef __Pyx_CyFunction_USED
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_FusedFunction_USED
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_Coroutine_USED
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_Generator_USED
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_AsyncGen_USED
if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_StopAsyncIteration_USED
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
/*--- Library function declarations ---*/
/*--- Threads initialization code ---*/
#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
PyEval_InitThreads();
#endif
/*--- Module creation code ---*/
#if CYTHON_PEP489_MULTI_PHASE_INIT
__pyx_m = __pyx_pyinit_module;
Py_INCREF(__pyx_m);
#else
#if PY_MAJOR_VERSION < 3
__pyx_m = Py_InitModule4("symbols", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
#else
__pyx_m = PyModule_Create(&__pyx_moduledef);
#endif
if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_d);
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_b);
__pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_cython_runtime);
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
/*--- Initialize various global constants etc. ---*/
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
if (__pyx_module_is_main_spacy__symbols) {
if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
}
#if PY_MAJOR_VERSION >= 3
{
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
if (!PyDict_GetItemString(modules, "spacy.symbols")) {
if (unlikely(PyDict_SetItemString(modules, "spacy.symbols", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
}
}
#endif
/*--- Builtin init code ---*/
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
/*--- Constants init code ---*/
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
/*--- Global type/function init code ---*/
(void)__Pyx_modinit_global_init_code();
(void)__Pyx_modinit_variable_export_code();
(void)__Pyx_modinit_function_export_code();
(void)__Pyx_modinit_type_init_code();
(void)__Pyx_modinit_type_import_code();
(void)__Pyx_modinit_variable_import_code();
(void)__Pyx_modinit_function_import_code();
/*--- Execution code ---*/
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
/* "spacy/symbols.pyx":3
* # cython: optimize.unpack_method_calls=False
* IDS = {
* "": NIL, # <<<<<<<<<<<<<<
* "IS_ALPHA": IS_ALPHA,
* "IS_ASCII": IS_ASCII,
*/
__pyx_t_1 = __Pyx_PyDict_NewPresized(457); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_NIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_kp_s_, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":4
* IDS = {
* "": NIL,
* "IS_ALPHA": IS_ALPHA, # <<<<<<<<<<<<<<
* "IS_ASCII": IS_ASCII,
* "IS_DIGIT": IS_DIGIT,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_ALPHA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_ALPHA, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":5
* "": NIL,
* "IS_ALPHA": IS_ALPHA,
* "IS_ASCII": IS_ASCII, # <<<<<<<<<<<<<<
* "IS_DIGIT": IS_DIGIT,
* "IS_LOWER": IS_LOWER,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_ASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_ASCII, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":6
* "IS_ALPHA": IS_ALPHA,
* "IS_ASCII": IS_ASCII,
* "IS_DIGIT": IS_DIGIT, # <<<<<<<<<<<<<<
* "IS_LOWER": IS_LOWER,
* "IS_PUNCT": IS_PUNCT,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_DIGIT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_DIGIT, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":7
* "IS_ASCII": IS_ASCII,
* "IS_DIGIT": IS_DIGIT,
* "IS_LOWER": IS_LOWER, # <<<<<<<<<<<<<<
* "IS_PUNCT": IS_PUNCT,
* "IS_SPACE": IS_SPACE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_LOWER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_LOWER, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":8
* "IS_DIGIT": IS_DIGIT,
* "IS_LOWER": IS_LOWER,
* "IS_PUNCT": IS_PUNCT, # <<<<<<<<<<<<<<
* "IS_SPACE": IS_SPACE,
* "IS_TITLE": IS_TITLE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_PUNCT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_PUNCT, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":9
* "IS_LOWER": IS_LOWER,
* "IS_PUNCT": IS_PUNCT,
* "IS_SPACE": IS_SPACE, # <<<<<<<<<<<<<<
* "IS_TITLE": IS_TITLE,
* "IS_UPPER": IS_UPPER,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_SPACE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_SPACE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":10
* "IS_PUNCT": IS_PUNCT,
* "IS_SPACE": IS_SPACE,
* "IS_TITLE": IS_TITLE, # <<<<<<<<<<<<<<
* "IS_UPPER": IS_UPPER,
* "LIKE_URL": LIKE_URL,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_TITLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_TITLE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":11
* "IS_SPACE": IS_SPACE,
* "IS_TITLE": IS_TITLE,
* "IS_UPPER": IS_UPPER, # <<<<<<<<<<<<<<
* "LIKE_URL": LIKE_URL,
* "LIKE_NUM": LIKE_NUM,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_UPPER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_UPPER, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":12
* "IS_TITLE": IS_TITLE,
* "IS_UPPER": IS_UPPER,
* "LIKE_URL": LIKE_URL, # <<<<<<<<<<<<<<
* "LIKE_NUM": LIKE_NUM,
* "LIKE_EMAIL": LIKE_EMAIL,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LIKE_URL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LIKE_URL, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":13
* "IS_UPPER": IS_UPPER,
* "LIKE_URL": LIKE_URL,
* "LIKE_NUM": LIKE_NUM, # <<<<<<<<<<<<<<
* "LIKE_EMAIL": LIKE_EMAIL,
* "IS_STOP": IS_STOP,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LIKE_NUM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LIKE_NUM, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":14
* "LIKE_URL": LIKE_URL,
* "LIKE_NUM": LIKE_NUM,
* "LIKE_EMAIL": LIKE_EMAIL, # <<<<<<<<<<<<<<
* "IS_STOP": IS_STOP,
* "IS_OOV_DEPRECATED": IS_OOV_DEPRECATED,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LIKE_EMAIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LIKE_EMAIL, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":15
* "LIKE_NUM": LIKE_NUM,
* "LIKE_EMAIL": LIKE_EMAIL,
* "IS_STOP": IS_STOP, # <<<<<<<<<<<<<<
* "IS_OOV_DEPRECATED": IS_OOV_DEPRECATED,
* "IS_BRACKET": IS_BRACKET,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_STOP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_STOP, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":16
* "LIKE_EMAIL": LIKE_EMAIL,
* "IS_STOP": IS_STOP,
* "IS_OOV_DEPRECATED": IS_OOV_DEPRECATED, # <<<<<<<<<<<<<<
* "IS_BRACKET": IS_BRACKET,
* "IS_QUOTE": IS_QUOTE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_OOV_DEPRECATED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_OOV_DEPRECATED, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":17
* "IS_STOP": IS_STOP,
* "IS_OOV_DEPRECATED": IS_OOV_DEPRECATED,
* "IS_BRACKET": IS_BRACKET, # <<<<<<<<<<<<<<
* "IS_QUOTE": IS_QUOTE,
* "IS_LEFT_PUNCT": IS_LEFT_PUNCT,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_BRACKET); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_BRACKET, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":18
* "IS_OOV_DEPRECATED": IS_OOV_DEPRECATED,
* "IS_BRACKET": IS_BRACKET,
* "IS_QUOTE": IS_QUOTE, # <<<<<<<<<<<<<<
* "IS_LEFT_PUNCT": IS_LEFT_PUNCT,
* "IS_RIGHT_PUNCT": IS_RIGHT_PUNCT,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_QUOTE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_QUOTE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":19
* "IS_BRACKET": IS_BRACKET,
* "IS_QUOTE": IS_QUOTE,
* "IS_LEFT_PUNCT": IS_LEFT_PUNCT, # <<<<<<<<<<<<<<
* "IS_RIGHT_PUNCT": IS_RIGHT_PUNCT,
* "IS_CURRENCY": IS_CURRENCY,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_LEFT_PUNCT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_LEFT_PUNCT, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":20
* "IS_QUOTE": IS_QUOTE,
* "IS_LEFT_PUNCT": IS_LEFT_PUNCT,
* "IS_RIGHT_PUNCT": IS_RIGHT_PUNCT, # <<<<<<<<<<<<<<
* "IS_CURRENCY": IS_CURRENCY,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_RIGHT_PUNCT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_RIGHT_PUNCT, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":21
* "IS_LEFT_PUNCT": IS_LEFT_PUNCT,
* "IS_RIGHT_PUNCT": IS_RIGHT_PUNCT,
* "IS_CURRENCY": IS_CURRENCY, # <<<<<<<<<<<<<<
*
* "FLAG19": FLAG19,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IS_CURRENCY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IS_CURRENCY, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":23
* "IS_CURRENCY": IS_CURRENCY,
*
* "FLAG19": FLAG19, # <<<<<<<<<<<<<<
* "FLAG20": FLAG20,
* "FLAG21": FLAG21,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG19); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG19, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":24
*
* "FLAG19": FLAG19,
* "FLAG20": FLAG20, # <<<<<<<<<<<<<<
* "FLAG21": FLAG21,
* "FLAG22": FLAG22,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG20); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG20, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":25
* "FLAG19": FLAG19,
* "FLAG20": FLAG20,
* "FLAG21": FLAG21, # <<<<<<<<<<<<<<
* "FLAG22": FLAG22,
* "FLAG23": FLAG23,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG21); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG21, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":26
* "FLAG20": FLAG20,
* "FLAG21": FLAG21,
* "FLAG22": FLAG22, # <<<<<<<<<<<<<<
* "FLAG23": FLAG23,
* "FLAG24": FLAG24,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG22); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG22, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":27
* "FLAG21": FLAG21,
* "FLAG22": FLAG22,
* "FLAG23": FLAG23, # <<<<<<<<<<<<<<
* "FLAG24": FLAG24,
* "FLAG25": FLAG25,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG23); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG23, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":28
* "FLAG22": FLAG22,
* "FLAG23": FLAG23,
* "FLAG24": FLAG24, # <<<<<<<<<<<<<<
* "FLAG25": FLAG25,
* "FLAG26": FLAG26,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG24); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG24, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":29
* "FLAG23": FLAG23,
* "FLAG24": FLAG24,
* "FLAG25": FLAG25, # <<<<<<<<<<<<<<
* "FLAG26": FLAG26,
* "FLAG27": FLAG27,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG25); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG25, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":30
* "FLAG24": FLAG24,
* "FLAG25": FLAG25,
* "FLAG26": FLAG26, # <<<<<<<<<<<<<<
* "FLAG27": FLAG27,
* "FLAG28": FLAG28,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG26); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG26, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":31
* "FLAG25": FLAG25,
* "FLAG26": FLAG26,
* "FLAG27": FLAG27, # <<<<<<<<<<<<<<
* "FLAG28": FLAG28,
* "FLAG29": FLAG29,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG27); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG27, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":32
* "FLAG26": FLAG26,
* "FLAG27": FLAG27,
* "FLAG28": FLAG28, # <<<<<<<<<<<<<<
* "FLAG29": FLAG29,
* "FLAG30": FLAG30,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG28); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG28, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":33
* "FLAG27": FLAG27,
* "FLAG28": FLAG28,
* "FLAG29": FLAG29, # <<<<<<<<<<<<<<
* "FLAG30": FLAG30,
* "FLAG31": FLAG31,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG29); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG29, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":34
* "FLAG28": FLAG28,
* "FLAG29": FLAG29,
* "FLAG30": FLAG30, # <<<<<<<<<<<<<<
* "FLAG31": FLAG31,
* "FLAG32": FLAG32,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG30); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG30, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":35
* "FLAG29": FLAG29,
* "FLAG30": FLAG30,
* "FLAG31": FLAG31, # <<<<<<<<<<<<<<
* "FLAG32": FLAG32,
* "FLAG33": FLAG33,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG31); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG31, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":36
* "FLAG30": FLAG30,
* "FLAG31": FLAG31,
* "FLAG32": FLAG32, # <<<<<<<<<<<<<<
* "FLAG33": FLAG33,
* "FLAG34": FLAG34,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG32, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":37
* "FLAG31": FLAG31,
* "FLAG32": FLAG32,
* "FLAG33": FLAG33, # <<<<<<<<<<<<<<
* "FLAG34": FLAG34,
* "FLAG35": FLAG35,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG33); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG33, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":38
* "FLAG32": FLAG32,
* "FLAG33": FLAG33,
* "FLAG34": FLAG34, # <<<<<<<<<<<<<<
* "FLAG35": FLAG35,
* "FLAG36": FLAG36,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG34); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG34, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":39
* "FLAG33": FLAG33,
* "FLAG34": FLAG34,
* "FLAG35": FLAG35, # <<<<<<<<<<<<<<
* "FLAG36": FLAG36,
* "FLAG37": FLAG37,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG35); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG35, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":40
* "FLAG34": FLAG34,
* "FLAG35": FLAG35,
* "FLAG36": FLAG36, # <<<<<<<<<<<<<<
* "FLAG37": FLAG37,
* "FLAG38": FLAG38,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG36); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG36, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":41
* "FLAG35": FLAG35,
* "FLAG36": FLAG36,
* "FLAG37": FLAG37, # <<<<<<<<<<<<<<
* "FLAG38": FLAG38,
* "FLAG39": FLAG39,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG37); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG37, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":42
* "FLAG36": FLAG36,
* "FLAG37": FLAG37,
* "FLAG38": FLAG38, # <<<<<<<<<<<<<<
* "FLAG39": FLAG39,
* "FLAG40": FLAG40,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG38); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG38, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":43
* "FLAG37": FLAG37,
* "FLAG38": FLAG38,
* "FLAG39": FLAG39, # <<<<<<<<<<<<<<
* "FLAG40": FLAG40,
* "FLAG41": FLAG41,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG39); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG39, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":44
* "FLAG38": FLAG38,
* "FLAG39": FLAG39,
* "FLAG40": FLAG40, # <<<<<<<<<<<<<<
* "FLAG41": FLAG41,
* "FLAG42": FLAG42,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG40); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG40, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":45
* "FLAG39": FLAG39,
* "FLAG40": FLAG40,
* "FLAG41": FLAG41, # <<<<<<<<<<<<<<
* "FLAG42": FLAG42,
* "FLAG43": FLAG43,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG41); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG41, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":46
* "FLAG40": FLAG40,
* "FLAG41": FLAG41,
* "FLAG42": FLAG42, # <<<<<<<<<<<<<<
* "FLAG43": FLAG43,
* "FLAG44": FLAG44,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG42); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG42, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":47
* "FLAG41": FLAG41,
* "FLAG42": FLAG42,
* "FLAG43": FLAG43, # <<<<<<<<<<<<<<
* "FLAG44": FLAG44,
* "FLAG45": FLAG45,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG43); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG43, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":48
* "FLAG42": FLAG42,
* "FLAG43": FLAG43,
* "FLAG44": FLAG44, # <<<<<<<<<<<<<<
* "FLAG45": FLAG45,
* "FLAG46": FLAG46,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG44); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG44, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":49
* "FLAG43": FLAG43,
* "FLAG44": FLAG44,
* "FLAG45": FLAG45, # <<<<<<<<<<<<<<
* "FLAG46": FLAG46,
* "FLAG47": FLAG47,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG45); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG45, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":50
* "FLAG44": FLAG44,
* "FLAG45": FLAG45,
* "FLAG46": FLAG46, # <<<<<<<<<<<<<<
* "FLAG47": FLAG47,
* "FLAG48": FLAG48,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG46); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG46, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":51
* "FLAG45": FLAG45,
* "FLAG46": FLAG46,
* "FLAG47": FLAG47, # <<<<<<<<<<<<<<
* "FLAG48": FLAG48,
* "FLAG49": FLAG49,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG47); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG47, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":52
* "FLAG46": FLAG46,
* "FLAG47": FLAG47,
* "FLAG48": FLAG48, # <<<<<<<<<<<<<<
* "FLAG49": FLAG49,
* "FLAG50": FLAG50,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG48); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG48, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":53
* "FLAG47": FLAG47,
* "FLAG48": FLAG48,
* "FLAG49": FLAG49, # <<<<<<<<<<<<<<
* "FLAG50": FLAG50,
* "FLAG51": FLAG51,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG49); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG49, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":54
* "FLAG48": FLAG48,
* "FLAG49": FLAG49,
* "FLAG50": FLAG50, # <<<<<<<<<<<<<<
* "FLAG51": FLAG51,
* "FLAG52": FLAG52,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG50); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG50, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":55
* "FLAG49": FLAG49,
* "FLAG50": FLAG50,
* "FLAG51": FLAG51, # <<<<<<<<<<<<<<
* "FLAG52": FLAG52,
* "FLAG53": FLAG53,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG51); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG51, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":56
* "FLAG50": FLAG50,
* "FLAG51": FLAG51,
* "FLAG52": FLAG52, # <<<<<<<<<<<<<<
* "FLAG53": FLAG53,
* "FLAG54": FLAG54,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG52); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG52, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":57
* "FLAG51": FLAG51,
* "FLAG52": FLAG52,
* "FLAG53": FLAG53, # <<<<<<<<<<<<<<
* "FLAG54": FLAG54,
* "FLAG55": FLAG55,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG53); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG53, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":58
* "FLAG52": FLAG52,
* "FLAG53": FLAG53,
* "FLAG54": FLAG54, # <<<<<<<<<<<<<<
* "FLAG55": FLAG55,
* "FLAG56": FLAG56,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG54); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG54, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":59
* "FLAG53": FLAG53,
* "FLAG54": FLAG54,
* "FLAG55": FLAG55, # <<<<<<<<<<<<<<
* "FLAG56": FLAG56,
* "FLAG57": FLAG57,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG55); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG55, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":60
* "FLAG54": FLAG54,
* "FLAG55": FLAG55,
* "FLAG56": FLAG56, # <<<<<<<<<<<<<<
* "FLAG57": FLAG57,
* "FLAG58": FLAG58,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG56); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG56, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":61
* "FLAG55": FLAG55,
* "FLAG56": FLAG56,
* "FLAG57": FLAG57, # <<<<<<<<<<<<<<
* "FLAG58": FLAG58,
* "FLAG59": FLAG59,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG57); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG57, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":62
* "FLAG56": FLAG56,
* "FLAG57": FLAG57,
* "FLAG58": FLAG58, # <<<<<<<<<<<<<<
* "FLAG59": FLAG59,
* "FLAG60": FLAG60,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG58); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG58, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":63
* "FLAG57": FLAG57,
* "FLAG58": FLAG58,
* "FLAG59": FLAG59, # <<<<<<<<<<<<<<
* "FLAG60": FLAG60,
* "FLAG61": FLAG61,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG59); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG59, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":64
* "FLAG58": FLAG58,
* "FLAG59": FLAG59,
* "FLAG60": FLAG60, # <<<<<<<<<<<<<<
* "FLAG61": FLAG61,
* "FLAG62": FLAG62,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG60); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG60, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":65
* "FLAG59": FLAG59,
* "FLAG60": FLAG60,
* "FLAG61": FLAG61, # <<<<<<<<<<<<<<
* "FLAG62": FLAG62,
* "FLAG63": FLAG63,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG61); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG61, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":66
* "FLAG60": FLAG60,
* "FLAG61": FLAG61,
* "FLAG62": FLAG62, # <<<<<<<<<<<<<<
* "FLAG63": FLAG63,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG62); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG62, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":67
* "FLAG61": FLAG61,
* "FLAG62": FLAG62,
* "FLAG63": FLAG63, # <<<<<<<<<<<<<<
*
* "ID": ID,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FLAG63); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FLAG63, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":69
* "FLAG63": FLAG63,
*
* "ID": ID, # <<<<<<<<<<<<<<
* "ORTH": ORTH,
* "LOWER": LOWER,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ID, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":70
*
* "ID": ID,
* "ORTH": ORTH, # <<<<<<<<<<<<<<
* "LOWER": LOWER,
* "NORM": NORM,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ORTH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ORTH, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":71
* "ID": ID,
* "ORTH": ORTH,
* "LOWER": LOWER, # <<<<<<<<<<<<<<
* "NORM": NORM,
* "SHAPE": SHAPE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LOWER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LOWER, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":72
* "ORTH": ORTH,
* "LOWER": LOWER,
* "NORM": NORM, # <<<<<<<<<<<<<<
* "SHAPE": SHAPE,
* "PREFIX": PREFIX,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_NORM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_NORM, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":73
* "LOWER": LOWER,
* "NORM": NORM,
* "SHAPE": SHAPE, # <<<<<<<<<<<<<<
* "PREFIX": PREFIX,
* "SUFFIX": SUFFIX,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_SHAPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_SHAPE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":74
* "NORM": NORM,
* "SHAPE": SHAPE,
* "PREFIX": PREFIX, # <<<<<<<<<<<<<<
* "SUFFIX": SUFFIX,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PREFIX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PREFIX, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":75
* "SHAPE": SHAPE,
* "PREFIX": PREFIX,
* "SUFFIX": SUFFIX, # <<<<<<<<<<<<<<
*
* "LENGTH": LENGTH,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_SUFFIX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_SUFFIX, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":77
* "SUFFIX": SUFFIX,
*
* "LENGTH": LENGTH, # <<<<<<<<<<<<<<
* "CLUSTER": CLUSTER,
* "LEMMA": LEMMA,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LENGTH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LENGTH, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":78
*
* "LENGTH": LENGTH,
* "CLUSTER": CLUSTER, # <<<<<<<<<<<<<<
* "LEMMA": LEMMA,
* "POS": POS,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_CLUSTER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_CLUSTER, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":79
* "LENGTH": LENGTH,
* "CLUSTER": CLUSTER,
* "LEMMA": LEMMA, # <<<<<<<<<<<<<<
* "POS": POS,
* "TAG": TAG,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LEMMA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LEMMA, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":80
* "CLUSTER": CLUSTER,
* "LEMMA": LEMMA,
* "POS": POS, # <<<<<<<<<<<<<<
* "TAG": TAG,
* "DEP": DEP,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_POS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_POS, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":81
* "LEMMA": LEMMA,
* "POS": POS,
* "TAG": TAG, # <<<<<<<<<<<<<<
* "DEP": DEP,
* "ENT_IOB": ENT_IOB,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_TAG); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_TAG, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":82
* "POS": POS,
* "TAG": TAG,
* "DEP": DEP, # <<<<<<<<<<<<<<
* "ENT_IOB": ENT_IOB,
* "ENT_TYPE": ENT_TYPE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEP, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":83
* "TAG": TAG,
* "DEP": DEP,
* "ENT_IOB": ENT_IOB, # <<<<<<<<<<<<<<
* "ENT_TYPE": ENT_TYPE,
* "ENT_ID": ENT_ID,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ENT_IOB); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ENT_IOB, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":84
* "DEP": DEP,
* "ENT_IOB": ENT_IOB,
* "ENT_TYPE": ENT_TYPE, # <<<<<<<<<<<<<<
* "ENT_ID": ENT_ID,
* "ENT_KB_ID": ENT_KB_ID,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ENT_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ENT_TYPE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":85
* "ENT_IOB": ENT_IOB,
* "ENT_TYPE": ENT_TYPE,
* "ENT_ID": ENT_ID, # <<<<<<<<<<<<<<
* "ENT_KB_ID": ENT_KB_ID,
* "HEAD": HEAD,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ENT_ID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ENT_ID, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":86
* "ENT_TYPE": ENT_TYPE,
* "ENT_ID": ENT_ID,
* "ENT_KB_ID": ENT_KB_ID, # <<<<<<<<<<<<<<
* "HEAD": HEAD,
* "SENT_START": SENT_START,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ENT_KB_ID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ENT_KB_ID, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":87
* "ENT_ID": ENT_ID,
* "ENT_KB_ID": ENT_KB_ID,
* "HEAD": HEAD, # <<<<<<<<<<<<<<
* "SENT_START": SENT_START,
* "SPACY": SPACY,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_HEAD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_HEAD, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":88
* "ENT_KB_ID": ENT_KB_ID,
* "HEAD": HEAD,
* "SENT_START": SENT_START, # <<<<<<<<<<<<<<
* "SPACY": SPACY,
* "PROB": PROB,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_SENT_START); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_SENT_START, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":89
* "HEAD": HEAD,
* "SENT_START": SENT_START,
* "SPACY": SPACY, # <<<<<<<<<<<<<<
* "PROB": PROB,
* "LANG": LANG,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_SPACY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_SPACY, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":90
* "SENT_START": SENT_START,
* "SPACY": SPACY,
* "PROB": PROB, # <<<<<<<<<<<<<<
* "LANG": LANG,
* "IDX": IDX,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PROB); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PROB, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":91
* "SPACY": SPACY,
* "PROB": PROB,
* "LANG": LANG, # <<<<<<<<<<<<<<
* "IDX": IDX,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LANG); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LANG, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":92
* "PROB": PROB,
* "LANG": LANG,
* "IDX": IDX, # <<<<<<<<<<<<<<
*
* "ADJ": ADJ,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_IDX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_IDX, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":94
* "IDX": IDX,
*
* "ADJ": ADJ, # <<<<<<<<<<<<<<
* "ADP": ADP,
* "ADV": ADV,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ADJ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ADJ, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":95
*
* "ADJ": ADJ,
* "ADP": ADP, # <<<<<<<<<<<<<<
* "ADV": ADV,
* "AUX": AUX,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ADP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ADP, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":96
* "ADJ": ADJ,
* "ADP": ADP,
* "ADV": ADV, # <<<<<<<<<<<<<<
* "AUX": AUX,
* "CONJ": CONJ,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ADV); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ADV, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":97
* "ADP": ADP,
* "ADV": ADV,
* "AUX": AUX, # <<<<<<<<<<<<<<
* "CONJ": CONJ,
* "CCONJ": CCONJ, # U20
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_AUX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_AUX, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":98
* "ADV": ADV,
* "AUX": AUX,
* "CONJ": CONJ, # <<<<<<<<<<<<<<
* "CCONJ": CCONJ, # U20
* "DET": DET,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_CONJ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_CONJ, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":99
* "AUX": AUX,
* "CONJ": CONJ,
* "CCONJ": CCONJ, # U20 # <<<<<<<<<<<<<<
* "DET": DET,
* "INTJ": INTJ,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_CCONJ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_CCONJ, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":100
* "CONJ": CONJ,
* "CCONJ": CCONJ, # U20
* "DET": DET, # <<<<<<<<<<<<<<
* "INTJ": INTJ,
* "NOUN": NOUN,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DET); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DET, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":101
* "CCONJ": CCONJ, # U20
* "DET": DET,
* "INTJ": INTJ, # <<<<<<<<<<<<<<
* "NOUN": NOUN,
* "NUM": NUM,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_INTJ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_INTJ, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":102
* "DET": DET,
* "INTJ": INTJ,
* "NOUN": NOUN, # <<<<<<<<<<<<<<
* "NUM": NUM,
* "PART": PART,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_NOUN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_NOUN, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":103
* "INTJ": INTJ,
* "NOUN": NOUN,
* "NUM": NUM, # <<<<<<<<<<<<<<
* "PART": PART,
* "PRON": PRON,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_NUM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_NUM, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":104
* "NOUN": NOUN,
* "NUM": NUM,
* "PART": PART, # <<<<<<<<<<<<<<
* "PRON": PRON,
* "PROPN": PROPN,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PART); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PART, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":105
* "NUM": NUM,
* "PART": PART,
* "PRON": PRON, # <<<<<<<<<<<<<<
* "PROPN": PROPN,
* "PUNCT": PUNCT,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PRON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PRON, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":106
* "PART": PART,
* "PRON": PRON,
* "PROPN": PROPN, # <<<<<<<<<<<<<<
* "PUNCT": PUNCT,
* "SCONJ": SCONJ,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PROPN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PROPN, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":107
* "PRON": PRON,
* "PROPN": PROPN,
* "PUNCT": PUNCT, # <<<<<<<<<<<<<<
* "SCONJ": SCONJ,
* "SYM": SYM,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PUNCT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PUNCT, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":108
* "PROPN": PROPN,
* "PUNCT": PUNCT,
* "SCONJ": SCONJ, # <<<<<<<<<<<<<<
* "SYM": SYM,
* "VERB": VERB,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_SCONJ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_SCONJ, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":109
* "PUNCT": PUNCT,
* "SCONJ": SCONJ,
* "SYM": SYM, # <<<<<<<<<<<<<<
* "VERB": VERB,
* "X": X,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_SYM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_SYM, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":110
* "SCONJ": SCONJ,
* "SYM": SYM,
* "VERB": VERB, # <<<<<<<<<<<<<<
* "X": X,
* "EOL": EOL,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_VERB); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_VERB, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":111
* "SYM": SYM,
* "VERB": VERB,
* "X": X, # <<<<<<<<<<<<<<
* "EOL": EOL,
* "SPACE": SPACE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_X); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_X, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":112
* "VERB": VERB,
* "X": X,
* "EOL": EOL, # <<<<<<<<<<<<<<
* "SPACE": SPACE,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_EOL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_EOL, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":113
* "X": X,
* "EOL": EOL,
* "SPACE": SPACE, # <<<<<<<<<<<<<<
*
* "DEPRECATED001": DEPRECATED001,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_SPACE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_SPACE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":115
* "SPACE": SPACE,
*
* "DEPRECATED001": DEPRECATED001, # <<<<<<<<<<<<<<
* "DEPRECATED002": DEPRECATED002,
* "DEPRECATED003": DEPRECATED003,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED001); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED001, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":116
*
* "DEPRECATED001": DEPRECATED001,
* "DEPRECATED002": DEPRECATED002, # <<<<<<<<<<<<<<
* "DEPRECATED003": DEPRECATED003,
* "DEPRECATED004": DEPRECATED004,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED002); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED002, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":117
* "DEPRECATED001": DEPRECATED001,
* "DEPRECATED002": DEPRECATED002,
* "DEPRECATED003": DEPRECATED003, # <<<<<<<<<<<<<<
* "DEPRECATED004": DEPRECATED004,
* "DEPRECATED005": DEPRECATED005,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED003); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED003, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":118
* "DEPRECATED002": DEPRECATED002,
* "DEPRECATED003": DEPRECATED003,
* "DEPRECATED004": DEPRECATED004, # <<<<<<<<<<<<<<
* "DEPRECATED005": DEPRECATED005,
* "DEPRECATED006": DEPRECATED006,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED004); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED004, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":119
* "DEPRECATED003": DEPRECATED003,
* "DEPRECATED004": DEPRECATED004,
* "DEPRECATED005": DEPRECATED005, # <<<<<<<<<<<<<<
* "DEPRECATED006": DEPRECATED006,
* "DEPRECATED007": DEPRECATED007,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED005); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED005, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":120
* "DEPRECATED004": DEPRECATED004,
* "DEPRECATED005": DEPRECATED005,
* "DEPRECATED006": DEPRECATED006, # <<<<<<<<<<<<<<
* "DEPRECATED007": DEPRECATED007,
* "DEPRECATED008": DEPRECATED008,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED006); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED006, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":121
* "DEPRECATED005": DEPRECATED005,
* "DEPRECATED006": DEPRECATED006,
* "DEPRECATED007": DEPRECATED007, # <<<<<<<<<<<<<<
* "DEPRECATED008": DEPRECATED008,
* "DEPRECATED009": DEPRECATED009,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED007); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED007, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":122
* "DEPRECATED006": DEPRECATED006,
* "DEPRECATED007": DEPRECATED007,
* "DEPRECATED008": DEPRECATED008, # <<<<<<<<<<<<<<
* "DEPRECATED009": DEPRECATED009,
* "DEPRECATED010": DEPRECATED010,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED008); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED008, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":123
* "DEPRECATED007": DEPRECATED007,
* "DEPRECATED008": DEPRECATED008,
* "DEPRECATED009": DEPRECATED009, # <<<<<<<<<<<<<<
* "DEPRECATED010": DEPRECATED010,
* "DEPRECATED011": DEPRECATED011,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED009); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED009, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":124
* "DEPRECATED008": DEPRECATED008,
* "DEPRECATED009": DEPRECATED009,
* "DEPRECATED010": DEPRECATED010, # <<<<<<<<<<<<<<
* "DEPRECATED011": DEPRECATED011,
* "DEPRECATED012": DEPRECATED012,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED010); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED010, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":125
* "DEPRECATED009": DEPRECATED009,
* "DEPRECATED010": DEPRECATED010,
* "DEPRECATED011": DEPRECATED011, # <<<<<<<<<<<<<<
* "DEPRECATED012": DEPRECATED012,
* "DEPRECATED013": DEPRECATED013,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED011); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED011, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":126
* "DEPRECATED010": DEPRECATED010,
* "DEPRECATED011": DEPRECATED011,
* "DEPRECATED012": DEPRECATED012, # <<<<<<<<<<<<<<
* "DEPRECATED013": DEPRECATED013,
* "DEPRECATED014": DEPRECATED014,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED012); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED012, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":127
* "DEPRECATED011": DEPRECATED011,
* "DEPRECATED012": DEPRECATED012,
* "DEPRECATED013": DEPRECATED013, # <<<<<<<<<<<<<<
* "DEPRECATED014": DEPRECATED014,
* "DEPRECATED015": DEPRECATED015,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED013); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED013, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":128
* "DEPRECATED012": DEPRECATED012,
* "DEPRECATED013": DEPRECATED013,
* "DEPRECATED014": DEPRECATED014, # <<<<<<<<<<<<<<
* "DEPRECATED015": DEPRECATED015,
* "DEPRECATED016": DEPRECATED016,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED014); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED014, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":129
* "DEPRECATED013": DEPRECATED013,
* "DEPRECATED014": DEPRECATED014,
* "DEPRECATED015": DEPRECATED015, # <<<<<<<<<<<<<<
* "DEPRECATED016": DEPRECATED016,
* "DEPRECATED017": DEPRECATED017,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED015); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED015, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":130
* "DEPRECATED014": DEPRECATED014,
* "DEPRECATED015": DEPRECATED015,
* "DEPRECATED016": DEPRECATED016, # <<<<<<<<<<<<<<
* "DEPRECATED017": DEPRECATED017,
* "DEPRECATED018": DEPRECATED018,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED016); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED016, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":131
* "DEPRECATED015": DEPRECATED015,
* "DEPRECATED016": DEPRECATED016,
* "DEPRECATED017": DEPRECATED017, # <<<<<<<<<<<<<<
* "DEPRECATED018": DEPRECATED018,
* "DEPRECATED019": DEPRECATED019,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED017); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED017, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":132
* "DEPRECATED016": DEPRECATED016,
* "DEPRECATED017": DEPRECATED017,
* "DEPRECATED018": DEPRECATED018, # <<<<<<<<<<<<<<
* "DEPRECATED019": DEPRECATED019,
* "DEPRECATED020": DEPRECATED020,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED018); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED018, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":133
* "DEPRECATED017": DEPRECATED017,
* "DEPRECATED018": DEPRECATED018,
* "DEPRECATED019": DEPRECATED019, # <<<<<<<<<<<<<<
* "DEPRECATED020": DEPRECATED020,
* "DEPRECATED021": DEPRECATED021,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED019); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED019, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":134
* "DEPRECATED018": DEPRECATED018,
* "DEPRECATED019": DEPRECATED019,
* "DEPRECATED020": DEPRECATED020, # <<<<<<<<<<<<<<
* "DEPRECATED021": DEPRECATED021,
* "DEPRECATED022": DEPRECATED022,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED020); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED020, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":135
* "DEPRECATED019": DEPRECATED019,
* "DEPRECATED020": DEPRECATED020,
* "DEPRECATED021": DEPRECATED021, # <<<<<<<<<<<<<<
* "DEPRECATED022": DEPRECATED022,
* "DEPRECATED023": DEPRECATED023,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED021); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED021, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":136
* "DEPRECATED020": DEPRECATED020,
* "DEPRECATED021": DEPRECATED021,
* "DEPRECATED022": DEPRECATED022, # <<<<<<<<<<<<<<
* "DEPRECATED023": DEPRECATED023,
* "DEPRECATED024": DEPRECATED024,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED022); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED022, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":137
* "DEPRECATED021": DEPRECATED021,
* "DEPRECATED022": DEPRECATED022,
* "DEPRECATED023": DEPRECATED023, # <<<<<<<<<<<<<<
* "DEPRECATED024": DEPRECATED024,
* "DEPRECATED025": DEPRECATED025,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED023); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED023, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":138
* "DEPRECATED022": DEPRECATED022,
* "DEPRECATED023": DEPRECATED023,
* "DEPRECATED024": DEPRECATED024, # <<<<<<<<<<<<<<
* "DEPRECATED025": DEPRECATED025,
* "DEPRECATED026": DEPRECATED026,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED024); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED024, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":139
* "DEPRECATED023": DEPRECATED023,
* "DEPRECATED024": DEPRECATED024,
* "DEPRECATED025": DEPRECATED025, # <<<<<<<<<<<<<<
* "DEPRECATED026": DEPRECATED026,
* "DEPRECATED027": DEPRECATED027,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED025); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED025, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":140
* "DEPRECATED024": DEPRECATED024,
* "DEPRECATED025": DEPRECATED025,
* "DEPRECATED026": DEPRECATED026, # <<<<<<<<<<<<<<
* "DEPRECATED027": DEPRECATED027,
* "DEPRECATED028": DEPRECATED028,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED026); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED026, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":141
* "DEPRECATED025": DEPRECATED025,
* "DEPRECATED026": DEPRECATED026,
* "DEPRECATED027": DEPRECATED027, # <<<<<<<<<<<<<<
* "DEPRECATED028": DEPRECATED028,
* "DEPRECATED029": DEPRECATED029,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED027); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED027, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":142
* "DEPRECATED026": DEPRECATED026,
* "DEPRECATED027": DEPRECATED027,
* "DEPRECATED028": DEPRECATED028, # <<<<<<<<<<<<<<
* "DEPRECATED029": DEPRECATED029,
* "DEPRECATED030": DEPRECATED030,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED028); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED028, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":143
* "DEPRECATED027": DEPRECATED027,
* "DEPRECATED028": DEPRECATED028,
* "DEPRECATED029": DEPRECATED029, # <<<<<<<<<<<<<<
* "DEPRECATED030": DEPRECATED030,
* "DEPRECATED031": DEPRECATED031,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED029); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED029, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":144
* "DEPRECATED028": DEPRECATED028,
* "DEPRECATED029": DEPRECATED029,
* "DEPRECATED030": DEPRECATED030, # <<<<<<<<<<<<<<
* "DEPRECATED031": DEPRECATED031,
* "DEPRECATED032": DEPRECATED032,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED030); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED030, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":145
* "DEPRECATED029": DEPRECATED029,
* "DEPRECATED030": DEPRECATED030,
* "DEPRECATED031": DEPRECATED031, # <<<<<<<<<<<<<<
* "DEPRECATED032": DEPRECATED032,
* "DEPRECATED033": DEPRECATED033,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED031); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED031, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":146
* "DEPRECATED030": DEPRECATED030,
* "DEPRECATED031": DEPRECATED031,
* "DEPRECATED032": DEPRECATED032, # <<<<<<<<<<<<<<
* "DEPRECATED033": DEPRECATED033,
* "DEPRECATED034": DEPRECATED034,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED032); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED032, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":147
* "DEPRECATED031": DEPRECATED031,
* "DEPRECATED032": DEPRECATED032,
* "DEPRECATED033": DEPRECATED033, # <<<<<<<<<<<<<<
* "DEPRECATED034": DEPRECATED034,
* "DEPRECATED035": DEPRECATED035,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED033); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED033, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":148
* "DEPRECATED032": DEPRECATED032,
* "DEPRECATED033": DEPRECATED033,
* "DEPRECATED034": DEPRECATED034, # <<<<<<<<<<<<<<
* "DEPRECATED035": DEPRECATED035,
* "DEPRECATED036": DEPRECATED036,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED034); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED034, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":149
* "DEPRECATED033": DEPRECATED033,
* "DEPRECATED034": DEPRECATED034,
* "DEPRECATED035": DEPRECATED035, # <<<<<<<<<<<<<<
* "DEPRECATED036": DEPRECATED036,
* "DEPRECATED037": DEPRECATED037,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED035); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED035, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":150
* "DEPRECATED034": DEPRECATED034,
* "DEPRECATED035": DEPRECATED035,
* "DEPRECATED036": DEPRECATED036, # <<<<<<<<<<<<<<
* "DEPRECATED037": DEPRECATED037,
* "DEPRECATED038": DEPRECATED038,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED036); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED036, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":151
* "DEPRECATED035": DEPRECATED035,
* "DEPRECATED036": DEPRECATED036,
* "DEPRECATED037": DEPRECATED037, # <<<<<<<<<<<<<<
* "DEPRECATED038": DEPRECATED038,
* "DEPRECATED039": DEPRECATED039,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED037); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED037, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":152
* "DEPRECATED036": DEPRECATED036,
* "DEPRECATED037": DEPRECATED037,
* "DEPRECATED038": DEPRECATED038, # <<<<<<<<<<<<<<
* "DEPRECATED039": DEPRECATED039,
* "DEPRECATED040": DEPRECATED040,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED038); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED038, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":153
* "DEPRECATED037": DEPRECATED037,
* "DEPRECATED038": DEPRECATED038,
* "DEPRECATED039": DEPRECATED039, # <<<<<<<<<<<<<<
* "DEPRECATED040": DEPRECATED040,
* "DEPRECATED041": DEPRECATED041,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED039); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED039, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":154
* "DEPRECATED038": DEPRECATED038,
* "DEPRECATED039": DEPRECATED039,
* "DEPRECATED040": DEPRECATED040, # <<<<<<<<<<<<<<
* "DEPRECATED041": DEPRECATED041,
* "DEPRECATED042": DEPRECATED042,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED040); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED040, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":155
* "DEPRECATED039": DEPRECATED039,
* "DEPRECATED040": DEPRECATED040,
* "DEPRECATED041": DEPRECATED041, # <<<<<<<<<<<<<<
* "DEPRECATED042": DEPRECATED042,
* "DEPRECATED043": DEPRECATED043,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED041); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED041, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":156
* "DEPRECATED040": DEPRECATED040,
* "DEPRECATED041": DEPRECATED041,
* "DEPRECATED042": DEPRECATED042, # <<<<<<<<<<<<<<
* "DEPRECATED043": DEPRECATED043,
* "DEPRECATED044": DEPRECATED044,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED042); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED042, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":157
* "DEPRECATED041": DEPRECATED041,
* "DEPRECATED042": DEPRECATED042,
* "DEPRECATED043": DEPRECATED043, # <<<<<<<<<<<<<<
* "DEPRECATED044": DEPRECATED044,
* "DEPRECATED045": DEPRECATED045,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED043); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED043, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":158
* "DEPRECATED042": DEPRECATED042,
* "DEPRECATED043": DEPRECATED043,
* "DEPRECATED044": DEPRECATED044, # <<<<<<<<<<<<<<
* "DEPRECATED045": DEPRECATED045,
* "DEPRECATED046": DEPRECATED046,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED044); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED044, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":159
* "DEPRECATED043": DEPRECATED043,
* "DEPRECATED044": DEPRECATED044,
* "DEPRECATED045": DEPRECATED045, # <<<<<<<<<<<<<<
* "DEPRECATED046": DEPRECATED046,
* "DEPRECATED047": DEPRECATED047,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED045); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED045, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":160
* "DEPRECATED044": DEPRECATED044,
* "DEPRECATED045": DEPRECATED045,
* "DEPRECATED046": DEPRECATED046, # <<<<<<<<<<<<<<
* "DEPRECATED047": DEPRECATED047,
* "DEPRECATED048": DEPRECATED048,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED046); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED046, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":161
* "DEPRECATED045": DEPRECATED045,
* "DEPRECATED046": DEPRECATED046,
* "DEPRECATED047": DEPRECATED047, # <<<<<<<<<<<<<<
* "DEPRECATED048": DEPRECATED048,
* "DEPRECATED049": DEPRECATED049,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED047); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED047, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":162
* "DEPRECATED046": DEPRECATED046,
* "DEPRECATED047": DEPRECATED047,
* "DEPRECATED048": DEPRECATED048, # <<<<<<<<<<<<<<
* "DEPRECATED049": DEPRECATED049,
* "DEPRECATED050": DEPRECATED050,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED048); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED048, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":163
* "DEPRECATED047": DEPRECATED047,
* "DEPRECATED048": DEPRECATED048,
* "DEPRECATED049": DEPRECATED049, # <<<<<<<<<<<<<<
* "DEPRECATED050": DEPRECATED050,
* "DEPRECATED051": DEPRECATED051,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED049); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED049, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":164
* "DEPRECATED048": DEPRECATED048,
* "DEPRECATED049": DEPRECATED049,
* "DEPRECATED050": DEPRECATED050, # <<<<<<<<<<<<<<
* "DEPRECATED051": DEPRECATED051,
* "DEPRECATED052": DEPRECATED052,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED050); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED050, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":165
* "DEPRECATED049": DEPRECATED049,
* "DEPRECATED050": DEPRECATED050,
* "DEPRECATED051": DEPRECATED051, # <<<<<<<<<<<<<<
* "DEPRECATED052": DEPRECATED052,
* "DEPRECATED053": DEPRECATED053,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED051); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED051, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":166
* "DEPRECATED050": DEPRECATED050,
* "DEPRECATED051": DEPRECATED051,
* "DEPRECATED052": DEPRECATED052, # <<<<<<<<<<<<<<
* "DEPRECATED053": DEPRECATED053,
* "DEPRECATED054": DEPRECATED054,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED052); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED052, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":167
* "DEPRECATED051": DEPRECATED051,
* "DEPRECATED052": DEPRECATED052,
* "DEPRECATED053": DEPRECATED053, # <<<<<<<<<<<<<<
* "DEPRECATED054": DEPRECATED054,
* "DEPRECATED055": DEPRECATED055,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED053); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED053, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":168
* "DEPRECATED052": DEPRECATED052,
* "DEPRECATED053": DEPRECATED053,
* "DEPRECATED054": DEPRECATED054, # <<<<<<<<<<<<<<
* "DEPRECATED055": DEPRECATED055,
* "DEPRECATED056": DEPRECATED056,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED054); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED054, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":169
* "DEPRECATED053": DEPRECATED053,
* "DEPRECATED054": DEPRECATED054,
* "DEPRECATED055": DEPRECATED055, # <<<<<<<<<<<<<<
* "DEPRECATED056": DEPRECATED056,
* "DEPRECATED057": DEPRECATED057,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED055); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED055, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":170
* "DEPRECATED054": DEPRECATED054,
* "DEPRECATED055": DEPRECATED055,
* "DEPRECATED056": DEPRECATED056, # <<<<<<<<<<<<<<
* "DEPRECATED057": DEPRECATED057,
* "DEPRECATED058": DEPRECATED058,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED056); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED056, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":171
* "DEPRECATED055": DEPRECATED055,
* "DEPRECATED056": DEPRECATED056,
* "DEPRECATED057": DEPRECATED057, # <<<<<<<<<<<<<<
* "DEPRECATED058": DEPRECATED058,
* "DEPRECATED059": DEPRECATED059,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED057); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED057, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":172
* "DEPRECATED056": DEPRECATED056,
* "DEPRECATED057": DEPRECATED057,
* "DEPRECATED058": DEPRECATED058, # <<<<<<<<<<<<<<
* "DEPRECATED059": DEPRECATED059,
* "DEPRECATED060": DEPRECATED060,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED058); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED058, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":173
* "DEPRECATED057": DEPRECATED057,
* "DEPRECATED058": DEPRECATED058,
* "DEPRECATED059": DEPRECATED059, # <<<<<<<<<<<<<<
* "DEPRECATED060": DEPRECATED060,
* "DEPRECATED061": DEPRECATED061,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED059); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED059, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":174
* "DEPRECATED058": DEPRECATED058,
* "DEPRECATED059": DEPRECATED059,
* "DEPRECATED060": DEPRECATED060, # <<<<<<<<<<<<<<
* "DEPRECATED061": DEPRECATED061,
* "DEPRECATED062": DEPRECATED062,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED060); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED060, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":175
* "DEPRECATED059": DEPRECATED059,
* "DEPRECATED060": DEPRECATED060,
* "DEPRECATED061": DEPRECATED061, # <<<<<<<<<<<<<<
* "DEPRECATED062": DEPRECATED062,
* "DEPRECATED063": DEPRECATED063,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED061); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED061, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":176
* "DEPRECATED060": DEPRECATED060,
* "DEPRECATED061": DEPRECATED061,
* "DEPRECATED062": DEPRECATED062, # <<<<<<<<<<<<<<
* "DEPRECATED063": DEPRECATED063,
* "DEPRECATED064": DEPRECATED064,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED062); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED062, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":177
* "DEPRECATED061": DEPRECATED061,
* "DEPRECATED062": DEPRECATED062,
* "DEPRECATED063": DEPRECATED063, # <<<<<<<<<<<<<<
* "DEPRECATED064": DEPRECATED064,
* "DEPRECATED065": DEPRECATED065,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED063); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED063, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":178
* "DEPRECATED062": DEPRECATED062,
* "DEPRECATED063": DEPRECATED063,
* "DEPRECATED064": DEPRECATED064, # <<<<<<<<<<<<<<
* "DEPRECATED065": DEPRECATED065,
* "DEPRECATED066": DEPRECATED066,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED064); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED064, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":179
* "DEPRECATED063": DEPRECATED063,
* "DEPRECATED064": DEPRECATED064,
* "DEPRECATED065": DEPRECATED065, # <<<<<<<<<<<<<<
* "DEPRECATED066": DEPRECATED066,
* "DEPRECATED067": DEPRECATED067,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED065); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED065, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":180
* "DEPRECATED064": DEPRECATED064,
* "DEPRECATED065": DEPRECATED065,
* "DEPRECATED066": DEPRECATED066, # <<<<<<<<<<<<<<
* "DEPRECATED067": DEPRECATED067,
* "DEPRECATED068": DEPRECATED068,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED066); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED066, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":181
* "DEPRECATED065": DEPRECATED065,
* "DEPRECATED066": DEPRECATED066,
* "DEPRECATED067": DEPRECATED067, # <<<<<<<<<<<<<<
* "DEPRECATED068": DEPRECATED068,
* "DEPRECATED069": DEPRECATED069,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED067); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED067, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":182
* "DEPRECATED066": DEPRECATED066,
* "DEPRECATED067": DEPRECATED067,
* "DEPRECATED068": DEPRECATED068, # <<<<<<<<<<<<<<
* "DEPRECATED069": DEPRECATED069,
* "DEPRECATED070": DEPRECATED070,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED068); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED068, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":183
* "DEPRECATED067": DEPRECATED067,
* "DEPRECATED068": DEPRECATED068,
* "DEPRECATED069": DEPRECATED069, # <<<<<<<<<<<<<<
* "DEPRECATED070": DEPRECATED070,
* "DEPRECATED071": DEPRECATED071,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED069); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED069, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":184
* "DEPRECATED068": DEPRECATED068,
* "DEPRECATED069": DEPRECATED069,
* "DEPRECATED070": DEPRECATED070, # <<<<<<<<<<<<<<
* "DEPRECATED071": DEPRECATED071,
* "DEPRECATED072": DEPRECATED072,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED070); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED070, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":185
* "DEPRECATED069": DEPRECATED069,
* "DEPRECATED070": DEPRECATED070,
* "DEPRECATED071": DEPRECATED071, # <<<<<<<<<<<<<<
* "DEPRECATED072": DEPRECATED072,
* "DEPRECATED073": DEPRECATED073,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED071); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED071, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":186
* "DEPRECATED070": DEPRECATED070,
* "DEPRECATED071": DEPRECATED071,
* "DEPRECATED072": DEPRECATED072, # <<<<<<<<<<<<<<
* "DEPRECATED073": DEPRECATED073,
* "DEPRECATED074": DEPRECATED074,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED072); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED072, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":187
* "DEPRECATED071": DEPRECATED071,
* "DEPRECATED072": DEPRECATED072,
* "DEPRECATED073": DEPRECATED073, # <<<<<<<<<<<<<<
* "DEPRECATED074": DEPRECATED074,
* "DEPRECATED075": DEPRECATED075,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED073); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED073, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":188
* "DEPRECATED072": DEPRECATED072,
* "DEPRECATED073": DEPRECATED073,
* "DEPRECATED074": DEPRECATED074, # <<<<<<<<<<<<<<
* "DEPRECATED075": DEPRECATED075,
* "DEPRECATED076": DEPRECATED076,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED074); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED074, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":189
* "DEPRECATED073": DEPRECATED073,
* "DEPRECATED074": DEPRECATED074,
* "DEPRECATED075": DEPRECATED075, # <<<<<<<<<<<<<<
* "DEPRECATED076": DEPRECATED076,
* "DEPRECATED077": DEPRECATED077,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED075); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED075, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":190
* "DEPRECATED074": DEPRECATED074,
* "DEPRECATED075": DEPRECATED075,
* "DEPRECATED076": DEPRECATED076, # <<<<<<<<<<<<<<
* "DEPRECATED077": DEPRECATED077,
* "DEPRECATED078": DEPRECATED078,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED076); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED076, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":191
* "DEPRECATED075": DEPRECATED075,
* "DEPRECATED076": DEPRECATED076,
* "DEPRECATED077": DEPRECATED077, # <<<<<<<<<<<<<<
* "DEPRECATED078": DEPRECATED078,
* "DEPRECATED079": DEPRECATED079,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED077); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED077, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":192
* "DEPRECATED076": DEPRECATED076,
* "DEPRECATED077": DEPRECATED077,
* "DEPRECATED078": DEPRECATED078, # <<<<<<<<<<<<<<
* "DEPRECATED079": DEPRECATED079,
* "DEPRECATED080": DEPRECATED080,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED078); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED078, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":193
* "DEPRECATED077": DEPRECATED077,
* "DEPRECATED078": DEPRECATED078,
* "DEPRECATED079": DEPRECATED079, # <<<<<<<<<<<<<<
* "DEPRECATED080": DEPRECATED080,
* "DEPRECATED081": DEPRECATED081,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED079); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED079, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":194
* "DEPRECATED078": DEPRECATED078,
* "DEPRECATED079": DEPRECATED079,
* "DEPRECATED080": DEPRECATED080, # <<<<<<<<<<<<<<
* "DEPRECATED081": DEPRECATED081,
* "DEPRECATED082": DEPRECATED082,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED080); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED080, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":195
* "DEPRECATED079": DEPRECATED079,
* "DEPRECATED080": DEPRECATED080,
* "DEPRECATED081": DEPRECATED081, # <<<<<<<<<<<<<<
* "DEPRECATED082": DEPRECATED082,
* "DEPRECATED083": DEPRECATED083,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED081); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED081, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":196
* "DEPRECATED080": DEPRECATED080,
* "DEPRECATED081": DEPRECATED081,
* "DEPRECATED082": DEPRECATED082, # <<<<<<<<<<<<<<
* "DEPRECATED083": DEPRECATED083,
* "DEPRECATED084": DEPRECATED084,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED082); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED082, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":197
* "DEPRECATED081": DEPRECATED081,
* "DEPRECATED082": DEPRECATED082,
* "DEPRECATED083": DEPRECATED083, # <<<<<<<<<<<<<<
* "DEPRECATED084": DEPRECATED084,
* "DEPRECATED085": DEPRECATED085,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED083); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED083, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":198
* "DEPRECATED082": DEPRECATED082,
* "DEPRECATED083": DEPRECATED083,
* "DEPRECATED084": DEPRECATED084, # <<<<<<<<<<<<<<
* "DEPRECATED085": DEPRECATED085,
* "DEPRECATED086": DEPRECATED086,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED084); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED084, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":199
* "DEPRECATED083": DEPRECATED083,
* "DEPRECATED084": DEPRECATED084,
* "DEPRECATED085": DEPRECATED085, # <<<<<<<<<<<<<<
* "DEPRECATED086": DEPRECATED086,
* "DEPRECATED087": DEPRECATED087,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED085); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED085, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":200
* "DEPRECATED084": DEPRECATED084,
* "DEPRECATED085": DEPRECATED085,
* "DEPRECATED086": DEPRECATED086, # <<<<<<<<<<<<<<
* "DEPRECATED087": DEPRECATED087,
* "DEPRECATED088": DEPRECATED088,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED086); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED086, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":201
* "DEPRECATED085": DEPRECATED085,
* "DEPRECATED086": DEPRECATED086,
* "DEPRECATED087": DEPRECATED087, # <<<<<<<<<<<<<<
* "DEPRECATED088": DEPRECATED088,
* "DEPRECATED089": DEPRECATED089,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED087); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED087, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":202
* "DEPRECATED086": DEPRECATED086,
* "DEPRECATED087": DEPRECATED087,
* "DEPRECATED088": DEPRECATED088, # <<<<<<<<<<<<<<
* "DEPRECATED089": DEPRECATED089,
* "DEPRECATED090": DEPRECATED090,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED088); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED088, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":203
* "DEPRECATED087": DEPRECATED087,
* "DEPRECATED088": DEPRECATED088,
* "DEPRECATED089": DEPRECATED089, # <<<<<<<<<<<<<<
* "DEPRECATED090": DEPRECATED090,
* "DEPRECATED091": DEPRECATED091,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED089); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED089, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":204
* "DEPRECATED088": DEPRECATED088,
* "DEPRECATED089": DEPRECATED089,
* "DEPRECATED090": DEPRECATED090, # <<<<<<<<<<<<<<
* "DEPRECATED091": DEPRECATED091,
* "DEPRECATED092": DEPRECATED092,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED090); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED090, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":205
* "DEPRECATED089": DEPRECATED089,
* "DEPRECATED090": DEPRECATED090,
* "DEPRECATED091": DEPRECATED091, # <<<<<<<<<<<<<<
* "DEPRECATED092": DEPRECATED092,
* "DEPRECATED093": DEPRECATED093,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED091); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED091, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":206
* "DEPRECATED090": DEPRECATED090,
* "DEPRECATED091": DEPRECATED091,
* "DEPRECATED092": DEPRECATED092, # <<<<<<<<<<<<<<
* "DEPRECATED093": DEPRECATED093,
* "DEPRECATED094": DEPRECATED094,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED092); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED092, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":207
* "DEPRECATED091": DEPRECATED091,
* "DEPRECATED092": DEPRECATED092,
* "DEPRECATED093": DEPRECATED093, # <<<<<<<<<<<<<<
* "DEPRECATED094": DEPRECATED094,
* "DEPRECATED095": DEPRECATED095,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED093); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED093, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":208
* "DEPRECATED092": DEPRECATED092,
* "DEPRECATED093": DEPRECATED093,
* "DEPRECATED094": DEPRECATED094, # <<<<<<<<<<<<<<
* "DEPRECATED095": DEPRECATED095,
* "DEPRECATED096": DEPRECATED096,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED094); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED094, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":209
* "DEPRECATED093": DEPRECATED093,
* "DEPRECATED094": DEPRECATED094,
* "DEPRECATED095": DEPRECATED095, # <<<<<<<<<<<<<<
* "DEPRECATED096": DEPRECATED096,
* "DEPRECATED097": DEPRECATED097,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED095); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED095, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":210
* "DEPRECATED094": DEPRECATED094,
* "DEPRECATED095": DEPRECATED095,
* "DEPRECATED096": DEPRECATED096, # <<<<<<<<<<<<<<
* "DEPRECATED097": DEPRECATED097,
* "DEPRECATED098": DEPRECATED098,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED096); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED096, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":211
* "DEPRECATED095": DEPRECATED095,
* "DEPRECATED096": DEPRECATED096,
* "DEPRECATED097": DEPRECATED097, # <<<<<<<<<<<<<<
* "DEPRECATED098": DEPRECATED098,
* "DEPRECATED099": DEPRECATED099,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED097); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED097, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":212
* "DEPRECATED096": DEPRECATED096,
* "DEPRECATED097": DEPRECATED097,
* "DEPRECATED098": DEPRECATED098, # <<<<<<<<<<<<<<
* "DEPRECATED099": DEPRECATED099,
* "DEPRECATED100": DEPRECATED100,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED098); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED098, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":213
* "DEPRECATED097": DEPRECATED097,
* "DEPRECATED098": DEPRECATED098,
* "DEPRECATED099": DEPRECATED099, # <<<<<<<<<<<<<<
* "DEPRECATED100": DEPRECATED100,
* "DEPRECATED101": DEPRECATED101,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED099); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED099, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":214
* "DEPRECATED098": DEPRECATED098,
* "DEPRECATED099": DEPRECATED099,
* "DEPRECATED100": DEPRECATED100, # <<<<<<<<<<<<<<
* "DEPRECATED101": DEPRECATED101,
* "DEPRECATED102": DEPRECATED102,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED100); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED100, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":215
* "DEPRECATED099": DEPRECATED099,
* "DEPRECATED100": DEPRECATED100,
* "DEPRECATED101": DEPRECATED101, # <<<<<<<<<<<<<<
* "DEPRECATED102": DEPRECATED102,
* "DEPRECATED103": DEPRECATED103,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED101); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED101, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":216
* "DEPRECATED100": DEPRECATED100,
* "DEPRECATED101": DEPRECATED101,
* "DEPRECATED102": DEPRECATED102, # <<<<<<<<<<<<<<
* "DEPRECATED103": DEPRECATED103,
* "DEPRECATED104": DEPRECATED104,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED102); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED102, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":217
* "DEPRECATED101": DEPRECATED101,
* "DEPRECATED102": DEPRECATED102,
* "DEPRECATED103": DEPRECATED103, # <<<<<<<<<<<<<<
* "DEPRECATED104": DEPRECATED104,
* "DEPRECATED105": DEPRECATED105,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED103); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED103, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":218
* "DEPRECATED102": DEPRECATED102,
* "DEPRECATED103": DEPRECATED103,
* "DEPRECATED104": DEPRECATED104, # <<<<<<<<<<<<<<
* "DEPRECATED105": DEPRECATED105,
* "DEPRECATED106": DEPRECATED106,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED104); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED104, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":219
* "DEPRECATED103": DEPRECATED103,
* "DEPRECATED104": DEPRECATED104,
* "DEPRECATED105": DEPRECATED105, # <<<<<<<<<<<<<<
* "DEPRECATED106": DEPRECATED106,
* "DEPRECATED107": DEPRECATED107,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED105); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED105, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":220
* "DEPRECATED104": DEPRECATED104,
* "DEPRECATED105": DEPRECATED105,
* "DEPRECATED106": DEPRECATED106, # <<<<<<<<<<<<<<
* "DEPRECATED107": DEPRECATED107,
* "DEPRECATED108": DEPRECATED108,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED106); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED106, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":221
* "DEPRECATED105": DEPRECATED105,
* "DEPRECATED106": DEPRECATED106,
* "DEPRECATED107": DEPRECATED107, # <<<<<<<<<<<<<<
* "DEPRECATED108": DEPRECATED108,
* "DEPRECATED109": DEPRECATED109,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED107); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED107, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":222
* "DEPRECATED106": DEPRECATED106,
* "DEPRECATED107": DEPRECATED107,
* "DEPRECATED108": DEPRECATED108, # <<<<<<<<<<<<<<
* "DEPRECATED109": DEPRECATED109,
* "DEPRECATED110": DEPRECATED110,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED108); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED108, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":223
* "DEPRECATED107": DEPRECATED107,
* "DEPRECATED108": DEPRECATED108,
* "DEPRECATED109": DEPRECATED109, # <<<<<<<<<<<<<<
* "DEPRECATED110": DEPRECATED110,
* "DEPRECATED111": DEPRECATED111,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED109); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED109, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":224
* "DEPRECATED108": DEPRECATED108,
* "DEPRECATED109": DEPRECATED109,
* "DEPRECATED110": DEPRECATED110, # <<<<<<<<<<<<<<
* "DEPRECATED111": DEPRECATED111,
* "DEPRECATED112": DEPRECATED112,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED110); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED110, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":225
* "DEPRECATED109": DEPRECATED109,
* "DEPRECATED110": DEPRECATED110,
* "DEPRECATED111": DEPRECATED111, # <<<<<<<<<<<<<<
* "DEPRECATED112": DEPRECATED112,
* "DEPRECATED113": DEPRECATED113,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED111); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED111, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":226
* "DEPRECATED110": DEPRECATED110,
* "DEPRECATED111": DEPRECATED111,
* "DEPRECATED112": DEPRECATED112, # <<<<<<<<<<<<<<
* "DEPRECATED113": DEPRECATED113,
* "DEPRECATED114": DEPRECATED114,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED112); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED112, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":227
* "DEPRECATED111": DEPRECATED111,
* "DEPRECATED112": DEPRECATED112,
* "DEPRECATED113": DEPRECATED113, # <<<<<<<<<<<<<<
* "DEPRECATED114": DEPRECATED114,
* "DEPRECATED115": DEPRECATED115,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED113); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED113, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":228
* "DEPRECATED112": DEPRECATED112,
* "DEPRECATED113": DEPRECATED113,
* "DEPRECATED114": DEPRECATED114, # <<<<<<<<<<<<<<
* "DEPRECATED115": DEPRECATED115,
* "DEPRECATED116": DEPRECATED116,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED114); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 228, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED114, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":229
* "DEPRECATED113": DEPRECATED113,
* "DEPRECATED114": DEPRECATED114,
* "DEPRECATED115": DEPRECATED115, # <<<<<<<<<<<<<<
* "DEPRECATED116": DEPRECATED116,
* "DEPRECATED117": DEPRECATED117,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED115); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED115, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":230
* "DEPRECATED114": DEPRECATED114,
* "DEPRECATED115": DEPRECATED115,
* "DEPRECATED116": DEPRECATED116, # <<<<<<<<<<<<<<
* "DEPRECATED117": DEPRECATED117,
* "DEPRECATED118": DEPRECATED118,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED116); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED116, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":231
* "DEPRECATED115": DEPRECATED115,
* "DEPRECATED116": DEPRECATED116,
* "DEPRECATED117": DEPRECATED117, # <<<<<<<<<<<<<<
* "DEPRECATED118": DEPRECATED118,
* "DEPRECATED119": DEPRECATED119,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED117); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED117, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":232
* "DEPRECATED116": DEPRECATED116,
* "DEPRECATED117": DEPRECATED117,
* "DEPRECATED118": DEPRECATED118, # <<<<<<<<<<<<<<
* "DEPRECATED119": DEPRECATED119,
* "DEPRECATED120": DEPRECATED120,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED118); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 232, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED118, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":233
* "DEPRECATED117": DEPRECATED117,
* "DEPRECATED118": DEPRECATED118,
* "DEPRECATED119": DEPRECATED119, # <<<<<<<<<<<<<<
* "DEPRECATED120": DEPRECATED120,
* "DEPRECATED121": DEPRECATED121,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED119); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED119, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":234
* "DEPRECATED118": DEPRECATED118,
* "DEPRECATED119": DEPRECATED119,
* "DEPRECATED120": DEPRECATED120, # <<<<<<<<<<<<<<
* "DEPRECATED121": DEPRECATED121,
* "DEPRECATED122": DEPRECATED122,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED120); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED120, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":235
* "DEPRECATED119": DEPRECATED119,
* "DEPRECATED120": DEPRECATED120,
* "DEPRECATED121": DEPRECATED121, # <<<<<<<<<<<<<<
* "DEPRECATED122": DEPRECATED122,
* "DEPRECATED123": DEPRECATED123,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED121); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED121, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":236
* "DEPRECATED120": DEPRECATED120,
* "DEPRECATED121": DEPRECATED121,
* "DEPRECATED122": DEPRECATED122, # <<<<<<<<<<<<<<
* "DEPRECATED123": DEPRECATED123,
* "DEPRECATED124": DEPRECATED124,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED122); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED122, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":237
* "DEPRECATED121": DEPRECATED121,
* "DEPRECATED122": DEPRECATED122,
* "DEPRECATED123": DEPRECATED123, # <<<<<<<<<<<<<<
* "DEPRECATED124": DEPRECATED124,
* "DEPRECATED125": DEPRECATED125,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED123); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED123, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":238
* "DEPRECATED122": DEPRECATED122,
* "DEPRECATED123": DEPRECATED123,
* "DEPRECATED124": DEPRECATED124, # <<<<<<<<<<<<<<
* "DEPRECATED125": DEPRECATED125,
* "DEPRECATED126": DEPRECATED126,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED124); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED124, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":239
* "DEPRECATED123": DEPRECATED123,
* "DEPRECATED124": DEPRECATED124,
* "DEPRECATED125": DEPRECATED125, # <<<<<<<<<<<<<<
* "DEPRECATED126": DEPRECATED126,
* "DEPRECATED127": DEPRECATED127,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED125); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED125, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":240
* "DEPRECATED124": DEPRECATED124,
* "DEPRECATED125": DEPRECATED125,
* "DEPRECATED126": DEPRECATED126, # <<<<<<<<<<<<<<
* "DEPRECATED127": DEPRECATED127,
* "DEPRECATED128": DEPRECATED128,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED126); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED126, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":241
* "DEPRECATED125": DEPRECATED125,
* "DEPRECATED126": DEPRECATED126,
* "DEPRECATED127": DEPRECATED127, # <<<<<<<<<<<<<<
* "DEPRECATED128": DEPRECATED128,
* "DEPRECATED129": DEPRECATED129,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED127); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED127, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":242
* "DEPRECATED126": DEPRECATED126,
* "DEPRECATED127": DEPRECATED127,
* "DEPRECATED128": DEPRECATED128, # <<<<<<<<<<<<<<
* "DEPRECATED129": DEPRECATED129,
* "DEPRECATED130": DEPRECATED130,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED128); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED128, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":243
* "DEPRECATED127": DEPRECATED127,
* "DEPRECATED128": DEPRECATED128,
* "DEPRECATED129": DEPRECATED129, # <<<<<<<<<<<<<<
* "DEPRECATED130": DEPRECATED130,
* "DEPRECATED131": DEPRECATED131,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED129); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED129, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":244
* "DEPRECATED128": DEPRECATED128,
* "DEPRECATED129": DEPRECATED129,
* "DEPRECATED130": DEPRECATED130, # <<<<<<<<<<<<<<
* "DEPRECATED131": DEPRECATED131,
* "DEPRECATED132": DEPRECATED132,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED130); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED130, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":245
* "DEPRECATED129": DEPRECATED129,
* "DEPRECATED130": DEPRECATED130,
* "DEPRECATED131": DEPRECATED131, # <<<<<<<<<<<<<<
* "DEPRECATED132": DEPRECATED132,
* "DEPRECATED133": DEPRECATED133,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED131); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 245, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED131, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":246
* "DEPRECATED130": DEPRECATED130,
* "DEPRECATED131": DEPRECATED131,
* "DEPRECATED132": DEPRECATED132, # <<<<<<<<<<<<<<
* "DEPRECATED133": DEPRECATED133,
* "DEPRECATED134": DEPRECATED134,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED132); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 246, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED132, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":247
* "DEPRECATED131": DEPRECATED131,
* "DEPRECATED132": DEPRECATED132,
* "DEPRECATED133": DEPRECATED133, # <<<<<<<<<<<<<<
* "DEPRECATED134": DEPRECATED134,
* "DEPRECATED135": DEPRECATED135,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED133); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED133, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":248
* "DEPRECATED132": DEPRECATED132,
* "DEPRECATED133": DEPRECATED133,
* "DEPRECATED134": DEPRECATED134, # <<<<<<<<<<<<<<
* "DEPRECATED135": DEPRECATED135,
* "DEPRECATED136": DEPRECATED136,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED134); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED134, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":249
* "DEPRECATED133": DEPRECATED133,
* "DEPRECATED134": DEPRECATED134,
* "DEPRECATED135": DEPRECATED135, # <<<<<<<<<<<<<<
* "DEPRECATED136": DEPRECATED136,
* "DEPRECATED137": DEPRECATED137,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED135); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED135, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":250
* "DEPRECATED134": DEPRECATED134,
* "DEPRECATED135": DEPRECATED135,
* "DEPRECATED136": DEPRECATED136, # <<<<<<<<<<<<<<
* "DEPRECATED137": DEPRECATED137,
* "DEPRECATED138": DEPRECATED138,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED136); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED136, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":251
* "DEPRECATED135": DEPRECATED135,
* "DEPRECATED136": DEPRECATED136,
* "DEPRECATED137": DEPRECATED137, # <<<<<<<<<<<<<<
* "DEPRECATED138": DEPRECATED138,
* "DEPRECATED139": DEPRECATED139,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED137); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED137, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":252
* "DEPRECATED136": DEPRECATED136,
* "DEPRECATED137": DEPRECATED137,
* "DEPRECATED138": DEPRECATED138, # <<<<<<<<<<<<<<
* "DEPRECATED139": DEPRECATED139,
* "DEPRECATED140": DEPRECATED140,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED138); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED138, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":253
* "DEPRECATED137": DEPRECATED137,
* "DEPRECATED138": DEPRECATED138,
* "DEPRECATED139": DEPRECATED139, # <<<<<<<<<<<<<<
* "DEPRECATED140": DEPRECATED140,
* "DEPRECATED141": DEPRECATED141,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED139); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED139, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":254
* "DEPRECATED138": DEPRECATED138,
* "DEPRECATED139": DEPRECATED139,
* "DEPRECATED140": DEPRECATED140, # <<<<<<<<<<<<<<
* "DEPRECATED141": DEPRECATED141,
* "DEPRECATED142": DEPRECATED142,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED140); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 254, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED140, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":255
* "DEPRECATED139": DEPRECATED139,
* "DEPRECATED140": DEPRECATED140,
* "DEPRECATED141": DEPRECATED141, # <<<<<<<<<<<<<<
* "DEPRECATED142": DEPRECATED142,
* "DEPRECATED143": DEPRECATED143,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED141); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED141, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":256
* "DEPRECATED140": DEPRECATED140,
* "DEPRECATED141": DEPRECATED141,
* "DEPRECATED142": DEPRECATED142, # <<<<<<<<<<<<<<
* "DEPRECATED143": DEPRECATED143,
* "DEPRECATED144": DEPRECATED144,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED142); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED142, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":257
* "DEPRECATED141": DEPRECATED141,
* "DEPRECATED142": DEPRECATED142,
* "DEPRECATED143": DEPRECATED143, # <<<<<<<<<<<<<<
* "DEPRECATED144": DEPRECATED144,
* "DEPRECATED145": DEPRECATED145,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED143); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED143, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":258
* "DEPRECATED142": DEPRECATED142,
* "DEPRECATED143": DEPRECATED143,
* "DEPRECATED144": DEPRECATED144, # <<<<<<<<<<<<<<
* "DEPRECATED145": DEPRECATED145,
* "DEPRECATED146": DEPRECATED146,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED144); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED144, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":259
* "DEPRECATED143": DEPRECATED143,
* "DEPRECATED144": DEPRECATED144,
* "DEPRECATED145": DEPRECATED145, # <<<<<<<<<<<<<<
* "DEPRECATED146": DEPRECATED146,
* "DEPRECATED147": DEPRECATED147,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED145); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED145, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":260
* "DEPRECATED144": DEPRECATED144,
* "DEPRECATED145": DEPRECATED145,
* "DEPRECATED146": DEPRECATED146, # <<<<<<<<<<<<<<
* "DEPRECATED147": DEPRECATED147,
* "DEPRECATED148": DEPRECATED148,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED146); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED146, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":261
* "DEPRECATED145": DEPRECATED145,
* "DEPRECATED146": DEPRECATED146,
* "DEPRECATED147": DEPRECATED147, # <<<<<<<<<<<<<<
* "DEPRECATED148": DEPRECATED148,
* "DEPRECATED149": DEPRECATED149,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED147); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED147, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":262
* "DEPRECATED146": DEPRECATED146,
* "DEPRECATED147": DEPRECATED147,
* "DEPRECATED148": DEPRECATED148, # <<<<<<<<<<<<<<
* "DEPRECATED149": DEPRECATED149,
* "DEPRECATED150": DEPRECATED150,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED148); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED148, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":263
* "DEPRECATED147": DEPRECATED147,
* "DEPRECATED148": DEPRECATED148,
* "DEPRECATED149": DEPRECATED149, # <<<<<<<<<<<<<<
* "DEPRECATED150": DEPRECATED150,
* "DEPRECATED151": DEPRECATED151,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED149); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED149, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":264
* "DEPRECATED148": DEPRECATED148,
* "DEPRECATED149": DEPRECATED149,
* "DEPRECATED150": DEPRECATED150, # <<<<<<<<<<<<<<
* "DEPRECATED151": DEPRECATED151,
* "DEPRECATED152": DEPRECATED152,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED150); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED150, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":265
* "DEPRECATED149": DEPRECATED149,
* "DEPRECATED150": DEPRECATED150,
* "DEPRECATED151": DEPRECATED151, # <<<<<<<<<<<<<<
* "DEPRECATED152": DEPRECATED152,
* "DEPRECATED153": DEPRECATED153,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED151); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED151, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":266
* "DEPRECATED150": DEPRECATED150,
* "DEPRECATED151": DEPRECATED151,
* "DEPRECATED152": DEPRECATED152, # <<<<<<<<<<<<<<
* "DEPRECATED153": DEPRECATED153,
* "DEPRECATED154": DEPRECATED154,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED152); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED152, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":267
* "DEPRECATED151": DEPRECATED151,
* "DEPRECATED152": DEPRECATED152,
* "DEPRECATED153": DEPRECATED153, # <<<<<<<<<<<<<<
* "DEPRECATED154": DEPRECATED154,
* "DEPRECATED155": DEPRECATED155,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED153); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED153, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":268
* "DEPRECATED152": DEPRECATED152,
* "DEPRECATED153": DEPRECATED153,
* "DEPRECATED154": DEPRECATED154, # <<<<<<<<<<<<<<
* "DEPRECATED155": DEPRECATED155,
* "DEPRECATED156": DEPRECATED156,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED154); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED154, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":269
* "DEPRECATED153": DEPRECATED153,
* "DEPRECATED154": DEPRECATED154,
* "DEPRECATED155": DEPRECATED155, # <<<<<<<<<<<<<<
* "DEPRECATED156": DEPRECATED156,
* "DEPRECATED157": DEPRECATED157,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED155); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED155, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":270
* "DEPRECATED154": DEPRECATED154,
* "DEPRECATED155": DEPRECATED155,
* "DEPRECATED156": DEPRECATED156, # <<<<<<<<<<<<<<
* "DEPRECATED157": DEPRECATED157,
* "DEPRECATED158": DEPRECATED158,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED156); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED156, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":271
* "DEPRECATED155": DEPRECATED155,
* "DEPRECATED156": DEPRECATED156,
* "DEPRECATED157": DEPRECATED157, # <<<<<<<<<<<<<<
* "DEPRECATED158": DEPRECATED158,
* "DEPRECATED159": DEPRECATED159,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED157); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED157, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":272
* "DEPRECATED156": DEPRECATED156,
* "DEPRECATED157": DEPRECATED157,
* "DEPRECATED158": DEPRECATED158, # <<<<<<<<<<<<<<
* "DEPRECATED159": DEPRECATED159,
* "DEPRECATED160": DEPRECATED160,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED158); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED158, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":273
* "DEPRECATED157": DEPRECATED157,
* "DEPRECATED158": DEPRECATED158,
* "DEPRECATED159": DEPRECATED159, # <<<<<<<<<<<<<<
* "DEPRECATED160": DEPRECATED160,
* "DEPRECATED161": DEPRECATED161,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED159); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 273, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED159, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":274
* "DEPRECATED158": DEPRECATED158,
* "DEPRECATED159": DEPRECATED159,
* "DEPRECATED160": DEPRECATED160, # <<<<<<<<<<<<<<
* "DEPRECATED161": DEPRECATED161,
* "DEPRECATED162": DEPRECATED162,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED160); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED160, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":275
* "DEPRECATED159": DEPRECATED159,
* "DEPRECATED160": DEPRECATED160,
* "DEPRECATED161": DEPRECATED161, # <<<<<<<<<<<<<<
* "DEPRECATED162": DEPRECATED162,
* "DEPRECATED163": DEPRECATED163,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED161); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED161, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":276
* "DEPRECATED160": DEPRECATED160,
* "DEPRECATED161": DEPRECATED161,
* "DEPRECATED162": DEPRECATED162, # <<<<<<<<<<<<<<
* "DEPRECATED163": DEPRECATED163,
* "DEPRECATED164": DEPRECATED164,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED162); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED162, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":277
* "DEPRECATED161": DEPRECATED161,
* "DEPRECATED162": DEPRECATED162,
* "DEPRECATED163": DEPRECATED163, # <<<<<<<<<<<<<<
* "DEPRECATED164": DEPRECATED164,
* "DEPRECATED165": DEPRECATED165,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED163); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED163, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":278
* "DEPRECATED162": DEPRECATED162,
* "DEPRECATED163": DEPRECATED163,
* "DEPRECATED164": DEPRECATED164, # <<<<<<<<<<<<<<
* "DEPRECATED165": DEPRECATED165,
* "DEPRECATED166": DEPRECATED166,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED164); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED164, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":279
* "DEPRECATED163": DEPRECATED163,
* "DEPRECATED164": DEPRECATED164,
* "DEPRECATED165": DEPRECATED165, # <<<<<<<<<<<<<<
* "DEPRECATED166": DEPRECATED166,
* "DEPRECATED167": DEPRECATED167,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED165); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED165, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":280
* "DEPRECATED164": DEPRECATED164,
* "DEPRECATED165": DEPRECATED165,
* "DEPRECATED166": DEPRECATED166, # <<<<<<<<<<<<<<
* "DEPRECATED167": DEPRECATED167,
* "DEPRECATED168": DEPRECATED168,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED166); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED166, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":281
* "DEPRECATED165": DEPRECATED165,
* "DEPRECATED166": DEPRECATED166,
* "DEPRECATED167": DEPRECATED167, # <<<<<<<<<<<<<<
* "DEPRECATED168": DEPRECATED168,
* "DEPRECATED169": DEPRECATED169,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED167); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED167, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":282
* "DEPRECATED166": DEPRECATED166,
* "DEPRECATED167": DEPRECATED167,
* "DEPRECATED168": DEPRECATED168, # <<<<<<<<<<<<<<
* "DEPRECATED169": DEPRECATED169,
* "DEPRECATED170": DEPRECATED170,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED168); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 282, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED168, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":283
* "DEPRECATED167": DEPRECATED167,
* "DEPRECATED168": DEPRECATED168,
* "DEPRECATED169": DEPRECATED169, # <<<<<<<<<<<<<<
* "DEPRECATED170": DEPRECATED170,
* "DEPRECATED171": DEPRECATED171,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED169); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED169, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":284
* "DEPRECATED168": DEPRECATED168,
* "DEPRECATED169": DEPRECATED169,
* "DEPRECATED170": DEPRECATED170, # <<<<<<<<<<<<<<
* "DEPRECATED171": DEPRECATED171,
* "DEPRECATED172": DEPRECATED172,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED170); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED170, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":285
* "DEPRECATED169": DEPRECATED169,
* "DEPRECATED170": DEPRECATED170,
* "DEPRECATED171": DEPRECATED171, # <<<<<<<<<<<<<<
* "DEPRECATED172": DEPRECATED172,
* "DEPRECATED173": DEPRECATED173,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED171); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED171, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":286
* "DEPRECATED170": DEPRECATED170,
* "DEPRECATED171": DEPRECATED171,
* "DEPRECATED172": DEPRECATED172, # <<<<<<<<<<<<<<
* "DEPRECATED173": DEPRECATED173,
* "DEPRECATED174": DEPRECATED174,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED172); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED172, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":287
* "DEPRECATED171": DEPRECATED171,
* "DEPRECATED172": DEPRECATED172,
* "DEPRECATED173": DEPRECATED173, # <<<<<<<<<<<<<<
* "DEPRECATED174": DEPRECATED174,
* "DEPRECATED175": DEPRECATED175,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED173); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED173, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":288
* "DEPRECATED172": DEPRECATED172,
* "DEPRECATED173": DEPRECATED173,
* "DEPRECATED174": DEPRECATED174, # <<<<<<<<<<<<<<
* "DEPRECATED175": DEPRECATED175,
* "DEPRECATED176": DEPRECATED176,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED174); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED174, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":289
* "DEPRECATED173": DEPRECATED173,
* "DEPRECATED174": DEPRECATED174,
* "DEPRECATED175": DEPRECATED175, # <<<<<<<<<<<<<<
* "DEPRECATED176": DEPRECATED176,
* "DEPRECATED177": DEPRECATED177,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED175); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED175, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":290
* "DEPRECATED174": DEPRECATED174,
* "DEPRECATED175": DEPRECATED175,
* "DEPRECATED176": DEPRECATED176, # <<<<<<<<<<<<<<
* "DEPRECATED177": DEPRECATED177,
* "DEPRECATED178": DEPRECATED178,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED176); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 290, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED176, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":291
* "DEPRECATED175": DEPRECATED175,
* "DEPRECATED176": DEPRECATED176,
* "DEPRECATED177": DEPRECATED177, # <<<<<<<<<<<<<<
* "DEPRECATED178": DEPRECATED178,
* "DEPRECATED179": DEPRECATED179,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED177); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED177, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":292
* "DEPRECATED176": DEPRECATED176,
* "DEPRECATED177": DEPRECATED177,
* "DEPRECATED178": DEPRECATED178, # <<<<<<<<<<<<<<
* "DEPRECATED179": DEPRECATED179,
* "DEPRECATED180": DEPRECATED180,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED178); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED178, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":293
* "DEPRECATED177": DEPRECATED177,
* "DEPRECATED178": DEPRECATED178,
* "DEPRECATED179": DEPRECATED179, # <<<<<<<<<<<<<<
* "DEPRECATED180": DEPRECATED180,
* "DEPRECATED181": DEPRECATED181,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED179); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 293, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED179, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":294
* "DEPRECATED178": DEPRECATED178,
* "DEPRECATED179": DEPRECATED179,
* "DEPRECATED180": DEPRECATED180, # <<<<<<<<<<<<<<
* "DEPRECATED181": DEPRECATED181,
* "DEPRECATED182": DEPRECATED182,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED180); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED180, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":295
* "DEPRECATED179": DEPRECATED179,
* "DEPRECATED180": DEPRECATED180,
* "DEPRECATED181": DEPRECATED181, # <<<<<<<<<<<<<<
* "DEPRECATED182": DEPRECATED182,
* "DEPRECATED183": DEPRECATED183,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED181); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED181, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":296
* "DEPRECATED180": DEPRECATED180,
* "DEPRECATED181": DEPRECATED181,
* "DEPRECATED182": DEPRECATED182, # <<<<<<<<<<<<<<
* "DEPRECATED183": DEPRECATED183,
* "DEPRECATED184": DEPRECATED184,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED182); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED182, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":297
* "DEPRECATED181": DEPRECATED181,
* "DEPRECATED182": DEPRECATED182,
* "DEPRECATED183": DEPRECATED183, # <<<<<<<<<<<<<<
* "DEPRECATED184": DEPRECATED184,
* "DEPRECATED185": DEPRECATED185,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED183); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 297, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED183, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":298
* "DEPRECATED182": DEPRECATED182,
* "DEPRECATED183": DEPRECATED183,
* "DEPRECATED184": DEPRECATED184, # <<<<<<<<<<<<<<
* "DEPRECATED185": DEPRECATED185,
* "DEPRECATED186": DEPRECATED186,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED184); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED184, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":299
* "DEPRECATED183": DEPRECATED183,
* "DEPRECATED184": DEPRECATED184,
* "DEPRECATED185": DEPRECATED185, # <<<<<<<<<<<<<<
* "DEPRECATED186": DEPRECATED186,
* "DEPRECATED187": DEPRECATED187,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED185); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED185, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":300
* "DEPRECATED184": DEPRECATED184,
* "DEPRECATED185": DEPRECATED185,
* "DEPRECATED186": DEPRECATED186, # <<<<<<<<<<<<<<
* "DEPRECATED187": DEPRECATED187,
* "DEPRECATED188": DEPRECATED188,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED186); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED186, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":301
* "DEPRECATED185": DEPRECATED185,
* "DEPRECATED186": DEPRECATED186,
* "DEPRECATED187": DEPRECATED187, # <<<<<<<<<<<<<<
* "DEPRECATED188": DEPRECATED188,
* "DEPRECATED189": DEPRECATED189,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED187); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED187, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":302
* "DEPRECATED186": DEPRECATED186,
* "DEPRECATED187": DEPRECATED187,
* "DEPRECATED188": DEPRECATED188, # <<<<<<<<<<<<<<
* "DEPRECATED189": DEPRECATED189,
* "DEPRECATED190": DEPRECATED190,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED188); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED188, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":303
* "DEPRECATED187": DEPRECATED187,
* "DEPRECATED188": DEPRECATED188,
* "DEPRECATED189": DEPRECATED189, # <<<<<<<<<<<<<<
* "DEPRECATED190": DEPRECATED190,
* "DEPRECATED191": DEPRECATED191,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED189); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED189, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":304
* "DEPRECATED188": DEPRECATED188,
* "DEPRECATED189": DEPRECATED189,
* "DEPRECATED190": DEPRECATED190, # <<<<<<<<<<<<<<
* "DEPRECATED191": DEPRECATED191,
* "DEPRECATED192": DEPRECATED192,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED190); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 304, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED190, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":305
* "DEPRECATED189": DEPRECATED189,
* "DEPRECATED190": DEPRECATED190,
* "DEPRECATED191": DEPRECATED191, # <<<<<<<<<<<<<<
* "DEPRECATED192": DEPRECATED192,
* "DEPRECATED193": DEPRECATED193,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED191); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED191, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":306
* "DEPRECATED190": DEPRECATED190,
* "DEPRECATED191": DEPRECATED191,
* "DEPRECATED192": DEPRECATED192, # <<<<<<<<<<<<<<
* "DEPRECATED193": DEPRECATED193,
* "DEPRECATED194": DEPRECATED194,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED192); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED192, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":307
* "DEPRECATED191": DEPRECATED191,
* "DEPRECATED192": DEPRECATED192,
* "DEPRECATED193": DEPRECATED193, # <<<<<<<<<<<<<<
* "DEPRECATED194": DEPRECATED194,
* "DEPRECATED195": DEPRECATED195,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED193); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED193, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":308
* "DEPRECATED192": DEPRECATED192,
* "DEPRECATED193": DEPRECATED193,
* "DEPRECATED194": DEPRECATED194, # <<<<<<<<<<<<<<
* "DEPRECATED195": DEPRECATED195,
* "DEPRECATED196": DEPRECATED196,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED194); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED194, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":309
* "DEPRECATED193": DEPRECATED193,
* "DEPRECATED194": DEPRECATED194,
* "DEPRECATED195": DEPRECATED195, # <<<<<<<<<<<<<<
* "DEPRECATED196": DEPRECATED196,
* "DEPRECATED197": DEPRECATED197,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED195); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED195, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":310
* "DEPRECATED194": DEPRECATED194,
* "DEPRECATED195": DEPRECATED195,
* "DEPRECATED196": DEPRECATED196, # <<<<<<<<<<<<<<
* "DEPRECATED197": DEPRECATED197,
* "DEPRECATED198": DEPRECATED198,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED196); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED196, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":311
* "DEPRECATED195": DEPRECATED195,
* "DEPRECATED196": DEPRECATED196,
* "DEPRECATED197": DEPRECATED197, # <<<<<<<<<<<<<<
* "DEPRECATED198": DEPRECATED198,
* "DEPRECATED199": DEPRECATED199,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED197); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 311, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED197, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":312
* "DEPRECATED196": DEPRECATED196,
* "DEPRECATED197": DEPRECATED197,
* "DEPRECATED198": DEPRECATED198, # <<<<<<<<<<<<<<
* "DEPRECATED199": DEPRECATED199,
* "DEPRECATED200": DEPRECATED200,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED198); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED198, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":313
* "DEPRECATED197": DEPRECATED197,
* "DEPRECATED198": DEPRECATED198,
* "DEPRECATED199": DEPRECATED199, # <<<<<<<<<<<<<<
* "DEPRECATED200": DEPRECATED200,
* "DEPRECATED201": DEPRECATED201,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED199); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED199, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":314
* "DEPRECATED198": DEPRECATED198,
* "DEPRECATED199": DEPRECATED199,
* "DEPRECATED200": DEPRECATED200, # <<<<<<<<<<<<<<
* "DEPRECATED201": DEPRECATED201,
* "DEPRECATED202": DEPRECATED202,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED200); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED200, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":315
* "DEPRECATED199": DEPRECATED199,
* "DEPRECATED200": DEPRECATED200,
* "DEPRECATED201": DEPRECATED201, # <<<<<<<<<<<<<<
* "DEPRECATED202": DEPRECATED202,
* "DEPRECATED203": DEPRECATED203,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED201); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED201, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":316
* "DEPRECATED200": DEPRECATED200,
* "DEPRECATED201": DEPRECATED201,
* "DEPRECATED202": DEPRECATED202, # <<<<<<<<<<<<<<
* "DEPRECATED203": DEPRECATED203,
* "DEPRECATED204": DEPRECATED204,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED202); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED202, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":317
* "DEPRECATED201": DEPRECATED201,
* "DEPRECATED202": DEPRECATED202,
* "DEPRECATED203": DEPRECATED203, # <<<<<<<<<<<<<<
* "DEPRECATED204": DEPRECATED204,
* "DEPRECATED205": DEPRECATED205,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED203); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED203, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":318
* "DEPRECATED202": DEPRECATED202,
* "DEPRECATED203": DEPRECATED203,
* "DEPRECATED204": DEPRECATED204, # <<<<<<<<<<<<<<
* "DEPRECATED205": DEPRECATED205,
* "DEPRECATED206": DEPRECATED206,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED204); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED204, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":319
* "DEPRECATED203": DEPRECATED203,
* "DEPRECATED204": DEPRECATED204,
* "DEPRECATED205": DEPRECATED205, # <<<<<<<<<<<<<<
* "DEPRECATED206": DEPRECATED206,
* "DEPRECATED207": DEPRECATED207,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED205); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED205, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":320
* "DEPRECATED204": DEPRECATED204,
* "DEPRECATED205": DEPRECATED205,
* "DEPRECATED206": DEPRECATED206, # <<<<<<<<<<<<<<
* "DEPRECATED207": DEPRECATED207,
* "DEPRECATED208": DEPRECATED208,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED206); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED206, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":321
* "DEPRECATED205": DEPRECATED205,
* "DEPRECATED206": DEPRECATED206,
* "DEPRECATED207": DEPRECATED207, # <<<<<<<<<<<<<<
* "DEPRECATED208": DEPRECATED208,
* "DEPRECATED209": DEPRECATED209,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED207); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED207, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":322
* "DEPRECATED206": DEPRECATED206,
* "DEPRECATED207": DEPRECATED207,
* "DEPRECATED208": DEPRECATED208, # <<<<<<<<<<<<<<
* "DEPRECATED209": DEPRECATED209,
* "DEPRECATED210": DEPRECATED210,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED208); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 322, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED208, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":323
* "DEPRECATED207": DEPRECATED207,
* "DEPRECATED208": DEPRECATED208,
* "DEPRECATED209": DEPRECATED209, # <<<<<<<<<<<<<<
* "DEPRECATED210": DEPRECATED210,
* "DEPRECATED211": DEPRECATED211,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED209); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED209, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":324
* "DEPRECATED208": DEPRECATED208,
* "DEPRECATED209": DEPRECATED209,
* "DEPRECATED210": DEPRECATED210, # <<<<<<<<<<<<<<
* "DEPRECATED211": DEPRECATED211,
* "DEPRECATED212": DEPRECATED212,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED210); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED210, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":325
* "DEPRECATED209": DEPRECATED209,
* "DEPRECATED210": DEPRECATED210,
* "DEPRECATED211": DEPRECATED211, # <<<<<<<<<<<<<<
* "DEPRECATED212": DEPRECATED212,
* "DEPRECATED213": DEPRECATED213,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED211); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 325, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED211, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":326
* "DEPRECATED210": DEPRECATED210,
* "DEPRECATED211": DEPRECATED211,
* "DEPRECATED212": DEPRECATED212, # <<<<<<<<<<<<<<
* "DEPRECATED213": DEPRECATED213,
* "DEPRECATED214": DEPRECATED214,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED212); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED212, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":327
* "DEPRECATED211": DEPRECATED211,
* "DEPRECATED212": DEPRECATED212,
* "DEPRECATED213": DEPRECATED213, # <<<<<<<<<<<<<<
* "DEPRECATED214": DEPRECATED214,
* "DEPRECATED215": DEPRECATED215,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED213); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 327, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED213, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":328
* "DEPRECATED212": DEPRECATED212,
* "DEPRECATED213": DEPRECATED213,
* "DEPRECATED214": DEPRECATED214, # <<<<<<<<<<<<<<
* "DEPRECATED215": DEPRECATED215,
* "DEPRECATED216": DEPRECATED216,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED214); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 328, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED214, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":329
* "DEPRECATED213": DEPRECATED213,
* "DEPRECATED214": DEPRECATED214,
* "DEPRECATED215": DEPRECATED215, # <<<<<<<<<<<<<<
* "DEPRECATED216": DEPRECATED216,
* "DEPRECATED217": DEPRECATED217,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED215); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED215, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":330
* "DEPRECATED214": DEPRECATED214,
* "DEPRECATED215": DEPRECATED215,
* "DEPRECATED216": DEPRECATED216, # <<<<<<<<<<<<<<
* "DEPRECATED217": DEPRECATED217,
* "DEPRECATED218": DEPRECATED218,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED216); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 330, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED216, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":331
* "DEPRECATED215": DEPRECATED215,
* "DEPRECATED216": DEPRECATED216,
* "DEPRECATED217": DEPRECATED217, # <<<<<<<<<<<<<<
* "DEPRECATED218": DEPRECATED218,
* "DEPRECATED219": DEPRECATED219,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED217); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED217, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":332
* "DEPRECATED216": DEPRECATED216,
* "DEPRECATED217": DEPRECATED217,
* "DEPRECATED218": DEPRECATED218, # <<<<<<<<<<<<<<
* "DEPRECATED219": DEPRECATED219,
* "DEPRECATED220": DEPRECATED220,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED218); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED218, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":333
* "DEPRECATED217": DEPRECATED217,
* "DEPRECATED218": DEPRECATED218,
* "DEPRECATED219": DEPRECATED219, # <<<<<<<<<<<<<<
* "DEPRECATED220": DEPRECATED220,
* "DEPRECATED221": DEPRECATED221,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED219); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED219, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":334
* "DEPRECATED218": DEPRECATED218,
* "DEPRECATED219": DEPRECATED219,
* "DEPRECATED220": DEPRECATED220, # <<<<<<<<<<<<<<
* "DEPRECATED221": DEPRECATED221,
* "DEPRECATED222": DEPRECATED222,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED220); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED220, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":335
* "DEPRECATED219": DEPRECATED219,
* "DEPRECATED220": DEPRECATED220,
* "DEPRECATED221": DEPRECATED221, # <<<<<<<<<<<<<<
* "DEPRECATED222": DEPRECATED222,
* "DEPRECATED223": DEPRECATED223,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED221); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED221, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":336
* "DEPRECATED220": DEPRECATED220,
* "DEPRECATED221": DEPRECATED221,
* "DEPRECATED222": DEPRECATED222, # <<<<<<<<<<<<<<
* "DEPRECATED223": DEPRECATED223,
* "DEPRECATED224": DEPRECATED224,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED222); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 336, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED222, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":337
* "DEPRECATED221": DEPRECATED221,
* "DEPRECATED222": DEPRECATED222,
* "DEPRECATED223": DEPRECATED223, # <<<<<<<<<<<<<<
* "DEPRECATED224": DEPRECATED224,
* "DEPRECATED225": DEPRECATED225,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED223); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED223, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":338
* "DEPRECATED222": DEPRECATED222,
* "DEPRECATED223": DEPRECATED223,
* "DEPRECATED224": DEPRECATED224, # <<<<<<<<<<<<<<
* "DEPRECATED225": DEPRECATED225,
* "DEPRECATED226": DEPRECATED226,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED224); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 338, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED224, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":339
* "DEPRECATED223": DEPRECATED223,
* "DEPRECATED224": DEPRECATED224,
* "DEPRECATED225": DEPRECATED225, # <<<<<<<<<<<<<<
* "DEPRECATED226": DEPRECATED226,
* "DEPRECATED227": DEPRECATED227,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED225); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 339, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED225, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":340
* "DEPRECATED224": DEPRECATED224,
* "DEPRECATED225": DEPRECATED225,
* "DEPRECATED226": DEPRECATED226, # <<<<<<<<<<<<<<
* "DEPRECATED227": DEPRECATED227,
* "DEPRECATED228": DEPRECATED228,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED226); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 340, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED226, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":341
* "DEPRECATED225": DEPRECATED225,
* "DEPRECATED226": DEPRECATED226,
* "DEPRECATED227": DEPRECATED227, # <<<<<<<<<<<<<<
* "DEPRECATED228": DEPRECATED228,
* "DEPRECATED229": DEPRECATED229,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED227); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED227, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":342
* "DEPRECATED226": DEPRECATED226,
* "DEPRECATED227": DEPRECATED227,
* "DEPRECATED228": DEPRECATED228, # <<<<<<<<<<<<<<
* "DEPRECATED229": DEPRECATED229,
* "DEPRECATED230": DEPRECATED230,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED228); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED228, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":343
* "DEPRECATED227": DEPRECATED227,
* "DEPRECATED228": DEPRECATED228,
* "DEPRECATED229": DEPRECATED229, # <<<<<<<<<<<<<<
* "DEPRECATED230": DEPRECATED230,
* "DEPRECATED231": DEPRECATED231,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED229); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 343, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED229, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":344
* "DEPRECATED228": DEPRECATED228,
* "DEPRECATED229": DEPRECATED229,
* "DEPRECATED230": DEPRECATED230, # <<<<<<<<<<<<<<
* "DEPRECATED231": DEPRECATED231,
* "DEPRECATED232": DEPRECATED232,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED230); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED230, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":345
* "DEPRECATED229": DEPRECATED229,
* "DEPRECATED230": DEPRECATED230,
* "DEPRECATED231": DEPRECATED231, # <<<<<<<<<<<<<<
* "DEPRECATED232": DEPRECATED232,
* "DEPRECATED233": DEPRECATED233,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED231); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED231, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":346
* "DEPRECATED230": DEPRECATED230,
* "DEPRECATED231": DEPRECATED231,
* "DEPRECATED232": DEPRECATED232, # <<<<<<<<<<<<<<
* "DEPRECATED233": DEPRECATED233,
* "DEPRECATED234": DEPRECATED234,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED232); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED232, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":347
* "DEPRECATED231": DEPRECATED231,
* "DEPRECATED232": DEPRECATED232,
* "DEPRECATED233": DEPRECATED233, # <<<<<<<<<<<<<<
* "DEPRECATED234": DEPRECATED234,
* "DEPRECATED235": DEPRECATED235,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED233); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED233, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":348
* "DEPRECATED232": DEPRECATED232,
* "DEPRECATED233": DEPRECATED233,
* "DEPRECATED234": DEPRECATED234, # <<<<<<<<<<<<<<
* "DEPRECATED235": DEPRECATED235,
* "DEPRECATED236": DEPRECATED236,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED234); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED234, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":349
* "DEPRECATED233": DEPRECATED233,
* "DEPRECATED234": DEPRECATED234,
* "DEPRECATED235": DEPRECATED235, # <<<<<<<<<<<<<<
* "DEPRECATED236": DEPRECATED236,
* "DEPRECATED237": DEPRECATED237,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED235); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 349, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED235, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":350
* "DEPRECATED234": DEPRECATED234,
* "DEPRECATED235": DEPRECATED235,
* "DEPRECATED236": DEPRECATED236, # <<<<<<<<<<<<<<
* "DEPRECATED237": DEPRECATED237,
* "DEPRECATED238": DEPRECATED238,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED236); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED236, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":351
* "DEPRECATED235": DEPRECATED235,
* "DEPRECATED236": DEPRECATED236,
* "DEPRECATED237": DEPRECATED237, # <<<<<<<<<<<<<<
* "DEPRECATED238": DEPRECATED238,
* "DEPRECATED239": DEPRECATED239,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED237); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED237, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":352
* "DEPRECATED236": DEPRECATED236,
* "DEPRECATED237": DEPRECATED237,
* "DEPRECATED238": DEPRECATED238, # <<<<<<<<<<<<<<
* "DEPRECATED239": DEPRECATED239,
* "DEPRECATED240": DEPRECATED240,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED238); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED238, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":353
* "DEPRECATED237": DEPRECATED237,
* "DEPRECATED238": DEPRECATED238,
* "DEPRECATED239": DEPRECATED239, # <<<<<<<<<<<<<<
* "DEPRECATED240": DEPRECATED240,
* "DEPRECATED241": DEPRECATED241,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED239); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 353, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED239, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":354
* "DEPRECATED238": DEPRECATED238,
* "DEPRECATED239": DEPRECATED239,
* "DEPRECATED240": DEPRECATED240, # <<<<<<<<<<<<<<
* "DEPRECATED241": DEPRECATED241,
* "DEPRECATED242": DEPRECATED242,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED240); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED240, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":355
* "DEPRECATED239": DEPRECATED239,
* "DEPRECATED240": DEPRECATED240,
* "DEPRECATED241": DEPRECATED241, # <<<<<<<<<<<<<<
* "DEPRECATED242": DEPRECATED242,
* "DEPRECATED243": DEPRECATED243,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED241); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED241, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":356
* "DEPRECATED240": DEPRECATED240,
* "DEPRECATED241": DEPRECATED241,
* "DEPRECATED242": DEPRECATED242, # <<<<<<<<<<<<<<
* "DEPRECATED243": DEPRECATED243,
* "DEPRECATED244": DEPRECATED244,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED242); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED242, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":357
* "DEPRECATED241": DEPRECATED241,
* "DEPRECATED242": DEPRECATED242,
* "DEPRECATED243": DEPRECATED243, # <<<<<<<<<<<<<<
* "DEPRECATED244": DEPRECATED244,
* "DEPRECATED245": DEPRECATED245,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED243); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED243, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":358
* "DEPRECATED242": DEPRECATED242,
* "DEPRECATED243": DEPRECATED243,
* "DEPRECATED244": DEPRECATED244, # <<<<<<<<<<<<<<
* "DEPRECATED245": DEPRECATED245,
* "DEPRECATED246": DEPRECATED246,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED244); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED244, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":359
* "DEPRECATED243": DEPRECATED243,
* "DEPRECATED244": DEPRECATED244,
* "DEPRECATED245": DEPRECATED245, # <<<<<<<<<<<<<<
* "DEPRECATED246": DEPRECATED246,
* "DEPRECATED247": DEPRECATED247,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED245); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED245, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":360
* "DEPRECATED244": DEPRECATED244,
* "DEPRECATED245": DEPRECATED245,
* "DEPRECATED246": DEPRECATED246, # <<<<<<<<<<<<<<
* "DEPRECATED247": DEPRECATED247,
* "DEPRECATED248": DEPRECATED248,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED246); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED246, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":361
* "DEPRECATED245": DEPRECATED245,
* "DEPRECATED246": DEPRECATED246,
* "DEPRECATED247": DEPRECATED247, # <<<<<<<<<<<<<<
* "DEPRECATED248": DEPRECATED248,
* "DEPRECATED249": DEPRECATED249,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED247); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED247, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":362
* "DEPRECATED246": DEPRECATED246,
* "DEPRECATED247": DEPRECATED247,
* "DEPRECATED248": DEPRECATED248, # <<<<<<<<<<<<<<
* "DEPRECATED249": DEPRECATED249,
* "DEPRECATED250": DEPRECATED250,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED248); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED248, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":363
* "DEPRECATED247": DEPRECATED247,
* "DEPRECATED248": DEPRECATED248,
* "DEPRECATED249": DEPRECATED249, # <<<<<<<<<<<<<<
* "DEPRECATED250": DEPRECATED250,
* "DEPRECATED251": DEPRECATED251,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED249); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 363, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED249, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":364
* "DEPRECATED248": DEPRECATED248,
* "DEPRECATED249": DEPRECATED249,
* "DEPRECATED250": DEPRECATED250, # <<<<<<<<<<<<<<
* "DEPRECATED251": DEPRECATED251,
* "DEPRECATED252": DEPRECATED252,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED250); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 364, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED250, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":365
* "DEPRECATED249": DEPRECATED249,
* "DEPRECATED250": DEPRECATED250,
* "DEPRECATED251": DEPRECATED251, # <<<<<<<<<<<<<<
* "DEPRECATED252": DEPRECATED252,
* "DEPRECATED253": DEPRECATED253,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED251); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED251, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":366
* "DEPRECATED250": DEPRECATED250,
* "DEPRECATED251": DEPRECATED251,
* "DEPRECATED252": DEPRECATED252, # <<<<<<<<<<<<<<
* "DEPRECATED253": DEPRECATED253,
* "DEPRECATED254": DEPRECATED254,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED252); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 366, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED252, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":367
* "DEPRECATED251": DEPRECATED251,
* "DEPRECATED252": DEPRECATED252,
* "DEPRECATED253": DEPRECATED253, # <<<<<<<<<<<<<<
* "DEPRECATED254": DEPRECATED254,
* "DEPRECATED255": DEPRECATED255,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED253); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 367, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED253, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":368
* "DEPRECATED252": DEPRECATED252,
* "DEPRECATED253": DEPRECATED253,
* "DEPRECATED254": DEPRECATED254, # <<<<<<<<<<<<<<
* "DEPRECATED255": DEPRECATED255,
* "DEPRECATED256": DEPRECATED256,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED254); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED254, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":369
* "DEPRECATED253": DEPRECATED253,
* "DEPRECATED254": DEPRECATED254,
* "DEPRECATED255": DEPRECATED255, # <<<<<<<<<<<<<<
* "DEPRECATED256": DEPRECATED256,
* "DEPRECATED257": DEPRECATED257,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED255); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 369, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED255, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":370
* "DEPRECATED254": DEPRECATED254,
* "DEPRECATED255": DEPRECATED255,
* "DEPRECATED256": DEPRECATED256, # <<<<<<<<<<<<<<
* "DEPRECATED257": DEPRECATED257,
* "DEPRECATED258": DEPRECATED258,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED256); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED256, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":371
* "DEPRECATED255": DEPRECATED255,
* "DEPRECATED256": DEPRECATED256,
* "DEPRECATED257": DEPRECATED257, # <<<<<<<<<<<<<<
* "DEPRECATED258": DEPRECATED258,
* "DEPRECATED259": DEPRECATED259,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED257); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED257, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":372
* "DEPRECATED256": DEPRECATED256,
* "DEPRECATED257": DEPRECATED257,
* "DEPRECATED258": DEPRECATED258, # <<<<<<<<<<<<<<
* "DEPRECATED259": DEPRECATED259,
* "DEPRECATED260": DEPRECATED260,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED258); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED258, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":373
* "DEPRECATED257": DEPRECATED257,
* "DEPRECATED258": DEPRECATED258,
* "DEPRECATED259": DEPRECATED259, # <<<<<<<<<<<<<<
* "DEPRECATED260": DEPRECATED260,
* "DEPRECATED261": DEPRECATED261,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED259); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED259, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":374
* "DEPRECATED258": DEPRECATED258,
* "DEPRECATED259": DEPRECATED259,
* "DEPRECATED260": DEPRECATED260, # <<<<<<<<<<<<<<
* "DEPRECATED261": DEPRECATED261,
* "DEPRECATED262": DEPRECATED262,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED260); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 374, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED260, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":375
* "DEPRECATED259": DEPRECATED259,
* "DEPRECATED260": DEPRECATED260,
* "DEPRECATED261": DEPRECATED261, # <<<<<<<<<<<<<<
* "DEPRECATED262": DEPRECATED262,
* "DEPRECATED263": DEPRECATED263,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED261); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 375, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED261, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":376
* "DEPRECATED260": DEPRECATED260,
* "DEPRECATED261": DEPRECATED261,
* "DEPRECATED262": DEPRECATED262, # <<<<<<<<<<<<<<
* "DEPRECATED263": DEPRECATED263,
* "DEPRECATED264": DEPRECATED264,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED262); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED262, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":377
* "DEPRECATED261": DEPRECATED261,
* "DEPRECATED262": DEPRECATED262,
* "DEPRECATED263": DEPRECATED263, # <<<<<<<<<<<<<<
* "DEPRECATED264": DEPRECATED264,
* "DEPRECATED265": DEPRECATED265,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED263); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED263, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":378
* "DEPRECATED262": DEPRECATED262,
* "DEPRECATED263": DEPRECATED263,
* "DEPRECATED264": DEPRECATED264, # <<<<<<<<<<<<<<
* "DEPRECATED265": DEPRECATED265,
* "DEPRECATED266": DEPRECATED266,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED264); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED264, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":379
* "DEPRECATED263": DEPRECATED263,
* "DEPRECATED264": DEPRECATED264,
* "DEPRECATED265": DEPRECATED265, # <<<<<<<<<<<<<<
* "DEPRECATED266": DEPRECATED266,
* "DEPRECATED267": DEPRECATED267,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED265); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED265, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":380
* "DEPRECATED264": DEPRECATED264,
* "DEPRECATED265": DEPRECATED265,
* "DEPRECATED266": DEPRECATED266, # <<<<<<<<<<<<<<
* "DEPRECATED267": DEPRECATED267,
* "DEPRECATED268": DEPRECATED268,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED266); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 380, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED266, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":381
* "DEPRECATED265": DEPRECATED265,
* "DEPRECATED266": DEPRECATED266,
* "DEPRECATED267": DEPRECATED267, # <<<<<<<<<<<<<<
* "DEPRECATED268": DEPRECATED268,
* "DEPRECATED269": DEPRECATED269,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED267); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED267, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":382
* "DEPRECATED266": DEPRECATED266,
* "DEPRECATED267": DEPRECATED267,
* "DEPRECATED268": DEPRECATED268, # <<<<<<<<<<<<<<
* "DEPRECATED269": DEPRECATED269,
* "DEPRECATED270": DEPRECATED270,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED268); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED268, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":383
* "DEPRECATED267": DEPRECATED267,
* "DEPRECATED268": DEPRECATED268,
* "DEPRECATED269": DEPRECATED269, # <<<<<<<<<<<<<<
* "DEPRECATED270": DEPRECATED270,
* "DEPRECATED271": DEPRECATED271,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED269); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED269, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":384
* "DEPRECATED268": DEPRECATED268,
* "DEPRECATED269": DEPRECATED269,
* "DEPRECATED270": DEPRECATED270, # <<<<<<<<<<<<<<
* "DEPRECATED271": DEPRECATED271,
* "DEPRECATED272": DEPRECATED272,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED270); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 384, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED270, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":385
* "DEPRECATED269": DEPRECATED269,
* "DEPRECATED270": DEPRECATED270,
* "DEPRECATED271": DEPRECATED271, # <<<<<<<<<<<<<<
* "DEPRECATED272": DEPRECATED272,
* "DEPRECATED273": DEPRECATED273,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED271); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 385, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED271, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":386
* "DEPRECATED270": DEPRECATED270,
* "DEPRECATED271": DEPRECATED271,
* "DEPRECATED272": DEPRECATED272, # <<<<<<<<<<<<<<
* "DEPRECATED273": DEPRECATED273,
* "DEPRECATED274": DEPRECATED274,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED272); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED272, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":387
* "DEPRECATED271": DEPRECATED271,
* "DEPRECATED272": DEPRECATED272,
* "DEPRECATED273": DEPRECATED273, # <<<<<<<<<<<<<<
* "DEPRECATED274": DEPRECATED274,
* "DEPRECATED275": DEPRECATED275,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED273); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 387, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED273, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":388
* "DEPRECATED272": DEPRECATED272,
* "DEPRECATED273": DEPRECATED273,
* "DEPRECATED274": DEPRECATED274, # <<<<<<<<<<<<<<
* "DEPRECATED275": DEPRECATED275,
* "DEPRECATED276": DEPRECATED276,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED274); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 388, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED274, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":389
* "DEPRECATED273": DEPRECATED273,
* "DEPRECATED274": DEPRECATED274,
* "DEPRECATED275": DEPRECATED275, # <<<<<<<<<<<<<<
* "DEPRECATED276": DEPRECATED276,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED275); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED275, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":390
* "DEPRECATED274": DEPRECATED274,
* "DEPRECATED275": DEPRECATED275,
* "DEPRECATED276": DEPRECATED276, # <<<<<<<<<<<<<<
*
* "PERSON": PERSON,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DEPRECATED276); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 390, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DEPRECATED276, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":392
* "DEPRECATED276": DEPRECATED276,
*
* "PERSON": PERSON, # <<<<<<<<<<<<<<
* "NORP": NORP,
* "FACILITY": FACILITY,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PERSON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 392, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PERSON, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":393
*
* "PERSON": PERSON,
* "NORP": NORP, # <<<<<<<<<<<<<<
* "FACILITY": FACILITY,
* "ORG": ORG,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_NORP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_NORP, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":394
* "PERSON": PERSON,
* "NORP": NORP,
* "FACILITY": FACILITY, # <<<<<<<<<<<<<<
* "ORG": ORG,
* "GPE": GPE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_FACILITY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 394, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FACILITY, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":395
* "NORP": NORP,
* "FACILITY": FACILITY,
* "ORG": ORG, # <<<<<<<<<<<<<<
* "GPE": GPE,
* "LOC": LOC,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ORG); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ORG, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":396
* "FACILITY": FACILITY,
* "ORG": ORG,
* "GPE": GPE, # <<<<<<<<<<<<<<
* "LOC": LOC,
* "PRODUCT": PRODUCT,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_GPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 396, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_GPE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":397
* "ORG": ORG,
* "GPE": GPE,
* "LOC": LOC, # <<<<<<<<<<<<<<
* "PRODUCT": PRODUCT,
* "EVENT": EVENT,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LOC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 397, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LOC, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":398
* "GPE": GPE,
* "LOC": LOC,
* "PRODUCT": PRODUCT, # <<<<<<<<<<<<<<
* "EVENT": EVENT,
* "WORK_OF_ART": WORK_OF_ART,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PRODUCT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PRODUCT, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":399
* "LOC": LOC,
* "PRODUCT": PRODUCT,
* "EVENT": EVENT, # <<<<<<<<<<<<<<
* "WORK_OF_ART": WORK_OF_ART,
* "LANGUAGE": LANGUAGE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_EVENT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 399, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_EVENT, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":400
* "PRODUCT": PRODUCT,
* "EVENT": EVENT,
* "WORK_OF_ART": WORK_OF_ART, # <<<<<<<<<<<<<<
* "LANGUAGE": LANGUAGE,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_WORK_OF_ART); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_WORK_OF_ART, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":401
* "EVENT": EVENT,
* "WORK_OF_ART": WORK_OF_ART,
* "LANGUAGE": LANGUAGE, # <<<<<<<<<<<<<<
*
* "DATE": DATE,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LANGUAGE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LANGUAGE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":403
* "LANGUAGE": LANGUAGE,
*
* "DATE": DATE, # <<<<<<<<<<<<<<
* "TIME": TIME,
* "PERCENT": PERCENT,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_DATE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DATE, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":404
*
* "DATE": DATE,
* "TIME": TIME, # <<<<<<<<<<<<<<
* "PERCENT": PERCENT,
* "MONEY": MONEY,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_TIME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_TIME, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":405
* "DATE": DATE,
* "TIME": TIME,
* "PERCENT": PERCENT, # <<<<<<<<<<<<<<
* "MONEY": MONEY,
* "QUANTITY": QUANTITY,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_PERCENT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PERCENT, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":406
* "TIME": TIME,
* "PERCENT": PERCENT,
* "MONEY": MONEY, # <<<<<<<<<<<<<<
* "QUANTITY": QUANTITY,
* "ORDINAL": ORDINAL,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_MONEY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_MONEY, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":407
* "PERCENT": PERCENT,
* "MONEY": MONEY,
* "QUANTITY": QUANTITY, # <<<<<<<<<<<<<<
* "ORDINAL": ORDINAL,
* "CARDINAL": CARDINAL,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_QUANTITY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 407, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_QUANTITY, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":408
* "MONEY": MONEY,
* "QUANTITY": QUANTITY,
* "ORDINAL": ORDINAL, # <<<<<<<<<<<<<<
* "CARDINAL": CARDINAL,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ORDINAL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 408, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ORDINAL, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":409
* "QUANTITY": QUANTITY,
* "ORDINAL": ORDINAL,
* "CARDINAL": CARDINAL, # <<<<<<<<<<<<<<
*
* "acomp": acomp,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_CARDINAL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_CARDINAL, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":411
* "CARDINAL": CARDINAL,
*
* "acomp": acomp, # <<<<<<<<<<<<<<
* "advcl": advcl,
* "advmod": advmod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_acomp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_acomp, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":412
*
* "acomp": acomp,
* "advcl": advcl, # <<<<<<<<<<<<<<
* "advmod": advmod,
* "agent": agent,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_advcl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_advcl, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":413
* "acomp": acomp,
* "advcl": advcl,
* "advmod": advmod, # <<<<<<<<<<<<<<
* "agent": agent,
* "amod": amod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_advmod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_advmod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":414
* "advcl": advcl,
* "advmod": advmod,
* "agent": agent, # <<<<<<<<<<<<<<
* "amod": amod,
* "appos": appos,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_agent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_agent, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":415
* "advmod": advmod,
* "agent": agent,
* "amod": amod, # <<<<<<<<<<<<<<
* "appos": appos,
* "attr": attr,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_amod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_amod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":416
* "agent": agent,
* "amod": amod,
* "appos": appos, # <<<<<<<<<<<<<<
* "attr": attr,
* "aux": aux,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_appos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_appos, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":417
* "amod": amod,
* "appos": appos,
* "attr": attr, # <<<<<<<<<<<<<<
* "aux": aux,
* "auxpass": auxpass,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_attr, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":418
* "appos": appos,
* "attr": attr,
* "aux": aux, # <<<<<<<<<<<<<<
* "auxpass": auxpass,
* "cc": cc,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_aux); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_aux, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":419
* "attr": attr,
* "aux": aux,
* "auxpass": auxpass, # <<<<<<<<<<<<<<
* "cc": cc,
* "ccomp": ccomp,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_auxpass); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_auxpass, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":420
* "aux": aux,
* "auxpass": auxpass,
* "cc": cc, # <<<<<<<<<<<<<<
* "ccomp": ccomp,
* "complm": complm,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_cc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_cc, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":421
* "auxpass": auxpass,
* "cc": cc,
* "ccomp": ccomp, # <<<<<<<<<<<<<<
* "complm": complm,
* "conj": conj,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_ccomp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ccomp, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":422
* "cc": cc,
* "ccomp": ccomp,
* "complm": complm, # <<<<<<<<<<<<<<
* "conj": conj,
* "cop": cop, # U20
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_complm); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_complm, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":423
* "ccomp": ccomp,
* "complm": complm,
* "conj": conj, # <<<<<<<<<<<<<<
* "cop": cop, # U20
* "csubj": csubj,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_conj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_conj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":424
* "complm": complm,
* "conj": conj,
* "cop": cop, # U20 # <<<<<<<<<<<<<<
* "csubj": csubj,
* "csubjpass": csubjpass,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_cop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_cop, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":425
* "conj": conj,
* "cop": cop, # U20
* "csubj": csubj, # <<<<<<<<<<<<<<
* "csubjpass": csubjpass,
* "dep": dep,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_csubj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 425, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_csubj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":426
* "cop": cop, # U20
* "csubj": csubj,
* "csubjpass": csubjpass, # <<<<<<<<<<<<<<
* "dep": dep,
* "det": det,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_csubjpass); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_csubjpass, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":427
* "csubj": csubj,
* "csubjpass": csubjpass,
* "dep": dep, # <<<<<<<<<<<<<<
* "det": det,
* "dobj": dobj,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_dep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dep, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":428
* "csubjpass": csubjpass,
* "dep": dep,
* "det": det, # <<<<<<<<<<<<<<
* "dobj": dobj,
* "expl": expl,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_det); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 428, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_det, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":429
* "dep": dep,
* "det": det,
* "dobj": dobj, # <<<<<<<<<<<<<<
* "expl": expl,
* "hmod": hmod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_dobj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 429, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dobj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":430
* "det": det,
* "dobj": dobj,
* "expl": expl, # <<<<<<<<<<<<<<
* "hmod": hmod,
* "hyph": hyph,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_expl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 430, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_expl, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":431
* "dobj": dobj,
* "expl": expl,
* "hmod": hmod, # <<<<<<<<<<<<<<
* "hyph": hyph,
* "infmod": infmod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_hmod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 431, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_hmod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":432
* "expl": expl,
* "hmod": hmod,
* "hyph": hyph, # <<<<<<<<<<<<<<
* "infmod": infmod,
* "intj": intj,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_hyph); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 432, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_hyph, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":433
* "hmod": hmod,
* "hyph": hyph,
* "infmod": infmod, # <<<<<<<<<<<<<<
* "intj": intj,
* "iobj": iobj,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_infmod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_infmod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":434
* "hyph": hyph,
* "infmod": infmod,
* "intj": intj, # <<<<<<<<<<<<<<
* "iobj": iobj,
* "mark": mark,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_intj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 434, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_intj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":435
* "infmod": infmod,
* "intj": intj,
* "iobj": iobj, # <<<<<<<<<<<<<<
* "mark": mark,
* "meta": meta,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_iobj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_iobj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":436
* "intj": intj,
* "iobj": iobj,
* "mark": mark, # <<<<<<<<<<<<<<
* "meta": meta,
* "neg": neg,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_mark); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mark, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":437
* "iobj": iobj,
* "mark": mark,
* "meta": meta, # <<<<<<<<<<<<<<
* "neg": neg,
* "nmod": nmod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_meta); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 437, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_meta, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":438
* "mark": mark,
* "meta": meta,
* "neg": neg, # <<<<<<<<<<<<<<
* "nmod": nmod,
* "nn": nn,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_neg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_neg, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":439
* "meta": meta,
* "neg": neg,
* "nmod": nmod, # <<<<<<<<<<<<<<
* "nn": nn,
* "npadvmod": npadvmod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_nmod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_nmod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":440
* "neg": neg,
* "nmod": nmod,
* "nn": nn, # <<<<<<<<<<<<<<
* "npadvmod": npadvmod,
* "nsubj": nsubj,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_nn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_nn, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":441
* "nmod": nmod,
* "nn": nn,
* "npadvmod": npadvmod, # <<<<<<<<<<<<<<
* "nsubj": nsubj,
* "nsubjpass": nsubjpass,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_npadvmod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 441, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_npadvmod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":442
* "nn": nn,
* "npadvmod": npadvmod,
* "nsubj": nsubj, # <<<<<<<<<<<<<<
* "nsubjpass": nsubjpass,
* "num": num,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_nsubj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_nsubj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":443
* "npadvmod": npadvmod,
* "nsubj": nsubj,
* "nsubjpass": nsubjpass, # <<<<<<<<<<<<<<
* "num": num,
* "number": number,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_nsubjpass); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 443, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_nsubjpass, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":444
* "nsubj": nsubj,
* "nsubjpass": nsubjpass,
* "num": num, # <<<<<<<<<<<<<<
* "number": number,
* "oprd": oprd,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_num); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 444, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_num, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":445
* "nsubjpass": nsubjpass,
* "num": num,
* "number": number, # <<<<<<<<<<<<<<
* "oprd": oprd,
* "obj": obj, # U20
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_number); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 445, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_number, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":446
* "num": num,
* "number": number,
* "oprd": oprd, # <<<<<<<<<<<<<<
* "obj": obj, # U20
* "obl": obl, # U20
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_oprd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 446, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_oprd, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":447
* "number": number,
* "oprd": oprd,
* "obj": obj, # U20 # <<<<<<<<<<<<<<
* "obl": obl, # U20
* "parataxis": parataxis,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_obj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":448
* "oprd": oprd,
* "obj": obj, # U20
* "obl": obl, # U20 # <<<<<<<<<<<<<<
* "parataxis": parataxis,
* "partmod": partmod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_obl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 448, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_obl, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":449
* "obj": obj, # U20
* "obl": obl, # U20
* "parataxis": parataxis, # <<<<<<<<<<<<<<
* "partmod": partmod,
* "pcomp": pcomp,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_parataxis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_parataxis, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":450
* "obl": obl, # U20
* "parataxis": parataxis,
* "partmod": partmod, # <<<<<<<<<<<<<<
* "pcomp": pcomp,
* "pobj": pobj,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_partmod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_partmod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":451
* "parataxis": parataxis,
* "partmod": partmod,
* "pcomp": pcomp, # <<<<<<<<<<<<<<
* "pobj": pobj,
* "poss": poss,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_pcomp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 451, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_pcomp, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":452
* "partmod": partmod,
* "pcomp": pcomp,
* "pobj": pobj, # <<<<<<<<<<<<<<
* "poss": poss,
* "possessive": possessive,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_pobj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 452, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_pobj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":453
* "pcomp": pcomp,
* "pobj": pobj,
* "poss": poss, # <<<<<<<<<<<<<<
* "possessive": possessive,
* "preconj": preconj,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_poss); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 453, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_poss, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":454
* "pobj": pobj,
* "poss": poss,
* "possessive": possessive, # <<<<<<<<<<<<<<
* "preconj": preconj,
* "prep": prep,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_possessive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_possessive, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":455
* "poss": poss,
* "possessive": possessive,
* "preconj": preconj, # <<<<<<<<<<<<<<
* "prep": prep,
* "prt": prt,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_preconj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 455, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_preconj, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":456
* "possessive": possessive,
* "preconj": preconj,
* "prep": prep, # <<<<<<<<<<<<<<
* "prt": prt,
* "punct": punct,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_prep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_prep, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":457
* "preconj": preconj,
* "prep": prep,
* "prt": prt, # <<<<<<<<<<<<<<
* "punct": punct,
* "quantmod": quantmod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_prt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_prt, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":458
* "prep": prep,
* "prt": prt,
* "punct": punct, # <<<<<<<<<<<<<<
* "quantmod": quantmod,
* "rcmod": rcmod,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_punct); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 458, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_punct, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":459
* "prt": prt,
* "punct": punct,
* "quantmod": quantmod, # <<<<<<<<<<<<<<
* "rcmod": rcmod,
* "relcl": relcl,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_quantmod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_quantmod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":460
* "punct": punct,
* "quantmod": quantmod,
* "rcmod": rcmod, # <<<<<<<<<<<<<<
* "relcl": relcl,
* "root": root,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_rcmod); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 460, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rcmod, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":461
* "quantmod": quantmod,
* "rcmod": rcmod,
* "relcl": relcl, # <<<<<<<<<<<<<<
* "root": root,
* "xcomp": xcomp,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_relcl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 461, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_relcl, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":462
* "rcmod": rcmod,
* "relcl": relcl,
* "root": root, # <<<<<<<<<<<<<<
* "xcomp": xcomp,
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_root); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 462, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_root, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":463
* "relcl": relcl,
* "root": root,
* "xcomp": xcomp, # <<<<<<<<<<<<<<
*
* "acl": acl,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_xcomp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_xcomp, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":465
* "xcomp": xcomp,
*
* "acl": acl, # <<<<<<<<<<<<<<
* "LAW": LAW,
* "MORPH": MORPH,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_acl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 465, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_acl, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":466
*
* "acl": acl,
* "LAW": LAW, # <<<<<<<<<<<<<<
* "MORPH": MORPH,
* "_": _,
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_LAW); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_LAW, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":467
* "acl": acl,
* "LAW": LAW,
* "MORPH": MORPH, # <<<<<<<<<<<<<<
* "_": _,
* }
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols_MORPH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_MORPH, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "spacy/symbols.pyx":468
* "LAW": LAW,
* "MORPH": MORPH,
* "_": _, # <<<<<<<<<<<<<<
* }
*
*/
__pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(__pyx_e_5spacy_7symbols__); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s__2, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (PyDict_SetItem(__pyx_d, __pyx_n_s_IDS, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "spacy/symbols.pyx":472
*
*
* def sort_nums(x): # <<<<<<<<<<<<<<
* return x[1]
*
*/
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5spacy_7symbols_1sort_nums, NULL, __pyx_n_s_spacy_symbols); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_sort_nums, __pyx_t_1) < 0) __PYX_ERR(0, 472, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "spacy/symbols.pyx":476
*
*
* NAMES = [it[0] for it in sorted(IDS.items(), key=sort_nums)] # <<<<<<<<<<<<<<
* # Unfortunate hack here, to work around problem with long cpdef enum
* # (which is generating an enormous amount of C++ in Cython 0.24+)
*/
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IDS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_sort_nums); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_key, __pyx_t_4) < 0) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
__pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
__pyx_t_6 = NULL;
} else {
__pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 476, __pyx_L1_error)
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
for (;;) {
if (likely(!__pyx_t_6)) {
if (likely(PyList_CheckExact(__pyx_t_2))) {
if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 476, __pyx_L1_error)
#else
__pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
} else {
if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 476, __pyx_L1_error)
#else
__pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
}
} else {
__pyx_t_4 = __pyx_t_6(__pyx_t_2);
if (unlikely(!__pyx_t_4)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(0, 476, __pyx_L1_error)
}
break;
}
__Pyx_GOTREF(__pyx_t_4);
}
if (PyDict_SetItem(__pyx_d, __pyx_n_s_it, __pyx_t_4) < 0) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_it); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (PyDict_SetItem(__pyx_d, __pyx_n_s_NAMES, __pyx_t_1) < 0) __PYX_ERR(0, 476, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "spacy/symbols.pyx":480
* # (which is generating an enormous amount of C++ in Cython 0.24+)
* # We keep the enum cdef, and just make sure the names are available to Python
* locals().update(IDS) # <<<<<<<<<<<<<<
*/
__pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_update); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 480, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_IDS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 480, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "spacy/symbols.pyx":1
* # cython: optimize.unpack_method_calls=False # <<<<<<<<<<<<<<
* IDS = {
* "": NIL,
*/
__pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/*--- Wrapped vars code ---*/
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
if (__pyx_m) {
if (__pyx_d) {
__Pyx_AddTraceback("init spacy.symbols", __pyx_clineno, __pyx_lineno, __pyx_filename);
}
Py_CLEAR(__pyx_m);
} else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ImportError, "init spacy.symbols");
}
__pyx_L0:;
__Pyx_RefNannyFinishContext();
#if CYTHON_PEP489_MULTI_PHASE_INIT
return (__pyx_m != NULL) ? 0 : -1;
#elif PY_MAJOR_VERSION >= 3
return __pyx_m;
#else
return;
#endif
}
/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
PyObject *m = NULL, *p = NULL;
void *r = NULL;
m = PyImport_ImportModule(modname);
if (!m) goto end;
p = PyObject_GetAttrString(m, "RefNannyAPI");
if (!p) goto end;
r = PyLong_AsVoidPtr(p);
end:
Py_XDECREF(p);
Py_XDECREF(m);
return (__Pyx_RefNannyAPIStruct *)r;
}
#endif
/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
PyTypeObject* tp = Py_TYPE(obj);
if (likely(tp->tp_getattro))
return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
if (likely(tp->tp_getattr))
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
return PyObject_GetAttr(obj, attr_name);
}
#endif
/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
if (unlikely(!result)) {
PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
"name '%U' is not defined", name);
#else
"name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
}
return result;
}
/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
PyObject *r;
if (!j) return NULL;
r = PyObject_GetItem(o, j);
Py_DECREF(j);
return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
Py_ssize_t wrapped_i = i;
if (wraparound & unlikely(i < 0)) {
wrapped_i += PyList_GET_SIZE(o);
}
if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
PyObject *r = PyList_GET_ITEM(o, wrapped_i);
Py_INCREF(r);
return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
Py_ssize_t wrapped_i = i;
if (wraparound & unlikely(i < 0)) {
wrapped_i += PyTuple_GET_SIZE(o);
}
if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
Py_INCREF(r);
return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
if (is_list || PyList_CheckExact(o)) {
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
PyObject *r = PyList_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
}
else if (PyTuple_CheckExact(o)) {
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
} else {
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
if (likely(m && m->sq_item)) {
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
Py_ssize_t l = m->sq_length(o);
if (likely(l >= 0)) {
i += l;
} else {
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
return NULL;
PyErr_Clear();
}
}
return m->sq_item(o, i);
}
}
#else
if (is_list || PySequence_Check(o)) {
return PySequence_GetItem(o, i);
}
#endif
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
PyObject *dict = Py_TYPE(obj)->tp_dict;
return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
PyObject **dictptr = NULL;
Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
dictptr = _PyObject_GetDictPtr(obj);
#endif
}
return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
PyObject *dict = Py_TYPE(obj)->tp_dict;
if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
return 0;
return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif
/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
} else if (unlikely(PyErr_Occurred())) {
return NULL;
}
#else
result = PyDict_GetItem(__pyx_d, name);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
}
#endif
#else
result = PyObject_GetItem(__pyx_d, name);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
}
PyErr_Clear();
#endif
return __Pyx_GetBuiltinName(name);
}
/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
PyObject *globals) {
PyFrameObject *f;
PyThreadState *tstate = __Pyx_PyThreadState_Current;
PyObject **fastlocals;
Py_ssize_t i;
PyObject *result;
assert(globals != NULL);
/* XXX Perhaps we should create a specialized
PyFrame_New() that doesn't take locals, but does
take builtins without sanity checking them.
*/
assert(tstate != NULL);
f = PyFrame_New(tstate, co, globals, NULL);
if (f == NULL) {
return NULL;
}
fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
for (i = 0; i < na; i++) {
Py_INCREF(*args);
fastlocals[i] = *args++;
}
result = PyEval_EvalFrameEx(f,0);
++tstate->recursion_depth;
Py_DECREF(f);
--tstate->recursion_depth;
return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
PyObject *globals = PyFunction_GET_GLOBALS(func);
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
PyObject *closure;
#if PY_MAJOR_VERSION >= 3
PyObject *kwdefs;
#endif
PyObject *kwtuple, **k;
PyObject **d;
Py_ssize_t nd;
Py_ssize_t nk;
PyObject *result;
assert(kwargs == NULL || PyDict_Check(kwargs));
nk = kwargs ? PyDict_Size(kwargs) : 0;
if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
return NULL;
}
if (
#if PY_MAJOR_VERSION >= 3
co->co_kwonlyargcount == 0 &&
#endif
likely(kwargs == NULL || nk == 0) &&
co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
if (argdefs == NULL && co->co_argcount == nargs) {
result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
goto done;
}
else if (nargs == 0 && argdefs != NULL
&& co->co_argcount == Py_SIZE(argdefs)) {
/* function called with no arguments, but all parameters have
a default value: use default values as arguments .*/
args = &PyTuple_GET_ITEM(argdefs, 0);
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
goto done;
}
}
if (kwargs != NULL) {
Py_ssize_t pos, i;
kwtuple = PyTuple_New(2 * nk);
if (kwtuple == NULL) {
result = NULL;
goto done;
}
k = &PyTuple_GET_ITEM(kwtuple, 0);
pos = i = 0;
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
Py_INCREF(k[i]);
Py_INCREF(k[i+1]);
i += 2;
}
nk = i / 2;
}
else {
kwtuple = NULL;
k = NULL;
}
closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
if (argdefs != NULL) {
d = &PyTuple_GET_ITEM(argdefs, 0);
nd = Py_SIZE(argdefs);
}
else {
d = NULL;
nd = 0;
}
#if PY_MAJOR_VERSION >= 3
result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
args, (int)nargs,
k, (int)nk,
d, (int)nd, kwdefs, closure);
#else
result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
args, (int)nargs,
k, (int)nk,
d, (int)nd, closure);
#endif
Py_XDECREF(kwtuple);
done:
Py_LeaveRecursiveCall();
return result;
}
#endif
#endif
/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
PyObject *result;
ternaryfunc call = Py_TYPE(func)->tp_call;
if (unlikely(!call))
return PyObject_Call(func, arg, kw);
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
return NULL;
result = (*call)(func, arg, kw);
Py_LeaveRecursiveCall();
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
PyErr_SetString(
PyExc_SystemError,
"NULL result without error in PyObject_Call");
}
return result;
}
#endif
/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
PyObject *self, *result;
PyCFunction cfunc;
cfunc = PyCFunction_GET_FUNCTION(func);
self = PyCFunction_GET_SELF(func);
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
return NULL;
result = cfunc(self, arg);
Py_LeaveRecursiveCall();
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
PyErr_SetString(
PyExc_SystemError,
"NULL result without error in PyObject_Call");
}
return result;
}
#endif
/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(func)) {
return __Pyx_PyFunction_FastCall(func, NULL, 0);
}
#endif
#ifdef __Pyx_CyFunction_USED
if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
if (likely(PyCFunction_Check(func)))
#endif
{
if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
return __Pyx_PyObject_CallMethO(func, NULL);
}
}
return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif
/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func);
int flags = PyCFunction_GET_FLAGS(func);
assert(PyCFunction_Check(func));
assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
assert(nargs >= 0);
assert(nargs == 0 || args != NULL);
/* _PyCFunction_FastCallDict() must not be called with an exception set,
because it may clear it (directly or indirectly) and so the
caller loses its exception */
assert(!PyErr_Occurred());
if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
} else {
return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
}
}
#endif
/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
PyObject *result;
PyObject *args = PyTuple_New(1);
if (unlikely(!args)) return NULL;
Py_INCREF(arg);
PyTuple_SET_ITEM(args, 0, arg);
result = __Pyx_PyObject_Call(func, args, NULL);
Py_DECREF(args);
return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(func)) {
return __Pyx_PyFunction_FastCall(func, &arg, 1);
}
#endif
if (likely(PyCFunction_Check(func))) {
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
} else if (__Pyx_PyFastCFunction_Check(func)) {
return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
}
}
return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
PyObject *result;
PyObject *args = PyTuple_Pack(1, arg);
if (unlikely(!args)) return NULL;
result = __Pyx_PyObject_Call(func, args, NULL);
Py_DECREF(args);
return result;
}
#endif
/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
tmp_type = tstate->curexc_type;
tmp_value = tstate->curexc_value;
tmp_tb = tstate->curexc_traceback;
tstate->curexc_type = type;
tstate->curexc_value = value;
tstate->curexc_traceback = tb;
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
*type = tstate->curexc_type;
*value = tstate->curexc_value;
*tb = tstate->curexc_traceback;
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
}
#endif
/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
PyObject *use_cline;
PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
PyObject **cython_runtime_dict;
#endif
if (unlikely(!__pyx_cython_runtime)) {
return c_line;
}
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
if (likely(cython_runtime_dict)) {
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
use_cline, *cython_runtime_dict,
__Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
} else
#endif
{
PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
if (use_cline_obj) {
use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
Py_DECREF(use_cline_obj);
} else {
PyErr_Clear();
use_cline = NULL;
}
}
if (!use_cline) {
c_line = 0;
PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
}
else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
c_line = 0;
}
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
return c_line;
}
#endif
/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
int start = 0, mid = 0, end = count - 1;
if (end >= 0 && code_line > entries[end].code_line) {
return count;
}
while (start < end) {
mid = start + (end - start) / 2;
if (code_line < entries[mid].code_line) {
end = mid;
} else if (code_line > entries[mid].code_line) {
start = mid + 1;
} else {
return mid;
}
}
if (code_line <= entries[mid].code_line) {
return mid;
} else {
return mid + 1;
}
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
PyCodeObject* code_object;
int pos;
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
return NULL;
}
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
return NULL;
}
code_object = __pyx_code_cache.entries[pos].code_object;
Py_INCREF(code_object);
return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
int pos, i;
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
if (unlikely(!code_line)) {
return;
}
if (unlikely(!entries)) {
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
if (likely(entries)) {
__pyx_code_cache.entries = entries;
__pyx_code_cache.max_count = 64;
__pyx_code_cache.count = 1;
entries[0].code_line = code_line;
entries[0].code_object = code_object;
Py_INCREF(code_object);
}
return;
}
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
PyCodeObject* tmp = entries[pos].code_object;
entries[pos].code_object = code_object;
Py_DECREF(tmp);
return;
}
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
int new_max = __pyx_code_cache.max_count + 64;
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
__pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
if (unlikely(!entries)) {
return;
}
__pyx_code_cache.entries = entries;
__pyx_code_cache.max_count = new_max;
}
for (i=__pyx_code_cache.count; i>pos; i--) {
entries[i] = entries[i-1];
}
entries[pos].code_line = code_line;
entries[pos].code_object = code_object;
__pyx_code_cache.count++;
Py_INCREF(code_object);
}
/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
const char *funcname, int c_line,
int py_line, const char *filename) {
PyCodeObject *py_code = 0;
PyObject *py_srcfile = 0;
PyObject *py_funcname = 0;
#if PY_MAJOR_VERSION < 3
py_srcfile = PyString_FromString(filename);
#else
py_srcfile = PyUnicode_FromString(filename);
#endif
if (!py_srcfile) goto bad;
if (c_line) {
#if PY_MAJOR_VERSION < 3
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
#else
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
#endif
}
else {
#if PY_MAJOR_VERSION < 3
py_funcname = PyString_FromString(funcname);
#else
py_funcname = PyUnicode_FromString(funcname);
#endif
}
if (!py_funcname) goto bad;
py_code = __Pyx_PyCode_New(
0,
0,
0,
0,
0,
__pyx_empty_bytes, /*PyObject *code,*/
__pyx_empty_tuple, /*PyObject *consts,*/
__pyx_empty_tuple, /*PyObject *names,*/
__pyx_empty_tuple, /*PyObject *varnames,*/
__pyx_empty_tuple, /*PyObject *freevars,*/
__pyx_empty_tuple, /*PyObject *cellvars,*/
py_srcfile, /*PyObject *filename,*/
py_funcname, /*PyObject *name,*/
py_line,
__pyx_empty_bytes /*PyObject *lnotab*/
);
Py_DECREF(py_srcfile);
Py_DECREF(py_funcname);
return py_code;
bad:
Py_XDECREF(py_srcfile);
Py_XDECREF(py_funcname);
return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename) {
PyCodeObject *py_code = 0;
PyFrameObject *py_frame = 0;
PyThreadState *tstate = __Pyx_PyThreadState_Current;
if (c_line) {
c_line = __Pyx_CLineForTraceback(tstate, c_line);
}
py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
if (!py_code) {
py_code = __Pyx_CreateCodeObjectForTraceback(
funcname, c_line, py_line, filename);
if (!py_code) goto bad;
__pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
}
py_frame = PyFrame_New(
tstate, /*PyThreadState *tstate,*/
py_code, /*PyCodeObject *code,*/
__pyx_d, /*PyObject *globals,*/
0 /*PyObject *locals*/
);
if (!py_frame) goto bad;
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
PyTraceBack_Here(py_frame);
bad:
Py_XDECREF(py_code);
Py_XDECREF(py_frame);
}
/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_5spacy_7symbols_symbol_t(enum __pyx_t_5spacy_7symbols_symbol_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
const enum __pyx_t_5spacy_7symbols_symbol_t neg_one = (enum __pyx_t_5spacy_7symbols_symbol_t) -1, const_zero = (enum __pyx_t_5spacy_7symbols_symbol_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(enum __pyx_t_5spacy_7symbols_symbol_t) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(enum __pyx_t_5spacy_7symbols_symbol_t) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(enum __pyx_t_5spacy_7symbols_symbol_t) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
}
} else {
if (sizeof(enum __pyx_t_5spacy_7symbols_symbol_t) <= sizeof(long)) {
return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(enum __pyx_t_5spacy_7symbols_symbol_t) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_5spacy_7symbols_symbol_t),
little, !is_unsigned);
}
}
/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(long) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(long) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
}
} else {
if (sizeof(long) <= sizeof(long)) {
return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(long),
little, !is_unsigned);
}
}
/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
if (likely(PyUnicode_Check(n)))
#else
if (likely(PyString_Check(n)))
#endif
return __Pyx_PyObject_GetAttrStr(o, n);
#endif
return PyObject_GetAttr(o, n);
}
/* Globals */
static PyObject* __Pyx_Globals(void) {
Py_ssize_t i;
PyObject *names;
PyObject *globals = __pyx_d;
Py_INCREF(globals);
names = PyObject_Dir(__pyx_m);
if (!names)
goto bad;
for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) {
#if CYTHON_COMPILING_IN_PYPY
PyObject* name = PySequence_ITEM(names, i);
if (!name)
goto bad;
#else
PyObject* name = PyList_GET_ITEM(names, i);
#endif
if (!PyDict_Contains(globals, name)) {
PyObject* value = __Pyx_GetAttr(__pyx_m, name);
if (!value) {
#if CYTHON_COMPILING_IN_PYPY
Py_DECREF(name);
#endif
goto bad;
}
if (PyDict_SetItem(globals, name, value) < 0) {
#if CYTHON_COMPILING_IN_PYPY
Py_DECREF(name);
#endif
Py_DECREF(value);
goto bad;
}
}
#if CYTHON_COMPILING_IN_PYPY
Py_DECREF(name);
#endif
}
Py_DECREF(names);
return globals;
bad:
Py_XDECREF(names);
Py_XDECREF(globals);
return NULL;
}
/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
{\
func_type value = func_value;\
if (sizeof(target_type) < sizeof(func_type)) {\
if (unlikely(value != (func_type) (target_type) value)) {\
func_type zero = 0;\
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
return (target_type) -1;\
if (is_unsigned && unlikely(value < zero))\
goto raise_neg_overflow;\
else\
goto raise_overflow;\
}\
}\
return (target_type) value;\
}
/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(long) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (long) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (long) 0;
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
case 2:
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (long) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(long) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (long) 0;
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
case -2:
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
}
#endif
if (sizeof(long) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
long val;
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (long) -1;
}
} else {
long val;
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
if (!tmp) return (long) -1;
val = __Pyx_PyInt_As_long(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to long");
return (long) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to long");
return (long) -1;
}
/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(int) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (int) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int) 0;
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
case 2:
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (int) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(int) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int) 0;
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
case -2:
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
}
#endif
if (sizeof(int) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
int val;
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (int) -1;
}
} else {
int val;
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
if (!tmp) return (int) -1;
val = __Pyx_PyInt_As_int(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to int");
return (int) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to int");
return (int) -1;
}
/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
while (a) {
a = a->tp_base;
if (a == b)
return 1;
}
return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
PyObject *mro;
if (a == b) return 1;
mro = a->tp_mro;
if (likely(mro)) {
Py_ssize_t i, n;
n = PyTuple_GET_SIZE(mro);
for (i = 0; i < n; i++) {
if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
return 1;
}
return 0;
}
return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
PyObject *exception, *value, *tb;
int res;
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__Pyx_ErrFetch(&exception, &value, &tb);
res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
if (unlikely(res == -1)) {
PyErr_WriteUnraisable(err);
res = 0;
}
if (!res) {
res = PyObject_IsSubclass(err, exc_type2);
if (unlikely(res == -1)) {
PyErr_WriteUnraisable(err);
res = 0;
}
}
__Pyx_ErrRestore(exception, value, tb);
return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
if (!res) {
res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
}
return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
Py_ssize_t i, n;
assert(PyExceptionClass_Check(exc_type));
n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
for (i=0; i<n; i++) {
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
}
#endif
for (i=0; i<n; i++) {
PyObject *t = PyTuple_GET_ITEM(tuple, i);
#if PY_MAJOR_VERSION < 3
if (likely(exc_type == t)) return 1;
#endif
if (likely(PyExceptionClass_Check(t))) {
if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
} else {
}
}
return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
if (likely(err == exc_type)) return 1;
if (likely(PyExceptionClass_Check(err))) {
if (likely(PyExceptionClass_Check(exc_type))) {
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
} else if (likely(PyTuple_Check(exc_type))) {
return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
} else {
}
}
return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
assert(PyExceptionClass_Check(exc_type1));
assert(PyExceptionClass_Check(exc_type2));
if (likely(err == exc_type1 || err == exc_type2)) return 1;
if (likely(PyExceptionClass_Check(err))) {
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
}
return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif
/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
char ctversion[4], rtversion[4];
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
char message[200];
PyOS_snprintf(message, sizeof(message),
"compiletime version %s of module '%.100s' "
"does not match runtime version %s",
ctversion, __Pyx_MODULE_NAME, rtversion);
return PyErr_WarnEx(NULL, message, 1);
}
return 0;
}
/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
while (t->p) {
#if PY_MAJOR_VERSION < 3
if (t->is_unicode) {
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
} else if (t->intern) {
*t->p = PyString_InternFromString(t->s);
} else {
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
}
#else
if (t->is_unicode | t->is_str) {
if (t->intern) {
*t->p = PyUnicode_InternFromString(t->s);
} else if (t->encoding) {
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
} else {
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
}
} else {
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
}
#endif
if (!*t->p)
return -1;
if (PyObject_Hash(*t->p) == -1)
return -1;
++t;
}
return 0;
}
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
Py_ssize_t ignore;
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
char* defenc_c;
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
if (!defenc) return NULL;
defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
{
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
char* c;
for (c = defenc_c; c < end; c++) {
if ((unsigned char) (*c) >= 128) {
PyUnicode_AsASCIIString(o);
return NULL;
}
}
}
#endif
*length = PyBytes_GET_SIZE(defenc);
return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
if (likely(PyUnicode_IS_ASCII(o))) {
*length = PyUnicode_GET_LENGTH(o);
return PyUnicode_AsUTF8(o);
} else {
PyUnicode_AsASCIIString(o);
return NULL;
}
#else
return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
__Pyx_sys_getdefaultencoding_not_ascii &&
#endif
PyUnicode_Check(o)) {
return __Pyx_PyUnicode_AsStringAndSize(o, length);
} else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
if (PyByteArray_Check(o)) {
*length = PyByteArray_GET_SIZE(o);
return PyByteArray_AS_STRING(o);
} else
#endif
{
char* result;
int r = PyBytes_AsStringAndSize(o, &result, length);
if (unlikely(r < 0)) {
return NULL;
} else {
return result;
}
}
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
int is_true = x == Py_True;
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
int retval;
if (unlikely(!x)) return -1;
retval = __Pyx_PyObject_IsTrue(x);
Py_DECREF(x);
return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
if (PyLong_Check(result)) {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"__int__ returned non-int (type %.200s). "
"The ability to return an instance of a strict subclass of int "
"is deprecated, and may be removed in a future version of Python.",
Py_TYPE(result)->tp_name)) {
Py_DECREF(result);
return NULL;
}
return result;
}
#endif
PyErr_Format(PyExc_TypeError,
"__%.4s__ returned non-%.4s (type %.200s)",
type_name, type_name, Py_TYPE(result)->tp_name);
Py_DECREF(result);
return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
PyNumberMethods *m;
#endif
const char *name = NULL;
PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
if (likely(PyLong_Check(x)))
#endif
return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
if (m && m->nb_int) {
name = "int";
res = m->nb_int(x);
}
else if (m && m->nb_long) {
name = "long";
res = m->nb_long(x);
}
#else
if (likely(m && m->nb_int)) {
name = "int";
res = m->nb_int(x);
}
#endif
#else
if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
res = PyNumber_Int(x);
}
#endif
if (likely(res)) {
#if PY_MAJOR_VERSION < 3
if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
if (unlikely(!PyLong_CheckExact(res))) {
#endif
return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
}
}
else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
"an integer is required");
}
return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
Py_ssize_t ival;
PyObject *x;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_CheckExact(b))) {
if (sizeof(Py_ssize_t) >= sizeof(long))
return PyInt_AS_LONG(b);
else
return PyInt_AsSsize_t(b);
}
#endif
if (likely(PyLong_CheckExact(b))) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)b)->ob_digit;
const Py_ssize_t size = Py_SIZE(b);
if (likely(__Pyx_sst_abs(size) <= 1)) {
ival = likely(size) ? digits[0] : 0;
if (size == -1) ival = -ival;
return ival;
} else {
switch (size) {
case 2:
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -2:
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case 3:
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -3:
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case 4:
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -4:
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
}
}
#endif
return PyLong_AsSsize_t(b);
}
x = PyNumber_Index(b);
if (!x) return -1;
ival = PyInt_AsSsize_t(x);
Py_DECREF(x);
return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
return PyInt_FromSize_t(ival);
}
#endif /* Py_PYTHON_H */
| 45.866468 | 341 | 0.712588 | [
"object",
"shape"
] |
3dff1a924f34f61a16507876a1623821602e2d54 | 973 | cpp | C++ | array/C++/0215-kth-largest-element-in-an-array/main.cpp | ljyljy/LeetCode-Solution-in-Good-Style | 0998211d21796868061eb22e2cbb9bcd112cedce | [
"Apache-2.0"
] | 1 | 2020-04-02T13:31:31.000Z | 2020-04-02T13:31:31.000Z | array/C++/0215-kth-largest-element-in-an-array/main.cpp | lemonnader/LeetCode-Solution-Well-Formed | baabdb1990fd49ab82a712e121f49c4f68b29459 | [
"Apache-2.0"
] | null | null | null | array/C++/0215-kth-largest-element-in-an-array/main.cpp | lemonnader/LeetCode-Solution-Well-Formed | baabdb1990fd49ab82a712e121f49c4f68b29459 | [
"Apache-2.0"
] | 1 | 2021-06-17T09:21:54.000Z | 2021-06-17T09:21:54.000Z | #include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int findKthLargest(vector<int> &nums, int k) {
int l = 0, r = nums.size() - 1;
k = nums.size() - k;
while (l <= r) {
int p = partition(nums, l, r);
if (k < p) {
r = p - 1;
} else if (k > p) {
l = p + 1;
} else {
return nums[p];
}
}
return nums[0];
}
int partition(vector<int> &nums, int l, int r) {
// 随机在 [l, r] 的范围中, 选择一个数值作为标定点 pivot
swap(nums[l], nums[rand() % (r - l + 1) + l]);
int t = nums[l];
while (l < r) {
while (l < r & nums[r] >= t) {
r--;
}
nums[l] = nums[r];
while (l < r & nums[l] < t) {
l++;
}
nums[r] = nums[l];
}
nums[l] = t;
return l;
}
};
| 22.113636 | 54 | 0.358684 | [
"vector"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.