Refactor native Matrix3, Vector2, Rectangle types

This commit is contained in:
Joshua Granick
2018-06-19 10:23:43 -07:00
parent fb6014e668
commit f0579fb450
14 changed files with 164 additions and 240 deletions

View File

@@ -18,7 +18,7 @@ namespace lime {
int height;
int offsetX;
int offsetY;
HL_Rectangle* rect;
Rectangle* rect;
/*ImageType*/ int type;
int version;
int width;

View File

@@ -8,7 +8,7 @@
namespace lime {
struct HL_Matrix3 {
struct Matrix3 {
hl_type* t;
double a;
@@ -18,29 +18,12 @@ namespace lime {
double tx;
double ty;
};
class Matrix3 {
public:
Matrix3 ();
Matrix3 (double a, double b, double c, double d, double tx, double ty);
Matrix3 (value matrix3);
Matrix3 (HL_Matrix3* matrix3);
vdynamic* Dynamic ();
value Value ();
double a;
double b;
double c;
double d;
double tx;
double ty;
Matrix3 (double a, double b, double c, double d, double tx, double ty);
Matrix3 (value matrix3);
void SetTo (double a, double b, double c, double d, double tx, double ty);
value Value ();
value Value (value matrix3);
};

View File

@@ -8,7 +8,7 @@
namespace lime {
struct HL_Rectangle {
struct Rectangle {
hl_type* t;
double height;
@@ -16,27 +16,13 @@ namespace lime {
double x;
double y;
};
class Rectangle {
public:
Rectangle ();
Rectangle (double x, double y, double width, double height);
Rectangle (value rect);
Rectangle (HL_Rectangle* rect);
void Contract (double x, double y, double width, double height);
value Value ();
double height;
double width;
double x;
double y;
Rectangle (double x, double y, double width, double height);
Rectangle (value rect);
void Contract (double x, double y, double width, double height);
void SetTo (double x, double y, double width, double height);
value Value ();
value Value (value rect);
};

View File

@@ -8,32 +8,19 @@
namespace lime {
struct HL_Vector2 {
struct Vector2 {
hl_type* t;
double length;
double x;
double y;
};
class Vector2 {
public:
Vector2 ();
Vector2 (double x, double y);
Vector2 (value vec);
Vector2 (HL_Vector2* vec);
vdynamic* Dynamic ();
value Value ();
double x;
double y;
Vector2 (double x, double y);
Vector2 (value vec);
void SetTo (double x, double y);
value Value ();
value Value (value vec);
};

View File

@@ -1904,11 +1904,10 @@ namespace lime {
}
HL_PRIM void hl_lime_image_data_util_color_transform (Image* image, HL_Rectangle* rect, ArrayBufferView* colorMatrix) {
HL_PRIM void hl_lime_image_data_util_color_transform (Image* image, Rectangle* rect, ArrayBufferView* colorMatrix) {
Rectangle _rect = Rectangle (rect);
ColorMatrix _colorMatrix = ColorMatrix (colorMatrix);
ImageDataUtil::ColorTransform (image, &_rect, &_colorMatrix);
ImageDataUtil::ColorTransform (image, rect, &_colorMatrix);
}
@@ -1924,11 +1923,9 @@ namespace lime {
}
HL_PRIM void hl_lime_image_data_util_copy_channel (Image* image, Image* sourceImage, HL_Rectangle* sourceRect, HL_Vector2* destPoint, int srcChannel, int destChannel) {
HL_PRIM void hl_lime_image_data_util_copy_channel (Image* image, Image* sourceImage, Rectangle* sourceRect, Vector2* destPoint, int srcChannel, int destChannel) {
Rectangle _sourceRect = Rectangle (sourceRect);
Vector2 _destPoint = Vector2 (destPoint);
ImageDataUtil::CopyChannel (image, sourceImage, &_sourceRect, &_destPoint, srcChannel, destChannel);
ImageDataUtil::CopyChannel (image, sourceImage, sourceRect, destPoint, srcChannel, destChannel);
}
@@ -1956,20 +1953,15 @@ namespace lime {
}
HL_PRIM void hl_lime_image_data_util_copy_pixels (Image* image, Image* sourceImage, HL_Rectangle* sourceRect, HL_Vector2* destPoint, Image* alphaImage, HL_Vector2* alphaPoint, bool mergeAlpha) {
Rectangle _sourceRect = Rectangle (sourceRect);
Vector2 _destPoint = Vector2 (destPoint);
HL_PRIM void hl_lime_image_data_util_copy_pixels (Image* image, Image* sourceImage, Rectangle* sourceRect, Vector2* destPoint, Image* alphaImage, Vector2* alphaPoint, bool mergeAlpha) {
if (!alphaImage) {
ImageDataUtil::CopyPixels (image, sourceImage, &_sourceRect, &_destPoint, NULL, NULL, mergeAlpha);
ImageDataUtil::CopyPixels (image, sourceImage, sourceRect, destPoint, NULL, NULL, mergeAlpha);
} else {
Vector2 _alphaPoint = Vector2 (alphaPoint);
ImageDataUtil::CopyPixels (image, sourceImage, &_sourceRect, &_destPoint, alphaImage, &_alphaPoint, mergeAlpha);
ImageDataUtil::CopyPixels (image, sourceImage, sourceRect, destPoint, alphaImage, alphaPoint, mergeAlpha);
}
@@ -1986,11 +1978,10 @@ namespace lime {
}
HL_PRIM void hl_lime_image_data_util_fill_rect (Image* image, HL_Rectangle* rect, int rg, int ba) {
HL_PRIM void hl_lime_image_data_util_fill_rect (Image* image, Rectangle* rect, int rg, int ba) {
Rectangle _rect = Rectangle (rect);
int32_t color = (rg << 16) | ba;
ImageDataUtil::FillRect (image, &_rect, color);
ImageDataUtil::FillRect (image, rect, color);
}
@@ -2023,11 +2014,9 @@ namespace lime {
}
HL_PRIM void hl_lime_image_data_util_get_pixels (Image* image, HL_Rectangle* rect, int format, Bytes* bytes) {
HL_PRIM void hl_lime_image_data_util_get_pixels (Image* image, Rectangle* rect, PixelFormat format, Bytes* bytes) {
Rectangle _rect = Rectangle (rect);
PixelFormat _format = (PixelFormat)format;
ImageDataUtil::GetPixels (image, &_rect, _format, bytes);
ImageDataUtil::GetPixels (image, rect, format, bytes);
}
@@ -2043,11 +2032,9 @@ namespace lime {
}
HL_PRIM void hl_lime_image_data_util_merge (Image* image, Image* sourceImage, HL_Rectangle* sourceRect, HL_Vector2* destPoint, int redMultiplier, int greenMultiplier, int blueMultiplier, int alphaMultiplier) {
HL_PRIM void hl_lime_image_data_util_merge (Image* image, Image* sourceImage, Rectangle* sourceRect, Vector2* destPoint, int redMultiplier, int greenMultiplier, int blueMultiplier, int alphaMultiplier) {
Rectangle _sourceRect = Rectangle (sourceRect);
Vector2 _destPoint = Vector2 (destPoint);
ImageDataUtil::Merge (image, sourceImage, &_sourceRect, &_destPoint, redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier);
ImageDataUtil::Merge (image, sourceImage, sourceRect, destPoint, redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier);
}
@@ -2111,10 +2098,9 @@ namespace lime {
}
HL_PRIM void hl_lime_image_data_util_set_pixels (Image* image, HL_Rectangle* rect, Bytes* bytes, int offset, PixelFormat format, Endian endian) {
HL_PRIM void hl_lime_image_data_util_set_pixels (Image* image, Rectangle* rect, Bytes* bytes, int offset, PixelFormat format, Endian endian) {
Rectangle _rect = Rectangle (rect);
ImageDataUtil::SetPixels (image, &_rect, bytes, offset, format, endian);
ImageDataUtil::SetPixels (image, rect, bytes, offset, format, endian);
}
@@ -2133,14 +2119,12 @@ namespace lime {
}
HL_PRIM int hl_lime_image_data_util_threshold (Image* image, Image* sourceImage, HL_Rectangle* sourceRect, HL_Vector2* destPoint, int operation, int thresholdRG, int thresholdBA, int colorRG, int colorBA, int maskRG, int maskBA, bool copySource) {
HL_PRIM int hl_lime_image_data_util_threshold (Image* image, Image* sourceImage, Rectangle* sourceRect, Vector2* destPoint, int operation, int thresholdRG, int thresholdBA, int colorRG, int colorBA, int maskRG, int maskBA, bool copySource) {
Rectangle _sourceRect = Rectangle (sourceRect);
Vector2 _destPoint = Vector2 (destPoint);
int32_t threshold = (thresholdRG << 16) | thresholdBA;
int32_t color = (colorRG << 16) | colorBA;
int32_t mask = (maskRG << 16) | maskBA;
return ImageDataUtil::Threshold (image, sourceImage, &_sourceRect, &_destPoint, operation, threshold, color, mask, copySource);
return ImageDataUtil::Threshold (image, sourceImage, sourceRect, destPoint, operation, threshold, color, mask, copySource);
}
@@ -2823,14 +2807,13 @@ namespace lime {
}
HL_PRIM ImageBuffer* hl_lime_renderer_read_pixels (HL_CFFIPointer* renderer, HL_Rectangle* rect, ImageBuffer* imageBuffer) {
HL_PRIM ImageBuffer* hl_lime_renderer_read_pixels (HL_CFFIPointer* renderer, Rectangle* rect, ImageBuffer* imageBuffer) {
Renderer* targetRenderer = (Renderer*)renderer->ptr;
if (rect) {
Rectangle _rect = Rectangle (rect);
targetRenderer->ReadPixels (imageBuffer, &_rect);
targetRenderer->ReadPixels (imageBuffer, rect);
} else {

View File

@@ -519,7 +519,7 @@ namespace lime {
Font* font = (Font*)face->ptr;
cairo_font_face_t* cairoFont = cairo_ft_font_face_create_for_ft_face ((FT_Face)font->face, flags);
ValuePointer* fontReference = new ValuePointer ((vdynamic*)face->ptr);
ValuePointer* fontReference = new ValuePointer ((vobj*)face->ptr);
cairo_font_face_set_user_data (cairoFont, &userData, fontReference, gc_user_data);
HL_CFFIPointer* object = HLCFFIPointer (cairoFont, (hl_finalizer)hl_gc_cairo_font_face);
@@ -558,12 +558,10 @@ namespace lime {
}
HL_PRIM HL_Vector2* hl_lime_cairo_get_current_point (HL_CFFIPointer* handle) {
HL_PRIM Vector2* hl_lime_cairo_get_current_point (HL_CFFIPointer* handle, Vector2* out) {
double x, y;
cairo_get_current_point ((cairo_t*)handle->ptr, &x, &y);
Vector2 vec2 = Vector2 (x, y);
return (HL_Vector2*)vec2.Dynamic ();
cairo_get_current_point ((cairo_t*)handle->ptr, &out->x, &out->y);
return out;
}
@@ -795,12 +793,18 @@ namespace lime {
}
HL_PRIM HL_Matrix3* hl_lime_cairo_get_matrix (HL_CFFIPointer* handle) {
HL_PRIM Matrix3* hl_lime_cairo_get_matrix (HL_CFFIPointer* handle, Matrix3* out) {
cairo_matrix_t cm;
cairo_get_matrix ((cairo_t*)handle->ptr, &cm);
Matrix3 mat3 = Matrix3 (cm.xx, cm.yx, cm.xy, cm.yy, cm.x0, cm.y0);
return (HL_Matrix3*)mat3.Dynamic ();
// cairo_matrix_t cm;
// cairo_get_matrix ((cairo_t*)handle->ptr, &cm);
// out->a = cm.xx;
// out->b = cm.yx;
// out->c = cm.xy;
// out->d = cm.yy;
// out->tx = cm.x0;
// out->ty = cm.y0;
cairo_get_matrix ((cairo_t*)handle->ptr, (cairo_matrix_t*)&out->a);
return out;
}
@@ -1443,12 +1447,18 @@ namespace lime {
}
HL_PRIM HL_Matrix3* hl_lime_cairo_pattern_get_matrix (HL_CFFIPointer* handle) {
HL_PRIM Matrix3* hl_lime_cairo_pattern_get_matrix (HL_CFFIPointer* handle, Matrix3* out) {
cairo_matrix_t cm;
cairo_pattern_get_matrix ((cairo_pattern_t*)handle->ptr, &cm);
Matrix3 mat3 = Matrix3 (cm.xx, cm.yx, cm.xy, cm.yy, cm.x0, cm.y0);
return (HL_Matrix3*)mat3.Dynamic ();
// cairo_matrix_t cm;
// cairo_pattern_get_matrix ((cairo_pattern_t*)handle->ptr, &cm);
// out->a = cm.xx;
// out->b = cm.yx;
// out->c = cm.xy;
// out->d = cm.yy;
// out->tx = cm.x0;
// out->ty = cm.y0;
cairo_pattern_get_matrix ((cairo_pattern_t*)handle->ptr, (cairo_matrix_t*)&out->a);
return out;
}
@@ -1493,14 +1503,14 @@ namespace lime {
}
HL_PRIM void hl_lime_cairo_pattern_set_matrix (HL_CFFIPointer* handle, HL_Matrix3* matrix) {
HL_PRIM void hl_lime_cairo_pattern_set_matrix (HL_CFFIPointer* handle, Matrix3* matrix) {
Matrix3 mat3 = Matrix3 (matrix);
// cairo_matrix_t cm;
// cairo_matrix_init (&cm, mat3.a, mat3.b, mat3.c, mat3.d, mat3.tx, mat3.ty);
cairo_matrix_t cm;
cairo_matrix_init (&cm, mat3.a, mat3.b, mat3.c, mat3.d, mat3.tx, mat3.ty);
// cairo_pattern_set_matrix ((cairo_pattern_t*)handle->ptr, &cm);
cairo_pattern_set_matrix ((cairo_pattern_t*)handle->ptr, &cm);
cairo_pattern_set_matrix ((cairo_pattern_t*)handle->ptr, (cairo_matrix_t*)&matrix->a);
}
@@ -1908,12 +1918,12 @@ namespace lime {
}
HL_PRIM void hl_lime_cairo_set_matrix (HL_CFFIPointer* handle, double a, double b, double c, double d, double tx, double ty) {
HL_PRIM void hl_lime_cairo_set_matrix (HL_CFFIPointer* handle, Matrix3* matrix) {
cairo_matrix_t cm;
cairo_matrix_init (&cm, a, b, c, d, tx, ty);
// cairo_matrix_t cm;
// cairo_matrix_init (&cm, a, b, c, d, tx, ty);
cairo_set_matrix ((cairo_t*)handle->ptr, &cm);
cairo_set_matrix ((cairo_t*)handle->ptr, (cairo_matrix_t*)&matrix->a);
}
@@ -2209,14 +2219,14 @@ namespace lime {
}
HL_PRIM void hl_lime_cairo_transform (HL_CFFIPointer* handle, HL_Matrix3* matrix) {
HL_PRIM void hl_lime_cairo_transform (HL_CFFIPointer* handle, Matrix3* matrix) {
Matrix3 mat3 = Matrix3 (matrix);
// cairo_matrix_t cm;
// cairo_matrix_init (&cm, mat3.a, mat3.b, mat3.c, mat3.d, mat3.tx, mat3.ty);
cairo_matrix_t cm;
cairo_matrix_init (&cm, mat3.a, mat3.b, mat3.c, mat3.d, mat3.tx, mat3.ty);
// cairo_transform ((cairo_t*)handle->ptr, &cm);
cairo_transform ((cairo_t*)handle->ptr, &cm);
cairo_transform ((cairo_t*)handle->ptr, (cairo_matrix_t*)&matrix->a);
}
@@ -2414,7 +2424,7 @@ namespace lime {
DEFINE_HL_PRIM (_VOID, lime_cairo_font_options_set_hint_style, _TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_VOID, lime_cairo_font_options_set_hint_metrics, _TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_I32, lime_cairo_get_antialias, _TCFFIPOINTER);
DEFINE_HL_PRIM (_TVECTOR2, lime_cairo_get_current_point, _TCFFIPOINTER);
DEFINE_HL_PRIM (_TVECTOR2, lime_cairo_get_current_point, _TCFFIPOINTER _TVECTOR2);
DEFINE_HL_PRIM (_ARR, lime_cairo_get_dash, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_cairo_get_dash_count, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_cairo_get_fill_rule, _TCFFIPOINTER);
@@ -2424,7 +2434,7 @@ namespace lime {
DEFINE_HL_PRIM (_I32, lime_cairo_get_line_cap, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_cairo_get_line_join, _TCFFIPOINTER);
DEFINE_HL_PRIM (_F64, lime_cairo_get_line_width, _TCFFIPOINTER);
DEFINE_HL_PRIM (_TMATRIX3, lime_cairo_get_matrix, _TCFFIPOINTER);
DEFINE_HL_PRIM (_TMATRIX3, lime_cairo_get_matrix, _TCFFIPOINTER _TMATRIX3);
DEFINE_HL_PRIM (_F64, lime_cairo_get_miter_limit, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_cairo_get_operator, _TCFFIPOINTER);
DEFINE_HL_PRIM (_TCFFIPOINTER, lime_cairo_get_source, _TCFFIPOINTER);
@@ -2459,7 +2469,7 @@ namespace lime {
DEFINE_HL_PRIM (_I32, lime_cairo_pattern_get_color_stop_count, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_cairo_pattern_get_extend, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, lime_cairo_pattern_get_filter, _TCFFIPOINTER);
DEFINE_HL_PRIM (_TMATRIX3, lime_cairo_pattern_get_matrix, _TCFFIPOINTER);
DEFINE_HL_PRIM (_TMATRIX3, lime_cairo_pattern_get_matrix, _TCFFIPOINTER _TMATRIX3);
DEFINE_HL_PRIM (_VOID, lime_cairo_pattern_set_extend, _TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_VOID, lime_cairo_pattern_set_filter, _TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_VOID, lime_cairo_pattern_set_matrix, _TCFFIPOINTER _TMATRIX3);
@@ -2485,7 +2495,7 @@ namespace lime {
DEFINE_HL_PRIM (_VOID, lime_cairo_set_line_cap, _TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_VOID, lime_cairo_set_line_join, _TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_VOID, lime_cairo_set_line_width, _TCFFIPOINTER _F64);
DEFINE_HL_PRIM (_VOID, lime_cairo_set_matrix, _TCFFIPOINTER _F64 _F64 _F64 _F64 _F64 _F64);
DEFINE_HL_PRIM (_VOID, lime_cairo_set_matrix, _TCFFIPOINTER _TMATRIX3);
DEFINE_HL_PRIM (_VOID, lime_cairo_set_miter_limit, _TCFFIPOINTER _F64);
DEFINE_HL_PRIM (_VOID, lime_cairo_set_operator, _TCFFIPOINTER _I32);
DEFINE_HL_PRIM (_VOID, lime_cairo_set_source, _TCFFIPOINTER _TCFFIPOINTER);

View File

@@ -3871,7 +3871,7 @@ namespace lime {
HL_PRIM HL_CFFIPointer* hl_lime_gl_object_register (int id, int type, void* object) {
GLObjectType _type = (GLObjectType)type;
HL_CFFIPointer* handle = HLCFFIPointer ((vdynamic*)object, (hl_finalizer)gc_gl_object);
HL_CFFIPointer* handle = HLCFFIPointer ((vobj*)object, (hl_finalizer)gc_gl_object);
//if (glObjects[_type].find (id) != glObjects[_type].end ()) {
//

View File

@@ -13,26 +13,11 @@ namespace lime {
static bool init = false;
Matrix3::Matrix3 () {
a = 1;
b = 0;
c = 0;
d = 1;
tx = 0;
ty = 0;
}
Matrix3::Matrix3 (double a, double b, double c, double d, double tx, double ty) {
this->a = a;
this->b = b;
this->c = c;
this->d = d;
this->tx = tx;
this->ty = ty;
t = 0;
SetTo (a, b, c, d, tx, ty);
}
@@ -61,42 +46,34 @@ namespace lime {
}
Matrix3::Matrix3 (HL_Matrix3* matrix3) {
void Matrix3::SetTo (double a, double b, double c, double d, double tx, double ty) {
a = matrix3->a;
b = matrix3->b;
c = matrix3->c;
d = matrix3->d;
tx = matrix3->tx;
ty = matrix3->ty;
}
vdynamic* Matrix3::Dynamic () {
HL_Matrix3* result = (HL_Matrix3*)malloc (sizeof (HL_Matrix3));
result->a = a;
result->b = b;
result->c = c;
result->d = d;
result->tx = tx;
result->ty = ty;
return (vdynamic*) result;
this->a = a;
this->b = b;
this->c = c;
this->d = d;
this->tx = tx;
this->ty = ty;
}
value Matrix3::Value () {
value result = alloc_empty_object ();
alloc_field (result, id_a, alloc_float (a));
alloc_field (result, id_b, alloc_float (b));
alloc_field (result, id_c, alloc_float (c));
alloc_field (result, id_d, alloc_float (d));
alloc_field (result, id_tx, alloc_float (tx));
alloc_field (result, id_ty, alloc_float (ty));
return result;
return Value (alloc_empty_object ());
}
value Matrix3::Value (value matrix3) {
alloc_field (matrix3, id_a, alloc_float (a));
alloc_field (matrix3, id_b, alloc_float (b));
alloc_field (matrix3, id_c, alloc_float (c));
alloc_field (matrix3, id_d, alloc_float (d));
alloc_field (matrix3, id_tx, alloc_float (tx));
alloc_field (matrix3, id_ty, alloc_float (ty));
return matrix3;
}

View File

@@ -11,22 +11,11 @@ namespace lime {
static bool init = false;
Rectangle::Rectangle () {
height = 0;
width = 0;
x = 0;
y = 0;
}
Rectangle::Rectangle (double x, double y, double width, double height) {
this->height = height;
this->width = width;
this->x = x;
this->y = y;
t = 0;
SetTo (x, y, width, height);
}
@@ -51,16 +40,6 @@ namespace lime {
}
Rectangle::Rectangle (HL_Rectangle* rect) {
width = rect->width;
height = rect->height;
x = rect->x;
y = rect->y;
}
void Rectangle::Contract (double x, double y, double width, double height) {
if (this->width == 0 && this->height == 0) {
@@ -80,8 +59,25 @@ namespace lime {
}
void Rectangle::SetTo (double x, double y, double width, double height) {
this->height = height;
this->width = width;
this->x = x;
this->y = y;
}
value Rectangle::Value () {
return Value (alloc_empty_object ());
}
value Rectangle::Value (value rect) {
if (!init) {
id_height = val_id ("height");
@@ -92,7 +88,6 @@ namespace lime {
}
value rect = alloc_empty_object ();
alloc_field (rect, id_height, alloc_float (height));
alloc_field (rect, id_width, alloc_float (width));
alloc_field (rect, id_x, alloc_float (x));

View File

@@ -9,18 +9,11 @@ namespace lime {
static bool init = false;
Vector2::Vector2 () {
x = 0;
y = 0;
}
Vector2::Vector2 (double x, double y) {
this->x = x;
this->y = y;
t = 0;
SetTo (x, y);
}
@@ -50,26 +43,23 @@ namespace lime {
}
Vector2::Vector2 (HL_Vector2* vec) {
void Vector2::SetTo (double x, double y) {
x = vec->x;
y = vec->y;
}
vdynamic* Vector2::Dynamic () {
HL_Vector2* result = (HL_Vector2*)malloc (sizeof (HL_Vector2));
result->x = x;
result->y = y;
return (vdynamic*) result;
this->x = x;
this->y = y;
}
value Vector2::Value () {
return Value (alloc_empty_object ());
}
value Vector2::Value (value vec) {
if (!init) {
id_x = val_id ("x");
@@ -78,10 +68,9 @@ namespace lime {
}
value result = alloc_empty_object ();
alloc_field (result, id_x, alloc_float (x));
alloc_field (result, id_y, alloc_float (y));
return result;
alloc_field (vec, id_x, alloc_float (x));
alloc_field (vec, id_y, alloc_float (y));
return vec;
}