Branch
Hash :
94046104
Author :
Thomas de Grivel
Date :
2020-02-24T15:19:27
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
/*
This is part of Patchwork13! the real-time data synthesis toolkit.
http://patchwork13.sourceforge.net/
pw13 - the patchwork13 core library
Copyright (C) 2005 Thomas de Grivel <billitch@yahoo.fr>
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.
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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
data.h - data, data types and operators
*/
#ifndef PW13_DATA_H_INCLUDED
#define PW13_DATA_H_INCLUDED
#include <stdarg.h>
#include "dll.h"
#include "types.h"
#include "list.h"
/** Representation of the data to flow through patches **/
union Pw13_Data {
unsigned int nblocks;
union {
char c[4];
unsigned char uc[4];
short s[2];
unsigned short us[2];
} t;
char c;
unsigned char uc;
short s;
unsigned short us;
int i;
unsigned int ui;
long l;
unsigned long ul;
float f;
int b;
char *pc;
void *ptr;
};
extern Pw13_Data pw13_data_zero_s;
/* constructors */
/** Allocate a single data block containing zero.
That means that the data segment contains no data. */
PW13_EXTERN Pw13_Data * pw13_data_zero ();
/** Allocate two blocks.
The first contains 1 in nblocks because there is a
single data block in the data segment.
The second block contains user data.*/
PW13_EXTERN Pw13_Data * pw13_data_one ();
PW13_EXTERN Pw13_Data * pw13_data_one_init (Pw13_Data val);
/** Allocate an array of blocks.
The first block contains the blocks count, and is followed by
the counted blocks.
*/
PW13_EXTERN Pw13_Data * pw13_data_array (unsigned int nblocks);
/** Allocate an array of blocks with a given byte size.
The first block contains the blocks count, and is followed by
enough blocks to contain the given number of bytes.
*/
PW13_EXTERN Pw13_Data * pw13_data_bytes (unsigned int nbytes);
/** Allocate and initialize an array of blocks.
The first block contains the blocks count, and is followed by
the counted blocks.
*/
PW13_EXTERN Pw13_Data * pw13_data_array_init (unsigned int nblocks, ...);
/** Copy a data segment */
PW13_EXTERN Pw13_Data * pw13_data_copy (Pw13_Data *d);
/* operators */
/** Returns the size in bytes of a data segment */
PW13_EXTERN unsigned int pw13_data_size (Pw13_Data *d);
/** Free a data segment */
PW13_EXTERN void pw13_data_free (Pw13_Data *d);
/* Data constructors for convenience */
PW13_EXTERN Pw13_Data *pw13_data_c (char val);
PW13_EXTERN Pw13_Data *pw13_data_uc (unsigned char val);
PW13_EXTERN Pw13_Data *pw13_data_s (short val);
PW13_EXTERN Pw13_Data *pw13_data_us (unsigned short val);
PW13_EXTERN Pw13_Data *pw13_data_i (int val);
PW13_EXTERN Pw13_Data *pw13_data_ui (unsigned int val);
PW13_EXTERN Pw13_Data *pw13_data_l (long val);
PW13_EXTERN Pw13_Data *pw13_data_ul (unsigned long val);
PW13_EXTERN Pw13_Data *pw13_data_f (float val);
PW13_EXTERN Pw13_Data *pw13_data_b (int val);
PW13_EXTERN Pw13_Data *pw13_data_pc (char *val);
PW13_EXTERN Pw13_Data *pw13_data_ptr (void *val);
#endif
/* ndef PW13_DATA_H_INCLUDED */