/* libsizzle/uvector.h - uniform vector function declarations
 
  Copyright (C) 2000 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
 
  This 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, or (at your option)
  any later version.
  
  This software 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
  General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this package; see the file COPYING.  If not, write to the
  Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  MA 02111-1307, USA.  */

#ifndef __SIZZLE_UVECTOR_H__
#define __SIZZLE_UVECTOR_H__

#if HAVE_CONFIG_H
# include <config.h>
#endif 

#if __SIZZLE_IMPORT__
# define SIZZLE_API __declspec (dllimport)
#elif __SIZZLE_EXPORT__ 
# define SIZZLE_API __declspec (dllexport)
#else
# define SIZZLE_API
#endif

#include "node.h"

#define s8vector_p(c)      (tagged_p(c) && \
                            tagged_type(c) == zzz_tagged_type_s8vector)
#define ro_s8vector_p(c)   (s8vector_p(c) && \
                            tagged_info(c) == tagged_info_ro)
#define s8vector_val(c)    (((signed char *) tagged_data0(c)))
#define s8vector_len(c)    ((zzz_object_t) tagged_data1(c))

#define u8vector_p(c)      (tagged_p(c) && \
                            tagged_type(c) == zzz_tagged_type_u8vector)
#define ro_u8vector_p(c)   (u8vector_p(c) && \
                            tagged_info(c) == tagged_info_ro)
#define u8vector_val(c)    (((unsigned char *) tagged_data0(c)))
#define u8vector_len(c)    ((zzz_object_t) tagged_data1(c))

#define s16vector_p(c)     (tagged_p(c) && \
                           tagged_type(c) == zzz_tagged_type_s16vector)
#define ro_s16vector_p(c)  (s16vector_p(c) && \
                           tagged_info(c) == tagged_info_ro)
#define s16vector_val(c)   (((signed short *) tagged_data0(c)))
#define s16vector_len(c)   ((zzz_object_t) tagged_data1(c))

#define u16vector_p(c)     (tagged_p(c) && \
                           tagged_type(c) == zzz_tagged_type_u16vector)
#define ro_u16vector_p(c)  (u16vector_p(c) && \
                           tagged_info(c) == tagged_info_ro)
#define u16vector_val(c)   (((unsigned short *) tagged_data0(c)))
#define u16vector_len(c)   ((zzz_object_t) tagged_data1(c))

#define s32vector_p(c)     (tagged_p(c) && \
                           tagged_type(c) == zzz_tagged_type_s32vector)
#define ro_s32vector_p(c)  (s32vector_p(c) && \
                           tagged_info(c) == tagged_info_ro)
#define s32vector_val(c)   (((signed int *) tagged_data0(c)))
#define s32vector_len(c)   ((zzz_object_t) tagged_data1(c))

#define u32vector_p(c)     (tagged_p(c) && \
                           tagged_type(c) == zzz_tagged_type_u32vector)
#define ro_u32vector_p(c)  (u32vector_p(c) && \
                           tagged_info(c) == tagged_info_ro)
#define u32vector_val(c)   (((unsigned int *) tagged_data0(c)))
#define u32vector_len(c)   ((zzz_object_t) tagged_data1(c))

#define f32vector_p(c)     (tagged_p(c) && \
                           tagged_type(c) == zzz_tagged_type_f32vector)
#define ro_f32vector_p(c)  (f32vector_p(c) && \
                           tagged_info(c) == tagged_info_ro)
#define f32vector_val(c)   (((float *) tagged_data0(c)))
#define f32vector_len(c)   ((zzz_object_t) tagged_data1(c))

#define f64vector_p(c)     (tagged_p(c) && \
                           tagged_type(c) == zzz_tagged_type_f64vector)
#define ro_f64vector_p(c)  (f64vector_p(c) && \
                           tagged_info(c) == tagged_info_ro)
#define f64vector_val(c)   (((double *) tagged_data0(c)))
#define f64vector_len(c)   ((zzz_object_t) tagged_data1(c))

/* This is non-zero if uniform vectors are available.  */
SIZZLE_API extern int zzz_config_have_uvector;

/* Tagged types for the uniform vector types.  */
SIZZLE_API extern zzz_object_t zzz_tagged_type_s8vector;
SIZZLE_API extern zzz_object_t zzz_tagged_type_u8vector;
SIZZLE_API extern zzz_object_t zzz_tagged_type_s16vector;
SIZZLE_API extern zzz_object_t zzz_tagged_type_u16vector;
SIZZLE_API extern zzz_object_t zzz_tagged_type_s32vector;
SIZZLE_API extern zzz_object_t zzz_tagged_type_u32vector;
SIZZLE_API extern zzz_object_t zzz_tagged_type_f32vector;
SIZZLE_API extern zzz_object_t zzz_tagged_type_f64vector;

/* Create a vector object holding @var{len} objects of the type
   indicated by the tag.  */
SIZZLE_API zzz_scm_t zzz_make_s8vector (int len);
SIZZLE_API zzz_scm_t zzz_make_u8vector (int len);
SIZZLE_API zzz_scm_t zzz_make_s16vector (int len);
SIZZLE_API zzz_scm_t zzz_make_u16vector (int len);
SIZZLE_API zzz_scm_t zzz_make_s32vector (int len);
SIZZLE_API zzz_scm_t zzz_make_u32vector (int len);
SIZZLE_API zzz_scm_t zzz_make_f32vector (int len);
SIZZLE_API zzz_scm_t zzz_make_f64vector (int len);

/* Create a constant vector object holding @var{len} objects of the
   type indicated by the tag.  Vectors created using this functions
   cannot be modified using Scheme primitives like
   @code{TAGvector-set!}.  */
SIZZLE_API zzz_scm_t zzz_make_ro_s8vector (int len);
SIZZLE_API zzz_scm_t zzz_make_ro_u8vector (int len);
SIZZLE_API zzz_scm_t zzz_make_ro_s16vector (int len);
SIZZLE_API zzz_scm_t zzz_make_ro_u16vector (int len);
SIZZLE_API zzz_scm_t zzz_make_ro_s32vector (int len);
SIZZLE_API zzz_scm_t zzz_make_ro_u32vector (int len);
SIZZLE_API zzz_scm_t zzz_make_ro_f32vector (int len);
SIZZLE_API zzz_scm_t zzz_make_ro_f64vector (int len);

/* Init function for the uniform vector module.  Defines the uniform
   vector types and all Scheme primitives for dealing with uniform
   vector objects.  */
SIZZLE_API result_t zzz_init_uvector (void);

#endif /* not __SIZZLE_UVECTOR_H__ */
