annotate stitch/ops.c @ 0:5242703e91d3 tip

Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author tomwalters
date Fri, 20 May 2011 15:19:45 +0100
parents
children
rev   line source
tomwalters@0 1 /*
tomwalters@0 2 Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989
tomwalters@0 3 ===========================================================================
tomwalters@0 4
tomwalters@0 5 Permission to use, copy, modify, and distribute this software without fee
tomwalters@0 6 is hereby granted for research purposes, provided that this copyright
tomwalters@0 7 notice appears in all copies and in all supporting documentation, and that
tomwalters@0 8 the software is not redistributed for any fee (except for a nominal shipping
tomwalters@0 9 charge). Anyone wanting to incorporate all or part of this software in a
tomwalters@0 10 commercial product must obtain a license from the Medical Research Council.
tomwalters@0 11
tomwalters@0 12 The MRC makes no representations about the suitability of this
tomwalters@0 13 software for any purpose. It is provided "as is" without express or implied
tomwalters@0 14 warranty.
tomwalters@0 15
tomwalters@0 16 THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
tomwalters@0 17 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
tomwalters@0 18 A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
tomwalters@0 19 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
tomwalters@0 20 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
tomwalters@0 21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
tomwalters@0 22 */
tomwalters@0 23
tomwalters@0 24 /*
tomwalters@0 25 ops.c
tomwalters@0 26 =====
tomwalters@0 27
tomwalters@0 28 quickie operators for stitch
tomwalters@0 29
tomwalters@0 30 */
tomwalters@0 31
tomwalters@0 32
tomwalters@0 33
tomwalters@0 34 typedef char *Pointer ;
tomwalters@0 35
tomwalters@0 36 typedef char *Address ;
tomwalters@0 37
tomwalters@0 38
tomwalters@0 39 /* a portable inteface to the system */
tomwalters@0 40
tomwalters@0 41 extern void stitch_error() ;
tomwalters@0 42
tomwalters@0 43 extern Pointer stitch_malloc() ;
tomwalters@0 44 extern Pointer stitch_copied_malloc() ;
tomwalters@0 45 extern Pointer stitch_zeroed_malloc() ;
tomwalters@0 46 extern Pointer stitch_ralloc() ;
tomwalters@0 47 extern Pointer stitch_calloc() ;
tomwalters@0 48
tomwalters@0 49 extern void stitch_free() ;
tomwalters@0 50 extern void stitch_exit() ;
tomwalters@0 51
tomwalters@0 52 /* beware these definitions, they are for speed and fail if stitch.h not included */
tomwalters@0 53
tomwalters@0 54 extern void (*stitch_bcopy)() ;
tomwalters@0 55 extern void (*stitch_bzero)() ;
tomwalters@0 56
tomwalters@0 57 extern char stitchStructStr[] ;
tomwalters@0 58
tomwalters@0 59
tomwalters@0 60
tomwalters@0 61
tomwalters@0 62 typedef struct _buffer *Buffer ;
tomwalters@0 63
tomwalters@0 64
tomwalters@0 65 struct _buffer { Pointer addr ; unsigned size, refs ; } ;
tomwalters@0 66
tomwalters@0 67 extern Buffer NewBuffer( /* char where[] */ ) ;
tomwalters@0 68 extern Buffer SharedBuffer( /* Buffer buffer */ ) ;
tomwalters@0 69 extern Buffer ResizedBuffer( /* Buffer buffer, unsigned size */ ) ;
tomwalters@0 70 extern void FreeBuffer( /* Buffer buffer */ ) ;
tomwalters@0 71
tomwalters@0 72
tomwalters@0 73
tomwalters@0 74
tomwalters@0 75 /* basic types */
tomwalters@0 76
tomwalters@0 77 typedef struct _source *Source, *SourceArray[1] ;
tomwalters@0 78
tomwalters@0 79
tomwalters@0 80
tomwalters@0 81 typedef Source CharSource, ShortSource, IntSource, FloatSource, DoubleSource, ComplexSource ;
tomwalters@0 82 typedef SourceArray CharSourceArray, ShortSourceArray, IntSourceArray, FloatSourceArray, DoubleSourceArray, ComplexSourceArray ;
tomwalters@0 83
tomwalters@0 84 typedef int ByteCount ;
tomwalters@0 85
tomwalters@0 86 /* dependant on type of source */
tomwalters@0 87
tomwalters@0 88 struct _source { Pointer (*pull)(), (*fill)(), (*roll)(), returned ; char *name, *type ; int opened ; Source (*open)() ; } ;
tomwalters@0 89 struct _source_operators { Source (*set)() ; Pointer (*delete)() ; Source (*setType)() ; char *(*getType)() ; char *(*getName)() ; } ;
tomwalters@0 90
tomwalters@0 91 struct _pullable_source { struct _source parent ; } ;
tomwalters@0 92 struct _fillable_source { struct _source parent ; Buffer buffer ; } ;
tomwalters@0 93
tomwalters@0 94
tomwalters@0 95
tomwalters@0 96
tomwalters@0 97
tomwalters@0 98
tomwalters@0 99 extern Source setSource() ;
tomwalters@0 100 extern Source typeSource() ;
tomwalters@0 101 extern char *sourceType() ;
tomwalters@0 102 extern char *sourceName() ;
tomwalters@0 103 extern Pointer deleteSource() ;
tomwalters@0 104
tomwalters@0 105 extern Pointer oldPull(), oldFill(), oldRoll() ;
tomwalters@0 106
tomwalters@0 107
tomwalters@0 108 extern void sinkSource() ;
tomwalters@0 109 extern void CloseSource() ;
tomwalters@0 110 extern void sinkAndCloseSource() ;
tomwalters@0 111
tomwalters@0 112 /* derived source types for different purposes */
tomwalters@0 113
tomwalters@0 114 extern Source newTappingSource() ;
tomwalters@0 115 extern Source newRollableSource() ;
tomwalters@0 116
tomwalters@0 117 extern Pointer nonRoller() ;
tomwalters@0 118
tomwalters@0 119
tomwalters@0 120
tomwalters@0 121 /* fundamental active source types */
tomwalters@0 122
tomwalters@0 123 extern Source setPullableSource() ;
tomwalters@0 124 extern Pointer deletePullableSource() ;
tomwalters@0 125
tomwalters@0 126 /* simple assertive derived sources */
tomwalters@0 127
tomwalters@0 128 extern Source newSlaveSource() ;
tomwalters@0 129 extern Source newStaticSource() ;
tomwalters@0 130 extern Source newRetainingSource() ;
tomwalters@0 131 extern Source newDelayingSource() ;
tomwalters@0 132 extern Source newBlockingSource() ;
tomwalters@0 133
tomwalters@0 134
tomwalters@0 135
tomwalters@0 136 /* derived higher level filling sources */
tomwalters@0 137
tomwalters@0 138 extern Source setFillableSource() ;
tomwalters@0 139 extern Pointer deleteFillableSource() ;
tomwalters@0 140
tomwalters@0 141 extern Source newSegmentingSource() ;
tomwalters@0 142
tomwalters@0 143 extern Source setCallbackSource() ;
tomwalters@0 144 extern Source newExternalSource() ;
tomwalters@0 145 extern Source newThroughSource() ;
tomwalters@0 146
tomwalters@0 147 extern Source newProcessingSource() ;
tomwalters@0 148 extern Source newSimpleProcessingSource() ;
tomwalters@0 149 extern Source newMultiplexedSource() ;
tomwalters@0 150 extern Source newMergingSource() ;
tomwalters@0 151
tomwalters@0 152 extern Source sharingSource() ;
tomwalters@0 153
tomwalters@0 154 extern Source *BindSources() ;
tomwalters@0 155
tomwalters@0 156 /* for compatability... for now */
tomwalters@0 157
tomwalters@0 158 extern Source stdStaticSource() ;
tomwalters@0 159 extern Source stdSlaveSource() ;
tomwalters@0 160 extern Source stdAutoSource() ;
tomwalters@0 161 extern Source stdSelfSource() ;
tomwalters@0 162
tomwalters@0 163
tomwalters@0 164
tomwalters@0 165 extern Source EmptySource ;
tomwalters@0 166 /*
tomwalters@0 167 stypes.h
tomwalters@0 168 ======
tomwalters@0 169
tomwalters@0 170 defines types for sources operations
tomwalters@0 171
tomwalters@0 172
tomwalters@0 173 */
tomwalters@0 174
tomwalters@0 175 typedef struct { char *ident ; int size ; Source (*maker)() ; } TypeInfo ;
tomwalters@0 176
tomwalters@0 177 extern int typeEntryNumber() ;
tomwalters@0 178 extern Source TypeConvertSource() ;
tomwalters@0 179 extern Source SourceSource() ;
tomwalters@0 180
tomwalters@0 181 extern char CharIdent[] ;
tomwalters@0 182 extern char ShortIdent[] ;
tomwalters@0 183 extern char IntIdent[] ;
tomwalters@0 184 extern char LongIdent[] ;
tomwalters@0 185 extern char FloatIdent[] ;
tomwalters@0 186 extern char DoubleIdent[] ;
tomwalters@0 187
tomwalters@0 188
tomwalters@0 189
tomwalters@0 190 /* basic data operations */
tomwalters@0 191
tomwalters@0 192 extern CharSource ConstantCharSource( ), IntegrateCharSource( ), CallingCharSource( ) ;
tomwalters@0 193 extern ShortSource ConstantShortSource( ), IntegrateShortSource( ), CallingShortSource( ) ;
tomwalters@0 194 extern IntSource ConstantIntSource( ), IntegrateIntSource( ), CallingIntSource( ) ;
tomwalters@0 195 extern FloatSource ConstantFloatSource( ), IntegrateFloatSource( ), CallingFloatSource( ) ;
tomwalters@0 196 extern DoubleSource ConstantDoubleSource( ), IntegrateDoubleSource( ), CallingDoubleSource( ) ;
tomwalters@0 197 extern ComplexSource ConstantComplexSource( ), IntegrateComplexSource( ), CallingComplexSource( ) ;
tomwalters@0 198
tomwalters@0 199 /* binary operators */
tomwalters@0 200
tomwalters@0 201 extern CharSource AddCharSources( ), SubtractCharSources( ), MultiplyCharSources( ), DivideCharSources( ) ;
tomwalters@0 202 extern ShortSource AddShortSources( ), SubtractShortSources( ), MultiplyShortSources( ), DivideShortSources( ) ;
tomwalters@0 203 extern IntSource AddIntSources( ), SubtractIntSources( ), MultiplyIntSources( ), DivideIntSources( ) ;
tomwalters@0 204 extern FloatSource AddFloatSources( ), SubtractFloatSources( ), MultiplyFloatSources( ), DivideDoubleSources( ) ;
tomwalters@0 205 extern DoubleSource AddDoubleSources( ), SubtractDoubleSources( ), MultiplyDoubleSources( ), DivideFloatSources( ) ;
tomwalters@0 206 extern ComplexSource AddComplexSources( ), SubtractComplexSources( ), MultiplyComplexSources( ), DivideComplexSources( ) ;
tomwalters@0 207
tomwalters@0 208 extern Source AddSources( ), SubtractSources( ), MultiplySources( ), DivideSources( ) ;
tomwalters@0 209
tomwalters@0 210 /* convertors */
tomwalters@0 211
tomwalters@0 212 extern CharSource CharCharSource( ), ShortCharSource( ), IntCharSource( ), FloatCharSource( ), DoubleCharSource( ) ;
tomwalters@0 213 extern ShortSource CharShortSource( ), ShortShortSource( ), IntShortSource( ), FloatShortSource( ), DoubleShortSource( ) ;
tomwalters@0 214 extern IntSource CharIntSource( ), ShortIntSource( ), IntIntSource( ), FloatIntSource( ), DoubleIntSource( ) ;
tomwalters@0 215 extern FloatSource CharFloatSource( ), ShortFloatSource( ), IntFloatSource( ), FloatFloatSource( ), DoubleFloatSource( ) ;
tomwalters@0 216 extern DoubleSource CharDoubleSource( ), ShortDoubleSource( ), IntDoubleSource( ), FloatDoubleSource( ), DoubleDoubleSource( ) ;
tomwalters@0 217 extern ComplexSource CharComplexSource( ), ShortComplexSource( ), IntComplexSource( ), FloatComplexSource( ), DoubleComplexSource( ) ;
tomwalters@0 218
tomwalters@0 219 extern Source SourceCharSource( ), SourceShortSource( ), SourceIntSource( ), SourceFloatSource( ), SourceDoubleSource( ), SourceComplexSource( ) ;
tomwalters@0 220
tomwalters@0 221
tomwalters@0 222 static void charConstantCallback( state, bytes, buffer, end )
tomwalters@0 223 char *state ;
tomwalters@0 224 ByteCount *bytes ;
tomwalters@0 225 char *buffer, *end ;
tomwalters@0 226 {
tomwalters@0 227 register char i, *optr = buffer, *eptr = end ;
tomwalters@0 228
tomwalters@0 229 i = *state ;
tomwalters@0 230
tomwalters@0 231 if( optr < eptr )
tomwalters@0 232 do
tomwalters@0 233 *optr++ = i ;
tomwalters@0 234 while( optr < eptr ) ;
tomwalters@0 235
tomwalters@0 236 return ;
tomwalters@0 237 }
tomwalters@0 238
tomwalters@0 239 CharSource ConstantCharSource( constant )
tomwalters@0 240 char constant ;
tomwalters@0 241 {
tomwalters@0 242 char * state = ( char * ) stitch_malloc( (unsigned) ( ( sizeof * ( char * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 243
tomwalters@0 244 *state = constant ;
tomwalters@0 245
tomwalters@0 246 return ( newExternalSource( (Pointer) ( (Pointer) state ), charConstantCallback, stitch_free, "ops.type constant" ) ) ;
tomwalters@0 247 }
tomwalters@0 248
tomwalters@0 249
tomwalters@0 250 static void charIntegralCallback( integral, bytes, buffer, end, input )
tomwalters@0 251 char *integral ;
tomwalters@0 252 ByteCount *bytes ;
tomwalters@0 253 char *buffer, *end, *input ;
tomwalters@0 254 {
tomwalters@0 255 register char *iptr = input ;
tomwalters@0 256 register char *optr = buffer ;
tomwalters@0 257 register char *eptr = end ;
tomwalters@0 258
tomwalters@0 259 if( optr < eptr )
tomwalters@0 260 do {
tomwalters@0 261 *optr++ = *integral ;
tomwalters@0 262 *integral += *iptr++ ;
tomwalters@0 263 } while( optr < eptr ) ;
tomwalters@0 264
tomwalters@0 265 return ;
tomwalters@0 266 }
tomwalters@0 267
tomwalters@0 268 CharSource IntegrateCharSource( source, initial )
tomwalters@0 269 CharSource source ;
tomwalters@0 270 char initial ;
tomwalters@0 271 {
tomwalters@0 272 char * integral = ( char * ) stitch_malloc( (unsigned) ( ( sizeof * ( char * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 273
tomwalters@0 274 *integral = initial ;
tomwalters@0 275
tomwalters@0 276 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), charIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
tomwalters@0 277 }
tomwalters@0 278
tomwalters@0 279 static void charCallingCallback( function, bytes, buffer, end, input )
tomwalters@0 280 char (*function)() ;
tomwalters@0 281 ByteCount *bytes ;
tomwalters@0 282 char *buffer, *end, *input ;
tomwalters@0 283 {
tomwalters@0 284 register char *iptr = input ;
tomwalters@0 285 register char *optr = buffer ;
tomwalters@0 286 register char *eptr = end ;
tomwalters@0 287
tomwalters@0 288 if( optr < eptr )
tomwalters@0 289 do
tomwalters@0 290 *optr++ = function( *iptr++ ) ;
tomwalters@0 291 while( optr < eptr ) ;
tomwalters@0 292
tomwalters@0 293 return ;
tomwalters@0 294 }
tomwalters@0 295
tomwalters@0 296 CharSource CallingCharSource( source, function )
tomwalters@0 297 CharSource source ;
tomwalters@0 298 char (*function)() ;
tomwalters@0 299 {
tomwalters@0 300 return ( newProcessingSource( (Pointer) ( (Pointer) function ), charCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
tomwalters@0 301 }
tomwalters@0 302
tomwalters@0 303 /* do operators */
tomwalters@0 304
tomwalters@0 305
tomwalters@0 306 static void AddCharOp( state, bytes, output, end, input1, input2 )
tomwalters@0 307 Pointer *state ;
tomwalters@0 308 ByteCount *bytes ;
tomwalters@0 309 char *output, *end, *input1, *input2 ;
tomwalters@0 310 {
tomwalters@0 311 register char *optr = output ;
tomwalters@0 312 register char *ipt1 = input1 ;
tomwalters@0 313 register char *ipt2 = input2 ;
tomwalters@0 314 register char *eptr = end ;
tomwalters@0 315
tomwalters@0 316 if( optr < eptr )
tomwalters@0 317 do
tomwalters@0 318 *optr++ = *ipt1++ + *ipt2++ ;
tomwalters@0 319 while( optr < eptr ) ;
tomwalters@0 320
tomwalters@0 321 return ;
tomwalters@0 322 }
tomwalters@0 323
tomwalters@0 324 Source AddCharSources( input1, input2 )
tomwalters@0 325 Source input1, input2 ;
tomwalters@0 326 {
tomwalters@0 327 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 328
tomwalters@0 329 inputs[0] = input1 ;
tomwalters@0 330 inputs[1] = input2 ;
tomwalters@0 331
tomwalters@0 332 inputs[2] = (struct _source *) 0 ;
tomwalters@0 333
tomwalters@0 334 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 335 }
tomwalters@0 336
tomwalters@0 337 /* VARARGS2 */
tomwalters@0 338 Source AddCharSourceArray( inputs )
tomwalters@0 339 Source *inputs ;
tomwalters@0 340 {
tomwalters@0 341 int count = 0 ;
tomwalters@0 342
tomwalters@0 343 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 344 count++ ;
tomwalters@0 345
tomwalters@0 346 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddCharOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 347 }
tomwalters@0 348
tomwalters@0 349
tomwalters@0 350 static void SubtractCharOp( state, bytes, output, end, input1, input2 )
tomwalters@0 351 Pointer *state ;
tomwalters@0 352 ByteCount *bytes ;
tomwalters@0 353 char *output, *end, *input1, *input2 ;
tomwalters@0 354 {
tomwalters@0 355 register char *optr = output ;
tomwalters@0 356 register char *ipt1 = input1 ;
tomwalters@0 357 register char *ipt2 = input2 ;
tomwalters@0 358 register char *eptr = end ;
tomwalters@0 359
tomwalters@0 360 if( optr < eptr )
tomwalters@0 361 do
tomwalters@0 362 *optr++ = *ipt1++ - *ipt2++ ;
tomwalters@0 363 while( optr < eptr ) ;
tomwalters@0 364
tomwalters@0 365 return ;
tomwalters@0 366 }
tomwalters@0 367
tomwalters@0 368 Source SubtractCharSources( input1, input2 )
tomwalters@0 369 Source input1, input2 ;
tomwalters@0 370 {
tomwalters@0 371 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 372
tomwalters@0 373 inputs[0] = input1 ;
tomwalters@0 374 inputs[1] = input2 ;
tomwalters@0 375
tomwalters@0 376 inputs[2] = (struct _source *) 0 ;
tomwalters@0 377
tomwalters@0 378 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 379 }
tomwalters@0 380
tomwalters@0 381 /* VARARGS2 */
tomwalters@0 382 Source SubtractCharSourceArray( inputs )
tomwalters@0 383 Source *inputs ;
tomwalters@0 384 {
tomwalters@0 385 int count = 0 ;
tomwalters@0 386
tomwalters@0 387 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 388 count++ ;
tomwalters@0 389
tomwalters@0 390 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractCharOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 391 }
tomwalters@0 392
tomwalters@0 393
tomwalters@0 394 static void MultiplyCharOp( state, bytes, output, end, input1, input2 )
tomwalters@0 395 Pointer *state ;
tomwalters@0 396 ByteCount *bytes ;
tomwalters@0 397 char *output, *end, *input1, *input2 ;
tomwalters@0 398 {
tomwalters@0 399 register char *optr = output ;
tomwalters@0 400 register char *ipt1 = input1 ;
tomwalters@0 401 register char *ipt2 = input2 ;
tomwalters@0 402 register char *eptr = end ;
tomwalters@0 403
tomwalters@0 404 if( optr < eptr )
tomwalters@0 405 do
tomwalters@0 406 *optr++ = *ipt1++ * *ipt2++ ;
tomwalters@0 407 while( optr < eptr ) ;
tomwalters@0 408
tomwalters@0 409 return ;
tomwalters@0 410 }
tomwalters@0 411
tomwalters@0 412 Source MultiplyCharSources( input1, input2 )
tomwalters@0 413 Source input1, input2 ;
tomwalters@0 414 {
tomwalters@0 415 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 416
tomwalters@0 417 inputs[0] = input1 ;
tomwalters@0 418 inputs[1] = input2 ;
tomwalters@0 419
tomwalters@0 420 inputs[2] = (struct _source *) 0 ;
tomwalters@0 421
tomwalters@0 422 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 423 }
tomwalters@0 424
tomwalters@0 425 /* VARARGS2 */
tomwalters@0 426 Source MultiplyCharSourceArray( inputs )
tomwalters@0 427 Source *inputs ;
tomwalters@0 428 {
tomwalters@0 429 int count = 0 ;
tomwalters@0 430
tomwalters@0 431 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 432 count++ ;
tomwalters@0 433
tomwalters@0 434 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyCharOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 435 }
tomwalters@0 436
tomwalters@0 437
tomwalters@0 438 static void DivideCharOp( state, bytes, output, end, input1, input2 )
tomwalters@0 439 Pointer *state ;
tomwalters@0 440 ByteCount *bytes ;
tomwalters@0 441 char *output, *end, *input1, *input2 ;
tomwalters@0 442 {
tomwalters@0 443 register char *optr = output ;
tomwalters@0 444 register char *ipt1 = input1 ;
tomwalters@0 445 register char *ipt2 = input2 ;
tomwalters@0 446 register char *eptr = end ;
tomwalters@0 447
tomwalters@0 448 if( optr < eptr )
tomwalters@0 449 do
tomwalters@0 450 *optr++ = *ipt1++ / *ipt2++ ;
tomwalters@0 451 while( optr < eptr ) ;
tomwalters@0 452
tomwalters@0 453 return ;
tomwalters@0 454 }
tomwalters@0 455
tomwalters@0 456 Source DivideCharSources( input1, input2 )
tomwalters@0 457 Source input1, input2 ;
tomwalters@0 458 {
tomwalters@0 459 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 460
tomwalters@0 461 inputs[0] = input1 ;
tomwalters@0 462 inputs[1] = input2 ;
tomwalters@0 463
tomwalters@0 464 inputs[2] = (struct _source *) 0 ;
tomwalters@0 465
tomwalters@0 466 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideCharOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 467 }
tomwalters@0 468
tomwalters@0 469 /* VARARGS2 */
tomwalters@0 470 Source DivideCharSourceArray( inputs )
tomwalters@0 471 Source *inputs ;
tomwalters@0 472 {
tomwalters@0 473 int count = 0 ;
tomwalters@0 474
tomwalters@0 475 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 476 count++ ;
tomwalters@0 477
tomwalters@0 478 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideCharOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 479 }
tomwalters@0 480
tomwalters@0 481
tomwalters@0 482
tomwalters@0 483
tomwalters@0 484 /* create convertors */
tomwalters@0 485
tomwalters@0 486 static void CharCharCallback( state, bytes, buffer )
tomwalters@0 487 Source state ;
tomwalters@0 488 ByteCount bytes ;
tomwalters@0 489 char *buffer ;
tomwalters@0 490 {
tomwalters@0 491 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 492 register char *o = buffer ;
tomwalters@0 493 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 494
tomwalters@0 495 if( (Pointer) o < e )
tomwalters@0 496 do
tomwalters@0 497 *o++ = *i++ ;
tomwalters@0 498 while( (Pointer) o < e ) ;
tomwalters@0 499
tomwalters@0 500 return ;
tomwalters@0 501 }
tomwalters@0 502
tomwalters@0 503 CharSource CharCharSource( source )
tomwalters@0 504 CharSource source ;
tomwalters@0 505 {
tomwalters@0 506 return( stdAutoSource( ( Pointer ) source, CharCharCallback ) ) ;
tomwalters@0 507 }
tomwalters@0 508
tomwalters@0 509
tomwalters@0 510 static void ShortCharCallback( state, bytes, buffer )
tomwalters@0 511 Source state ;
tomwalters@0 512 ByteCount bytes ;
tomwalters@0 513 char *buffer ;
tomwalters@0 514 {
tomwalters@0 515 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 516 register char *o = buffer ;
tomwalters@0 517 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 518
tomwalters@0 519 if( (Pointer) o < e )
tomwalters@0 520 do
tomwalters@0 521 *o++ = *i++ ;
tomwalters@0 522 while( (Pointer) o < e ) ;
tomwalters@0 523
tomwalters@0 524 return ;
tomwalters@0 525 }
tomwalters@0 526
tomwalters@0 527 CharSource ShortCharSource( source )
tomwalters@0 528 CharSource source ;
tomwalters@0 529 {
tomwalters@0 530 return( stdAutoSource( ( Pointer ) source, ShortCharCallback ) ) ;
tomwalters@0 531 }
tomwalters@0 532
tomwalters@0 533
tomwalters@0 534
tomwalters@0 535
tomwalters@0 536 static void IntCharCallback( state, bytes, buffer )
tomwalters@0 537 Source state ;
tomwalters@0 538 ByteCount bytes ;
tomwalters@0 539 char *buffer ;
tomwalters@0 540 {
tomwalters@0 541 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 542 register char *o = buffer ;
tomwalters@0 543 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 544
tomwalters@0 545 if( (Pointer) o < e )
tomwalters@0 546 do
tomwalters@0 547 *o++ = *i++ ;
tomwalters@0 548 while( (Pointer) o < e ) ;
tomwalters@0 549
tomwalters@0 550 return ;
tomwalters@0 551 }
tomwalters@0 552
tomwalters@0 553 CharSource IntCharSource( source )
tomwalters@0 554 CharSource source ;
tomwalters@0 555 {
tomwalters@0 556 return( stdAutoSource( ( Pointer ) source, IntCharCallback ) ) ;
tomwalters@0 557 }
tomwalters@0 558
tomwalters@0 559
tomwalters@0 560 static void FloatCharCallback( state, bytes, buffer )
tomwalters@0 561 Source state ;
tomwalters@0 562 ByteCount bytes ;
tomwalters@0 563 char *buffer ;
tomwalters@0 564 {
tomwalters@0 565 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 566 register char *o = buffer ;
tomwalters@0 567 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 568
tomwalters@0 569 if( (Pointer) o < e )
tomwalters@0 570 do
tomwalters@0 571 *o++ = *i++ ;
tomwalters@0 572 while( (Pointer) o < e ) ;
tomwalters@0 573
tomwalters@0 574 return ;
tomwalters@0 575 }
tomwalters@0 576
tomwalters@0 577 CharSource FloatCharSource( source )
tomwalters@0 578 CharSource source ;
tomwalters@0 579 {
tomwalters@0 580 return( stdAutoSource( ( Pointer ) source, FloatCharCallback ) ) ;
tomwalters@0 581 }
tomwalters@0 582
tomwalters@0 583
tomwalters@0 584
tomwalters@0 585 static void DoubleCharCallback( state, bytes, buffer )
tomwalters@0 586 Source state ;
tomwalters@0 587 ByteCount bytes ;
tomwalters@0 588 char *buffer ;
tomwalters@0 589 {
tomwalters@0 590 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( char) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 591 register char *o = buffer ;
tomwalters@0 592 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 593
tomwalters@0 594 if( (Pointer) o < e )
tomwalters@0 595 do
tomwalters@0 596 *o++ = *i++ ;
tomwalters@0 597 while( (Pointer) o < e ) ;
tomwalters@0 598
tomwalters@0 599 return ;
tomwalters@0 600 }
tomwalters@0 601
tomwalters@0 602 CharSource DoubleCharSource( source )
tomwalters@0 603 CharSource source ;
tomwalters@0 604 {
tomwalters@0 605 return( stdAutoSource( ( Pointer ) source, DoubleCharCallback ) ) ;
tomwalters@0 606 }
tomwalters@0 607
tomwalters@0 608
tomwalters@0 609
tomwalters@0 610
tomwalters@0 611 Source SourceCharSource( source )
tomwalters@0 612 Source source ;
tomwalters@0 613 {
tomwalters@0 614 static Source (*converts[])() = {
tomwalters@0 615 SourceSource,
tomwalters@0 616 CharCharSource,
tomwalters@0 617 ShortCharSource,
tomwalters@0 618 IntCharSource,
tomwalters@0 619 FloatCharSource,
tomwalters@0 620 DoubleCharSource
tomwalters@0 621 } ;
tomwalters@0 622
tomwalters@0 623 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
tomwalters@0 624 }
tomwalters@0 625
tomwalters@0 626
tomwalters@0 627 static void shortConstantCallback( state, bytes, buffer, end )
tomwalters@0 628 short *state ;
tomwalters@0 629 ByteCount *bytes ;
tomwalters@0 630 short *buffer, *end ;
tomwalters@0 631 {
tomwalters@0 632 register short i, *optr = buffer, *eptr = end ;
tomwalters@0 633
tomwalters@0 634 i = *state ;
tomwalters@0 635
tomwalters@0 636 if( optr < eptr )
tomwalters@0 637 do
tomwalters@0 638 *optr++ = i ;
tomwalters@0 639 while( optr < eptr ) ;
tomwalters@0 640
tomwalters@0 641 return ;
tomwalters@0 642 }
tomwalters@0 643
tomwalters@0 644 ShortSource ConstantShortSource( constant )
tomwalters@0 645 short constant ;
tomwalters@0 646 {
tomwalters@0 647 short * state = ( short * ) stitch_malloc( (unsigned) ( ( sizeof * ( short * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 648
tomwalters@0 649 *state = constant ;
tomwalters@0 650
tomwalters@0 651 return ( newExternalSource( (Pointer) ( (Pointer) state ), shortConstantCallback, stitch_free, "ops.type constant" ) ) ;
tomwalters@0 652 }
tomwalters@0 653
tomwalters@0 654
tomwalters@0 655 static void shortIntegralCallback( integral, bytes, buffer, end, input )
tomwalters@0 656 short *integral ;
tomwalters@0 657 ByteCount *bytes ;
tomwalters@0 658 short *buffer, *end, *input ;
tomwalters@0 659 {
tomwalters@0 660 register short *iptr = input ;
tomwalters@0 661 register short *optr = buffer ;
tomwalters@0 662 register short *eptr = end ;
tomwalters@0 663
tomwalters@0 664 if( optr < eptr )
tomwalters@0 665 do {
tomwalters@0 666 *optr++ = *integral ;
tomwalters@0 667 *integral += *iptr++ ;
tomwalters@0 668 } while( optr < eptr ) ;
tomwalters@0 669
tomwalters@0 670 return ;
tomwalters@0 671 }
tomwalters@0 672
tomwalters@0 673 ShortSource IntegrateShortSource( source, initial )
tomwalters@0 674 ShortSource source ;
tomwalters@0 675 short initial ;
tomwalters@0 676 {
tomwalters@0 677 short * integral = ( short * ) stitch_malloc( (unsigned) ( ( sizeof * ( short * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 678
tomwalters@0 679 *integral = initial ;
tomwalters@0 680
tomwalters@0 681 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), shortIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
tomwalters@0 682 }
tomwalters@0 683
tomwalters@0 684 static void shortCallingCallback( function, bytes, buffer, end, input )
tomwalters@0 685 short (*function)() ;
tomwalters@0 686 ByteCount *bytes ;
tomwalters@0 687 short *buffer, *end, *input ;
tomwalters@0 688 {
tomwalters@0 689 register short *iptr = input ;
tomwalters@0 690 register short *optr = buffer ;
tomwalters@0 691 register short *eptr = end ;
tomwalters@0 692
tomwalters@0 693 if( optr < eptr )
tomwalters@0 694 do
tomwalters@0 695 *optr++ = function( *iptr++ ) ;
tomwalters@0 696 while( optr < eptr ) ;
tomwalters@0 697
tomwalters@0 698 return ;
tomwalters@0 699 }
tomwalters@0 700
tomwalters@0 701 ShortSource CallingShortSource( source, function )
tomwalters@0 702 ShortSource source ;
tomwalters@0 703 short (*function)() ;
tomwalters@0 704 {
tomwalters@0 705 return ( newProcessingSource( (Pointer) ( (Pointer) function ), shortCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
tomwalters@0 706 }
tomwalters@0 707
tomwalters@0 708 /* do operators */
tomwalters@0 709
tomwalters@0 710 static void AddShortOp( state, bytes, output, end, input1, input2 )
tomwalters@0 711 Pointer *state ;
tomwalters@0 712 ByteCount *bytes ;
tomwalters@0 713 short *output, *end, *input1, *input2 ;
tomwalters@0 714 {
tomwalters@0 715 register short *optr = output ;
tomwalters@0 716 register short *ipt1 = input1 ;
tomwalters@0 717 register short *ipt2 = input2 ;
tomwalters@0 718 register short *eptr = end ;
tomwalters@0 719
tomwalters@0 720 if( optr < eptr )
tomwalters@0 721 do
tomwalters@0 722 *optr++ = *ipt1++ + *ipt2++ ;
tomwalters@0 723 while( optr < eptr ) ;
tomwalters@0 724
tomwalters@0 725 return ;
tomwalters@0 726 }
tomwalters@0 727
tomwalters@0 728 Source AddShortSources( input1, input2 )
tomwalters@0 729 Source input1, input2 ;
tomwalters@0 730 {
tomwalters@0 731 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 732
tomwalters@0 733 inputs[0] = input1 ;
tomwalters@0 734 inputs[1] = input2 ;
tomwalters@0 735
tomwalters@0 736 inputs[2] = (struct _source *) 0 ;
tomwalters@0 737
tomwalters@0 738 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 739 }
tomwalters@0 740
tomwalters@0 741 /* VARARGS2 */
tomwalters@0 742 Source AddShortSourceArray( inputs )
tomwalters@0 743 Source *inputs ;
tomwalters@0 744 {
tomwalters@0 745 int count = 0 ;
tomwalters@0 746
tomwalters@0 747 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 748 count++ ;
tomwalters@0 749
tomwalters@0 750 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddShortOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 751 }
tomwalters@0 752
tomwalters@0 753
tomwalters@0 754 static void SubtractShortOp( state, bytes, output, end, input1, input2 )
tomwalters@0 755 Pointer *state ;
tomwalters@0 756 ByteCount *bytes ;
tomwalters@0 757 short *output, *end, *input1, *input2 ;
tomwalters@0 758 {
tomwalters@0 759 register short *optr = output ;
tomwalters@0 760 register short *ipt1 = input1 ;
tomwalters@0 761 register short *ipt2 = input2 ;
tomwalters@0 762 register short *eptr = end ;
tomwalters@0 763
tomwalters@0 764 if( optr < eptr )
tomwalters@0 765 do
tomwalters@0 766 *optr++ = *ipt1++ - *ipt2++ ;
tomwalters@0 767 while( optr < eptr ) ;
tomwalters@0 768
tomwalters@0 769 return ;
tomwalters@0 770 }
tomwalters@0 771
tomwalters@0 772 Source SubtractShortSources( input1, input2 )
tomwalters@0 773 Source input1, input2 ;
tomwalters@0 774 {
tomwalters@0 775 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 776
tomwalters@0 777 inputs[0] = input1 ;
tomwalters@0 778 inputs[1] = input2 ;
tomwalters@0 779
tomwalters@0 780 inputs[2] = (struct _source *) 0 ;
tomwalters@0 781
tomwalters@0 782 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 783 }
tomwalters@0 784
tomwalters@0 785 /* VARARGS2 */
tomwalters@0 786 Source SubtractShortSourceArray( inputs )
tomwalters@0 787 Source *inputs ;
tomwalters@0 788 {
tomwalters@0 789 int count = 0 ;
tomwalters@0 790
tomwalters@0 791 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 792 count++ ;
tomwalters@0 793
tomwalters@0 794 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractShortOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 795 }
tomwalters@0 796
tomwalters@0 797
tomwalters@0 798 static void MultiplyShortOp( state, bytes, output, end, input1, input2 )
tomwalters@0 799 Pointer *state ;
tomwalters@0 800 ByteCount *bytes ;
tomwalters@0 801 short *output, *end, *input1, *input2 ;
tomwalters@0 802 {
tomwalters@0 803 register short *optr = output ;
tomwalters@0 804 register short *ipt1 = input1 ;
tomwalters@0 805 register short *ipt2 = input2 ;
tomwalters@0 806 register short *eptr = end ;
tomwalters@0 807
tomwalters@0 808 if( optr < eptr )
tomwalters@0 809 do
tomwalters@0 810 *optr++ = *ipt1++ * *ipt2++ ;
tomwalters@0 811 while( optr < eptr ) ;
tomwalters@0 812
tomwalters@0 813 return ;
tomwalters@0 814 }
tomwalters@0 815
tomwalters@0 816 Source MultiplyShortSources( input1, input2 )
tomwalters@0 817 Source input1, input2 ;
tomwalters@0 818 {
tomwalters@0 819 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 820
tomwalters@0 821 inputs[0] = input1 ;
tomwalters@0 822 inputs[1] = input2 ;
tomwalters@0 823
tomwalters@0 824 inputs[2] = (struct _source *) 0 ;
tomwalters@0 825
tomwalters@0 826 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 827 }
tomwalters@0 828
tomwalters@0 829 /* VARARGS2 */
tomwalters@0 830 Source MultiplyShortSourceArray( inputs )
tomwalters@0 831 Source *inputs ;
tomwalters@0 832 {
tomwalters@0 833 int count = 0 ;
tomwalters@0 834
tomwalters@0 835 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 836 count++ ;
tomwalters@0 837
tomwalters@0 838 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyShortOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 839 }
tomwalters@0 840
tomwalters@0 841
tomwalters@0 842 static void DivideShortOp( state, bytes, output, end, input1, input2 )
tomwalters@0 843 Pointer *state ;
tomwalters@0 844 ByteCount *bytes ;
tomwalters@0 845 short *output, *end, *input1, *input2 ;
tomwalters@0 846 {
tomwalters@0 847 register short *optr = output ;
tomwalters@0 848 register short *ipt1 = input1 ;
tomwalters@0 849 register short *ipt2 = input2 ;
tomwalters@0 850 register short *eptr = end ;
tomwalters@0 851
tomwalters@0 852 if( optr < eptr )
tomwalters@0 853 do
tomwalters@0 854 *optr++ = *ipt1++ / *ipt2++ ;
tomwalters@0 855 while( optr < eptr ) ;
tomwalters@0 856
tomwalters@0 857 return ;
tomwalters@0 858 }
tomwalters@0 859
tomwalters@0 860 Source DivideShortSources( input1, input2 )
tomwalters@0 861 Source input1, input2 ;
tomwalters@0 862 {
tomwalters@0 863 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 864
tomwalters@0 865 inputs[0] = input1 ;
tomwalters@0 866 inputs[1] = input2 ;
tomwalters@0 867
tomwalters@0 868 inputs[2] = (struct _source *) 0 ;
tomwalters@0 869
tomwalters@0 870 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideShortOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 871 }
tomwalters@0 872
tomwalters@0 873 /* VARARGS2 */
tomwalters@0 874 Source DivideShortSourceArray( inputs )
tomwalters@0 875 Source *inputs ;
tomwalters@0 876 {
tomwalters@0 877 int count = 0 ;
tomwalters@0 878
tomwalters@0 879 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 880 count++ ;
tomwalters@0 881
tomwalters@0 882 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideShortOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 883 }
tomwalters@0 884
tomwalters@0 885
tomwalters@0 886
tomwalters@0 887
tomwalters@0 888 /* create convertors */
tomwalters@0 889
tomwalters@0 890
tomwalters@0 891 static void CharShortCallback( state, bytes, buffer )
tomwalters@0 892 Source state ;
tomwalters@0 893 ByteCount bytes ;
tomwalters@0 894 short *buffer ;
tomwalters@0 895 {
tomwalters@0 896 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 897 register short *o = buffer ;
tomwalters@0 898 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 899
tomwalters@0 900 if( (Pointer) o < e )
tomwalters@0 901 do
tomwalters@0 902 *o++ = *i++ ;
tomwalters@0 903 while( (Pointer) o < e ) ;
tomwalters@0 904
tomwalters@0 905 return ;
tomwalters@0 906 }
tomwalters@0 907
tomwalters@0 908 ShortSource CharShortSource( source )
tomwalters@0 909 ShortSource source ;
tomwalters@0 910 {
tomwalters@0 911 return( stdAutoSource( ( Pointer ) source, CharShortCallback ) ) ;
tomwalters@0 912 }
tomwalters@0 913
tomwalters@0 914
tomwalters@0 915
tomwalters@0 916 static void ShortShortCallback( state, bytes, buffer )
tomwalters@0 917 Source state ;
tomwalters@0 918 ByteCount bytes ;
tomwalters@0 919 short *buffer ;
tomwalters@0 920 {
tomwalters@0 921 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 922 register short *o = buffer ;
tomwalters@0 923 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 924
tomwalters@0 925 if( (Pointer) o < e )
tomwalters@0 926 do
tomwalters@0 927 *o++ = *i++ ;
tomwalters@0 928 while( (Pointer) o < e ) ;
tomwalters@0 929
tomwalters@0 930 return ;
tomwalters@0 931 }
tomwalters@0 932
tomwalters@0 933 ShortSource ShortShortSource( source )
tomwalters@0 934 ShortSource source ;
tomwalters@0 935 {
tomwalters@0 936 return( stdAutoSource( ( Pointer ) source, ShortShortCallback ) ) ;
tomwalters@0 937 }
tomwalters@0 938
tomwalters@0 939
tomwalters@0 940 static void IntShortCallback( state, bytes, buffer )
tomwalters@0 941 Source state ;
tomwalters@0 942 ByteCount bytes ;
tomwalters@0 943 short *buffer ;
tomwalters@0 944 {
tomwalters@0 945 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 946 register short *o = buffer ;
tomwalters@0 947 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 948
tomwalters@0 949 if( (Pointer) o < e )
tomwalters@0 950 do
tomwalters@0 951 *o++ = *i++ ;
tomwalters@0 952 while( (Pointer) o < e ) ;
tomwalters@0 953
tomwalters@0 954 return ;
tomwalters@0 955 }
tomwalters@0 956
tomwalters@0 957 ShortSource IntShortSource( source )
tomwalters@0 958 ShortSource source ;
tomwalters@0 959 {
tomwalters@0 960 return( stdAutoSource( ( Pointer ) source, IntShortCallback ) ) ;
tomwalters@0 961 }
tomwalters@0 962
tomwalters@0 963
tomwalters@0 964
tomwalters@0 965 static void FloatShortCallback( state, bytes, buffer )
tomwalters@0 966 Source state ;
tomwalters@0 967 ByteCount bytes ;
tomwalters@0 968 short *buffer ;
tomwalters@0 969 {
tomwalters@0 970 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 971 register short *o = buffer ;
tomwalters@0 972 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 973
tomwalters@0 974 if( (Pointer) o < e )
tomwalters@0 975 do
tomwalters@0 976 *o++ = *i++ ;
tomwalters@0 977 while( (Pointer) o < e ) ;
tomwalters@0 978
tomwalters@0 979 return ;
tomwalters@0 980 }
tomwalters@0 981
tomwalters@0 982 ShortSource FloatShortSource( source )
tomwalters@0 983 ShortSource source ;
tomwalters@0 984 {
tomwalters@0 985 return( stdAutoSource( ( Pointer ) source, FloatShortCallback ) ) ;
tomwalters@0 986 }
tomwalters@0 987
tomwalters@0 988
tomwalters@0 989 static void DoubleShortCallback( state, bytes, buffer )
tomwalters@0 990 Source state ;
tomwalters@0 991 ByteCount bytes ;
tomwalters@0 992 short *buffer ;
tomwalters@0 993 {
tomwalters@0 994 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( short) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 995 register short *o = buffer ;
tomwalters@0 996 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 997
tomwalters@0 998 if( (Pointer) o < e )
tomwalters@0 999 do
tomwalters@0 1000 *o++ = *i++ ;
tomwalters@0 1001 while( (Pointer) o < e ) ;
tomwalters@0 1002
tomwalters@0 1003 return ;
tomwalters@0 1004 }
tomwalters@0 1005
tomwalters@0 1006 ShortSource DoubleShortSource( source )
tomwalters@0 1007 ShortSource source ;
tomwalters@0 1008 {
tomwalters@0 1009 return( stdAutoSource( ( Pointer ) source, DoubleShortCallback ) ) ;
tomwalters@0 1010 }
tomwalters@0 1011
tomwalters@0 1012
tomwalters@0 1013
tomwalters@0 1014
tomwalters@0 1015 Source SourceShortSource( source )
tomwalters@0 1016 Source source ;
tomwalters@0 1017 {
tomwalters@0 1018 static Source (*converts[])() = {
tomwalters@0 1019 SourceSource,
tomwalters@0 1020 CharShortSource,
tomwalters@0 1021 ShortShortSource,
tomwalters@0 1022 IntShortSource,
tomwalters@0 1023 FloatShortSource,
tomwalters@0 1024 DoubleShortSource
tomwalters@0 1025 } ;
tomwalters@0 1026
tomwalters@0 1027 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
tomwalters@0 1028 }
tomwalters@0 1029
tomwalters@0 1030
tomwalters@0 1031
tomwalters@0 1032 static void intConstantCallback( state, bytes, buffer, end )
tomwalters@0 1033 int *state ;
tomwalters@0 1034 ByteCount *bytes ;
tomwalters@0 1035 int *buffer, *end ;
tomwalters@0 1036 {
tomwalters@0 1037 register int i, *optr = buffer, *eptr = end ;
tomwalters@0 1038
tomwalters@0 1039 i = *state ;
tomwalters@0 1040
tomwalters@0 1041 if( optr < eptr )
tomwalters@0 1042 do
tomwalters@0 1043 *optr++ = i ;
tomwalters@0 1044 while( optr < eptr ) ;
tomwalters@0 1045
tomwalters@0 1046 return ;
tomwalters@0 1047 }
tomwalters@0 1048
tomwalters@0 1049 IntSource ConstantIntSource( constant )
tomwalters@0 1050 int constant ;
tomwalters@0 1051 {
tomwalters@0 1052 int * state = ( int * ) stitch_malloc( (unsigned) ( ( sizeof * ( int * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 1053
tomwalters@0 1054 *state = constant ;
tomwalters@0 1055
tomwalters@0 1056 return ( newExternalSource( (Pointer) ( (Pointer) state ), intConstantCallback, stitch_free, "ops.type constant" ) ) ;
tomwalters@0 1057 }
tomwalters@0 1058
tomwalters@0 1059
tomwalters@0 1060 static void intIntegralCallback( integral, bytes, buffer, end, input )
tomwalters@0 1061 int *integral ;
tomwalters@0 1062 ByteCount *bytes ;
tomwalters@0 1063 int *buffer, *end, *input ;
tomwalters@0 1064 {
tomwalters@0 1065 register int *iptr = input ;
tomwalters@0 1066 register int *optr = buffer ;
tomwalters@0 1067 register int *eptr = end ;
tomwalters@0 1068
tomwalters@0 1069 if( optr < eptr )
tomwalters@0 1070 do {
tomwalters@0 1071 *optr++ = *integral ;
tomwalters@0 1072 *integral += *iptr++ ;
tomwalters@0 1073 } while( optr < eptr ) ;
tomwalters@0 1074
tomwalters@0 1075 return ;
tomwalters@0 1076 }
tomwalters@0 1077
tomwalters@0 1078 IntSource IntegrateIntSource( source, initial )
tomwalters@0 1079 IntSource source ;
tomwalters@0 1080 int initial ;
tomwalters@0 1081 {
tomwalters@0 1082 int * integral = ( int * ) stitch_malloc( (unsigned) ( ( sizeof * ( int * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 1083
tomwalters@0 1084 *integral = initial ;
tomwalters@0 1085
tomwalters@0 1086 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), intIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
tomwalters@0 1087 }
tomwalters@0 1088
tomwalters@0 1089 static void intCallingCallback( function, bytes, buffer, end, input )
tomwalters@0 1090 int (*function)() ;
tomwalters@0 1091 ByteCount *bytes ;
tomwalters@0 1092 int *buffer, *end, *input ;
tomwalters@0 1093 {
tomwalters@0 1094 register int *iptr = input ;
tomwalters@0 1095 register int *optr = buffer ;
tomwalters@0 1096 register int *eptr = end ;
tomwalters@0 1097
tomwalters@0 1098 if( optr < eptr )
tomwalters@0 1099 do
tomwalters@0 1100 *optr++ = function( *iptr++ ) ;
tomwalters@0 1101 while( optr < eptr ) ;
tomwalters@0 1102
tomwalters@0 1103 return ;
tomwalters@0 1104 }
tomwalters@0 1105
tomwalters@0 1106 IntSource CallingIntSource( source, function )
tomwalters@0 1107 IntSource source ;
tomwalters@0 1108 int (*function)() ;
tomwalters@0 1109 {
tomwalters@0 1110 return ( newProcessingSource( (Pointer) ( (Pointer) function ), intCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
tomwalters@0 1111 }
tomwalters@0 1112
tomwalters@0 1113 /* do operators */
tomwalters@0 1114
tomwalters@0 1115
tomwalters@0 1116 static void AddIntOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1117 Pointer *state ;
tomwalters@0 1118 ByteCount *bytes ;
tomwalters@0 1119 int *output, *end, *input1, *input2 ;
tomwalters@0 1120 {
tomwalters@0 1121 register int *optr = output ;
tomwalters@0 1122 register int *ipt1 = input1 ;
tomwalters@0 1123 register int *ipt2 = input2 ;
tomwalters@0 1124 register int *eptr = end ;
tomwalters@0 1125
tomwalters@0 1126 if( optr < eptr )
tomwalters@0 1127 do
tomwalters@0 1128 *optr++ = *ipt1++ + *ipt2++ ;
tomwalters@0 1129 while( optr < eptr ) ;
tomwalters@0 1130
tomwalters@0 1131 return ;
tomwalters@0 1132 }
tomwalters@0 1133
tomwalters@0 1134 Source AddIntSources( input1, input2 )
tomwalters@0 1135 Source input1, input2 ;
tomwalters@0 1136 {
tomwalters@0 1137 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1138
tomwalters@0 1139 inputs[0] = input1 ;
tomwalters@0 1140 inputs[1] = input2 ;
tomwalters@0 1141
tomwalters@0 1142 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1143
tomwalters@0 1144 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1145 }
tomwalters@0 1146
tomwalters@0 1147 /* VARARGS2 */
tomwalters@0 1148 Source AddIntSourceArray( inputs )
tomwalters@0 1149 Source *inputs ;
tomwalters@0 1150 {
tomwalters@0 1151 int count = 0 ;
tomwalters@0 1152
tomwalters@0 1153 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1154 count++ ;
tomwalters@0 1155
tomwalters@0 1156 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddIntOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1157 }
tomwalters@0 1158
tomwalters@0 1159
tomwalters@0 1160
tomwalters@0 1161 static void SubtractIntOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1162 Pointer *state ;
tomwalters@0 1163 ByteCount *bytes ;
tomwalters@0 1164 int *output, *end, *input1, *input2 ;
tomwalters@0 1165 {
tomwalters@0 1166 register int *optr = output ;
tomwalters@0 1167 register int *ipt1 = input1 ;
tomwalters@0 1168 register int *ipt2 = input2 ;
tomwalters@0 1169 register int *eptr = end ;
tomwalters@0 1170
tomwalters@0 1171 if( optr < eptr )
tomwalters@0 1172 do
tomwalters@0 1173 *optr++ = *ipt1++ - *ipt2++ ;
tomwalters@0 1174 while( optr < eptr ) ;
tomwalters@0 1175
tomwalters@0 1176 return ;
tomwalters@0 1177 }
tomwalters@0 1178
tomwalters@0 1179 Source SubtractIntSources( input1, input2 )
tomwalters@0 1180 Source input1, input2 ;
tomwalters@0 1181 {
tomwalters@0 1182 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1183
tomwalters@0 1184 inputs[0] = input1 ;
tomwalters@0 1185 inputs[1] = input2 ;
tomwalters@0 1186
tomwalters@0 1187 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1188
tomwalters@0 1189 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1190 }
tomwalters@0 1191
tomwalters@0 1192 /* VARARGS2 */
tomwalters@0 1193 Source SubtractIntSourceArray( inputs )
tomwalters@0 1194 Source *inputs ;
tomwalters@0 1195 {
tomwalters@0 1196 int count = 0 ;
tomwalters@0 1197
tomwalters@0 1198 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1199 count++ ;
tomwalters@0 1200
tomwalters@0 1201 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractIntOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1202 }
tomwalters@0 1203
tomwalters@0 1204
tomwalters@0 1205
tomwalters@0 1206
tomwalters@0 1207 static void MultiplyIntOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1208 Pointer *state ;
tomwalters@0 1209 ByteCount *bytes ;
tomwalters@0 1210 int *output, *end, *input1, *input2 ;
tomwalters@0 1211 {
tomwalters@0 1212 register int *optr = output ;
tomwalters@0 1213 register int *ipt1 = input1 ;
tomwalters@0 1214 register int *ipt2 = input2 ;
tomwalters@0 1215 register int *eptr = end ;
tomwalters@0 1216
tomwalters@0 1217 if( optr < eptr )
tomwalters@0 1218 do
tomwalters@0 1219 *optr++ = *ipt1++ * *ipt2++ ;
tomwalters@0 1220 while( optr < eptr ) ;
tomwalters@0 1221
tomwalters@0 1222 return ;
tomwalters@0 1223 }
tomwalters@0 1224
tomwalters@0 1225 Source MultiplyIntSources( input1, input2 )
tomwalters@0 1226 Source input1, input2 ;
tomwalters@0 1227 {
tomwalters@0 1228 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1229
tomwalters@0 1230 inputs[0] = input1 ;
tomwalters@0 1231 inputs[1] = input2 ;
tomwalters@0 1232
tomwalters@0 1233 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1234
tomwalters@0 1235 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1236 }
tomwalters@0 1237
tomwalters@0 1238 /* VARARGS2 */
tomwalters@0 1239 Source MultiplyIntSourceArray( inputs )
tomwalters@0 1240 Source *inputs ;
tomwalters@0 1241 {
tomwalters@0 1242 int count = 0 ;
tomwalters@0 1243
tomwalters@0 1244 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1245 count++ ;
tomwalters@0 1246
tomwalters@0 1247 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyIntOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1248 }
tomwalters@0 1249
tomwalters@0 1250
tomwalters@0 1251
tomwalters@0 1252 static void DivideIntOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1253 Pointer *state ;
tomwalters@0 1254 ByteCount *bytes ;
tomwalters@0 1255 int *output, *end, *input1, *input2 ;
tomwalters@0 1256 {
tomwalters@0 1257 register int *optr = output ;
tomwalters@0 1258 register int *ipt1 = input1 ;
tomwalters@0 1259 register int *ipt2 = input2 ;
tomwalters@0 1260 register int *eptr = end ;
tomwalters@0 1261
tomwalters@0 1262 if( optr < eptr )
tomwalters@0 1263 do
tomwalters@0 1264 *optr++ = *ipt1++ / *ipt2++ ;
tomwalters@0 1265 while( optr < eptr ) ;
tomwalters@0 1266
tomwalters@0 1267 return ;
tomwalters@0 1268 }
tomwalters@0 1269
tomwalters@0 1270 Source DivideIntSources( input1, input2 )
tomwalters@0 1271 Source input1, input2 ;
tomwalters@0 1272 {
tomwalters@0 1273 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1274
tomwalters@0 1275 inputs[0] = input1 ;
tomwalters@0 1276 inputs[1] = input2 ;
tomwalters@0 1277
tomwalters@0 1278 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1279
tomwalters@0 1280 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideIntOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1281 }
tomwalters@0 1282
tomwalters@0 1283 /* VARARGS2 */
tomwalters@0 1284 Source DivideIntSourceArray( inputs )
tomwalters@0 1285 Source *inputs ;
tomwalters@0 1286 {
tomwalters@0 1287 int count = 0 ;
tomwalters@0 1288
tomwalters@0 1289 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1290 count++ ;
tomwalters@0 1291
tomwalters@0 1292 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideIntOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1293 }
tomwalters@0 1294
tomwalters@0 1295
tomwalters@0 1296
tomwalters@0 1297
tomwalters@0 1298 /* create convertors */
tomwalters@0 1299
tomwalters@0 1300 static void CharIntCallback( state, bytes, buffer )
tomwalters@0 1301 Source state ;
tomwalters@0 1302 ByteCount bytes ;
tomwalters@0 1303 int *buffer ;
tomwalters@0 1304 {
tomwalters@0 1305 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1306 register int *o = buffer ;
tomwalters@0 1307 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1308
tomwalters@0 1309 if( (Pointer) o < e )
tomwalters@0 1310 do
tomwalters@0 1311 *o++ = *i++ ;
tomwalters@0 1312 while( (Pointer) o < e ) ;
tomwalters@0 1313
tomwalters@0 1314 return ;
tomwalters@0 1315 }
tomwalters@0 1316
tomwalters@0 1317 IntSource CharIntSource( source )
tomwalters@0 1318 IntSource source ;
tomwalters@0 1319 {
tomwalters@0 1320 return( stdAutoSource( ( Pointer ) source, CharIntCallback ) ) ;
tomwalters@0 1321 }
tomwalters@0 1322
tomwalters@0 1323
tomwalters@0 1324
tomwalters@0 1325 static void ShortIntCallback( state, bytes, buffer )
tomwalters@0 1326 Source state ;
tomwalters@0 1327 ByteCount bytes ;
tomwalters@0 1328 int *buffer ;
tomwalters@0 1329 {
tomwalters@0 1330 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1331 register int *o = buffer ;
tomwalters@0 1332 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1333
tomwalters@0 1334 if( (Pointer) o < e )
tomwalters@0 1335 do
tomwalters@0 1336 *o++ = *i++ ;
tomwalters@0 1337 while( (Pointer) o < e ) ;
tomwalters@0 1338
tomwalters@0 1339 return ;
tomwalters@0 1340 }
tomwalters@0 1341
tomwalters@0 1342 IntSource ShortIntSource( source )
tomwalters@0 1343 IntSource source ;
tomwalters@0 1344 {
tomwalters@0 1345 return( stdAutoSource( ( Pointer ) source, ShortIntCallback ) ) ;
tomwalters@0 1346 }
tomwalters@0 1347
tomwalters@0 1348
tomwalters@0 1349
tomwalters@0 1350 static void IntIntCallback( state, bytes, buffer )
tomwalters@0 1351 Source state ;
tomwalters@0 1352 ByteCount bytes ;
tomwalters@0 1353 int *buffer ;
tomwalters@0 1354 {
tomwalters@0 1355 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1356 register int *o = buffer ;
tomwalters@0 1357 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1358
tomwalters@0 1359 if( (Pointer) o < e )
tomwalters@0 1360 do
tomwalters@0 1361 *o++ = *i++ ;
tomwalters@0 1362 while( (Pointer) o < e ) ;
tomwalters@0 1363
tomwalters@0 1364 return ;
tomwalters@0 1365 }
tomwalters@0 1366
tomwalters@0 1367 IntSource IntIntSource( source )
tomwalters@0 1368 IntSource source ;
tomwalters@0 1369 {
tomwalters@0 1370 return( stdAutoSource( ( Pointer ) source, IntIntCallback ) ) ;
tomwalters@0 1371 }
tomwalters@0 1372
tomwalters@0 1373
tomwalters@0 1374
tomwalters@0 1375 static void FloatIntCallback( state, bytes, buffer )
tomwalters@0 1376 Source state ;
tomwalters@0 1377 ByteCount bytes ;
tomwalters@0 1378 int *buffer ;
tomwalters@0 1379 {
tomwalters@0 1380 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1381 register int *o = buffer ;
tomwalters@0 1382 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1383
tomwalters@0 1384 if( (Pointer) o < e )
tomwalters@0 1385 do
tomwalters@0 1386 *o++ = *i++ ;
tomwalters@0 1387 while( (Pointer) o < e ) ;
tomwalters@0 1388
tomwalters@0 1389 return ;
tomwalters@0 1390 }
tomwalters@0 1391
tomwalters@0 1392 IntSource FloatIntSource( source )
tomwalters@0 1393 IntSource source ;
tomwalters@0 1394 {
tomwalters@0 1395 return( stdAutoSource( ( Pointer ) source, FloatIntCallback ) ) ;
tomwalters@0 1396 }
tomwalters@0 1397
tomwalters@0 1398
tomwalters@0 1399
tomwalters@0 1400 static void DoubleIntCallback( state, bytes, buffer )
tomwalters@0 1401 Source state ;
tomwalters@0 1402 ByteCount bytes ;
tomwalters@0 1403 int *buffer ;
tomwalters@0 1404 {
tomwalters@0 1405 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( int) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1406 register int *o = buffer ;
tomwalters@0 1407 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1408
tomwalters@0 1409 if( (Pointer) o < e )
tomwalters@0 1410 do
tomwalters@0 1411 *o++ = *i++ ;
tomwalters@0 1412 while( (Pointer) o < e ) ;
tomwalters@0 1413
tomwalters@0 1414 return ;
tomwalters@0 1415 }
tomwalters@0 1416
tomwalters@0 1417 IntSource DoubleIntSource( source )
tomwalters@0 1418 IntSource source ;
tomwalters@0 1419 {
tomwalters@0 1420 return( stdAutoSource( ( Pointer ) source, DoubleIntCallback ) ) ;
tomwalters@0 1421 }
tomwalters@0 1422
tomwalters@0 1423
tomwalters@0 1424
tomwalters@0 1425
tomwalters@0 1426 Source SourceIntSource( source )
tomwalters@0 1427 Source source ;
tomwalters@0 1428 {
tomwalters@0 1429 static Source (*converts[])() = {
tomwalters@0 1430 SourceSource,
tomwalters@0 1431 CharIntSource,
tomwalters@0 1432 ShortIntSource,
tomwalters@0 1433 IntIntSource,
tomwalters@0 1434 FloatIntSource,
tomwalters@0 1435 DoubleIntSource
tomwalters@0 1436 } ;
tomwalters@0 1437
tomwalters@0 1438 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
tomwalters@0 1439 }
tomwalters@0 1440
tomwalters@0 1441
tomwalters@0 1442 static void floatConstantCallback( state, bytes, buffer, end )
tomwalters@0 1443 float *state ;
tomwalters@0 1444 ByteCount *bytes ;
tomwalters@0 1445 float *buffer, *end ;
tomwalters@0 1446 {
tomwalters@0 1447 register float i, *optr = buffer, *eptr = end ;
tomwalters@0 1448
tomwalters@0 1449 i = *state ;
tomwalters@0 1450
tomwalters@0 1451 if( optr < eptr )
tomwalters@0 1452 do
tomwalters@0 1453 *optr++ = i ;
tomwalters@0 1454 while( optr < eptr ) ;
tomwalters@0 1455
tomwalters@0 1456 return ;
tomwalters@0 1457 }
tomwalters@0 1458
tomwalters@0 1459 FloatSource ConstantFloatSource( constant )
tomwalters@0 1460 float constant ;
tomwalters@0 1461 {
tomwalters@0 1462 float * state = ( float * ) stitch_malloc( (unsigned) ( ( sizeof * ( float * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 1463
tomwalters@0 1464 *state = constant ;
tomwalters@0 1465
tomwalters@0 1466 return ( newExternalSource( (Pointer) ( (Pointer) state ), floatConstantCallback, stitch_free, "ops.type constant" ) ) ;
tomwalters@0 1467 }
tomwalters@0 1468
tomwalters@0 1469
tomwalters@0 1470 static void floatIntegralCallback( integral, bytes, buffer, end, input )
tomwalters@0 1471 float *integral ;
tomwalters@0 1472 ByteCount *bytes ;
tomwalters@0 1473 float *buffer, *end, *input ;
tomwalters@0 1474 {
tomwalters@0 1475 register float *iptr = input ;
tomwalters@0 1476 register float *optr = buffer ;
tomwalters@0 1477 register float *eptr = end ;
tomwalters@0 1478
tomwalters@0 1479 if( optr < eptr )
tomwalters@0 1480 do {
tomwalters@0 1481 *optr++ = *integral ;
tomwalters@0 1482 *integral += *iptr++ ;
tomwalters@0 1483 } while( optr < eptr ) ;
tomwalters@0 1484
tomwalters@0 1485 return ;
tomwalters@0 1486 }
tomwalters@0 1487
tomwalters@0 1488 FloatSource IntegrateFloatSource( source, initial )
tomwalters@0 1489 FloatSource source ;
tomwalters@0 1490 float initial ;
tomwalters@0 1491 {
tomwalters@0 1492 float * integral = ( float * ) stitch_malloc( (unsigned) ( ( sizeof * ( float * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 1493
tomwalters@0 1494 *integral = initial ;
tomwalters@0 1495
tomwalters@0 1496 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), floatIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
tomwalters@0 1497 }
tomwalters@0 1498
tomwalters@0 1499 static void floatCallingCallback( function, bytes, buffer, end, input )
tomwalters@0 1500 float (*function)() ;
tomwalters@0 1501 ByteCount *bytes ;
tomwalters@0 1502 float *buffer, *end, *input ;
tomwalters@0 1503 {
tomwalters@0 1504 register float *iptr = input ;
tomwalters@0 1505 register float *optr = buffer ;
tomwalters@0 1506 register float *eptr = end ;
tomwalters@0 1507
tomwalters@0 1508 if( optr < eptr )
tomwalters@0 1509 do
tomwalters@0 1510 *optr++ = function( *iptr++ ) ;
tomwalters@0 1511 while( optr < eptr ) ;
tomwalters@0 1512
tomwalters@0 1513 return ;
tomwalters@0 1514 }
tomwalters@0 1515
tomwalters@0 1516 FloatSource CallingFloatSource( source, function )
tomwalters@0 1517 FloatSource source ;
tomwalters@0 1518 float (*function)() ;
tomwalters@0 1519 {
tomwalters@0 1520 return ( newProcessingSource( (Pointer) ( (Pointer) function ), floatCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
tomwalters@0 1521 }
tomwalters@0 1522
tomwalters@0 1523 /* do operators */
tomwalters@0 1524
tomwalters@0 1525 static void AddFloatOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1526 Pointer *state ;
tomwalters@0 1527 ByteCount *bytes ;
tomwalters@0 1528 float *output, *end, *input1, *input2 ;
tomwalters@0 1529 {
tomwalters@0 1530 register float *optr = output ;
tomwalters@0 1531 register float *ipt1 = input1 ;
tomwalters@0 1532 register float *ipt2 = input2 ;
tomwalters@0 1533 register float *eptr = end ;
tomwalters@0 1534
tomwalters@0 1535 if( optr < eptr )
tomwalters@0 1536 do
tomwalters@0 1537 *optr++ = *ipt1++ + *ipt2++ ;
tomwalters@0 1538 while( optr < eptr ) ;
tomwalters@0 1539
tomwalters@0 1540 return ;
tomwalters@0 1541 }
tomwalters@0 1542
tomwalters@0 1543 Source AddFloatSources( input1, input2 )
tomwalters@0 1544 Source input1, input2 ;
tomwalters@0 1545 {
tomwalters@0 1546 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1547
tomwalters@0 1548 inputs[0] = input1 ;
tomwalters@0 1549 inputs[1] = input2 ;
tomwalters@0 1550
tomwalters@0 1551 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1552
tomwalters@0 1553 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1554 }
tomwalters@0 1555
tomwalters@0 1556 /* VARARGS2 */
tomwalters@0 1557 Source AddFloatSourceArray( inputs )
tomwalters@0 1558 Source *inputs ;
tomwalters@0 1559 {
tomwalters@0 1560 int count = 0 ;
tomwalters@0 1561
tomwalters@0 1562 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1563 count++ ;
tomwalters@0 1564
tomwalters@0 1565 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1566 }
tomwalters@0 1567
tomwalters@0 1568
tomwalters@0 1569
tomwalters@0 1570 static void SubtractFloatOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1571 Pointer *state ;
tomwalters@0 1572 ByteCount *bytes ;
tomwalters@0 1573 float *output, *end, *input1, *input2 ;
tomwalters@0 1574 {
tomwalters@0 1575 register float *optr = output ;
tomwalters@0 1576 register float *ipt1 = input1 ;
tomwalters@0 1577 register float *ipt2 = input2 ;
tomwalters@0 1578 register float *eptr = end ;
tomwalters@0 1579
tomwalters@0 1580 if( optr < eptr )
tomwalters@0 1581 do
tomwalters@0 1582 *optr++ = *ipt1++ - *ipt2++ ;
tomwalters@0 1583 while( optr < eptr ) ;
tomwalters@0 1584
tomwalters@0 1585 return ;
tomwalters@0 1586 }
tomwalters@0 1587
tomwalters@0 1588 Source SubtractFloatSources( input1, input2 )
tomwalters@0 1589 Source input1, input2 ;
tomwalters@0 1590 {
tomwalters@0 1591 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1592
tomwalters@0 1593 inputs[0] = input1 ;
tomwalters@0 1594 inputs[1] = input2 ;
tomwalters@0 1595
tomwalters@0 1596 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1597
tomwalters@0 1598 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1599 }
tomwalters@0 1600
tomwalters@0 1601 /* VARARGS2 */
tomwalters@0 1602 Source SubtractFloatSourceArray( inputs )
tomwalters@0 1603 Source *inputs ;
tomwalters@0 1604 {
tomwalters@0 1605 int count = 0 ;
tomwalters@0 1606
tomwalters@0 1607 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1608 count++ ;
tomwalters@0 1609
tomwalters@0 1610 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1611 }
tomwalters@0 1612
tomwalters@0 1613
tomwalters@0 1614 static void MultiplyFloatOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1615 Pointer *state ;
tomwalters@0 1616 ByteCount *bytes ;
tomwalters@0 1617 float *output, *end, *input1, *input2 ;
tomwalters@0 1618 {
tomwalters@0 1619 register float *optr = output ;
tomwalters@0 1620 register float *ipt1 = input1 ;
tomwalters@0 1621 register float *ipt2 = input2 ;
tomwalters@0 1622 register float *eptr = end ;
tomwalters@0 1623
tomwalters@0 1624 if( optr < eptr )
tomwalters@0 1625 do
tomwalters@0 1626 *optr++ = *ipt1++ * *ipt2++ ;
tomwalters@0 1627 while( optr < eptr ) ;
tomwalters@0 1628
tomwalters@0 1629 return ;
tomwalters@0 1630 }
tomwalters@0 1631
tomwalters@0 1632 Source MultiplyFloatSources( input1, input2 )
tomwalters@0 1633 Source input1, input2 ;
tomwalters@0 1634 {
tomwalters@0 1635 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1636
tomwalters@0 1637 inputs[0] = input1 ;
tomwalters@0 1638 inputs[1] = input2 ;
tomwalters@0 1639
tomwalters@0 1640 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1641
tomwalters@0 1642 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1643 }
tomwalters@0 1644
tomwalters@0 1645 /* VARARGS2 */
tomwalters@0 1646 Source MultiplyFloatSourceArray( inputs )
tomwalters@0 1647 Source *inputs ;
tomwalters@0 1648 {
tomwalters@0 1649 int count = 0 ;
tomwalters@0 1650
tomwalters@0 1651 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1652 count++ ;
tomwalters@0 1653
tomwalters@0 1654 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1655 }
tomwalters@0 1656
tomwalters@0 1657
tomwalters@0 1658
tomwalters@0 1659 static void DivideFloatOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1660 Pointer *state ;
tomwalters@0 1661 ByteCount *bytes ;
tomwalters@0 1662 float *output, *end, *input1, *input2 ;
tomwalters@0 1663 {
tomwalters@0 1664 register float *optr = output ;
tomwalters@0 1665 register float *ipt1 = input1 ;
tomwalters@0 1666 register float *ipt2 = input2 ;
tomwalters@0 1667 register float *eptr = end ;
tomwalters@0 1668
tomwalters@0 1669 if( optr < eptr )
tomwalters@0 1670 do
tomwalters@0 1671 *optr++ = *ipt1++ / *ipt2++ ;
tomwalters@0 1672 while( optr < eptr ) ;
tomwalters@0 1673
tomwalters@0 1674 return ;
tomwalters@0 1675 }
tomwalters@0 1676
tomwalters@0 1677 Source DivideFloatSources( input1, input2 )
tomwalters@0 1678 Source input1, input2 ;
tomwalters@0 1679 {
tomwalters@0 1680 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1681
tomwalters@0 1682 inputs[0] = input1 ;
tomwalters@0 1683 inputs[1] = input2 ;
tomwalters@0 1684
tomwalters@0 1685 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1686
tomwalters@0 1687 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideFloatOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1688 }
tomwalters@0 1689
tomwalters@0 1690 /* VARARGS2 */
tomwalters@0 1691 Source DivideFloatSourceArray( inputs )
tomwalters@0 1692 Source *inputs ;
tomwalters@0 1693 {
tomwalters@0 1694 int count = 0 ;
tomwalters@0 1695
tomwalters@0 1696 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1697 count++ ;
tomwalters@0 1698
tomwalters@0 1699 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideFloatOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1700 }
tomwalters@0 1701
tomwalters@0 1702
tomwalters@0 1703
tomwalters@0 1704
tomwalters@0 1705 /* create convertors */
tomwalters@0 1706
tomwalters@0 1707
tomwalters@0 1708 static void CharFloatCallback( state, bytes, buffer )
tomwalters@0 1709 Source state ;
tomwalters@0 1710 ByteCount bytes ;
tomwalters@0 1711 float *buffer ;
tomwalters@0 1712 {
tomwalters@0 1713 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1714 register float *o = buffer ;
tomwalters@0 1715 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1716
tomwalters@0 1717 if( (Pointer) o < e )
tomwalters@0 1718 do
tomwalters@0 1719 *o++ = *i++ ;
tomwalters@0 1720 while( (Pointer) o < e ) ;
tomwalters@0 1721
tomwalters@0 1722 return ;
tomwalters@0 1723 }
tomwalters@0 1724
tomwalters@0 1725 FloatSource CharFloatSource( source )
tomwalters@0 1726 FloatSource source ;
tomwalters@0 1727 {
tomwalters@0 1728 return( stdAutoSource( ( Pointer ) source, CharFloatCallback ) ) ;
tomwalters@0 1729 }
tomwalters@0 1730
tomwalters@0 1731
tomwalters@0 1732 static void ShortFloatCallback( state, bytes, buffer )
tomwalters@0 1733 Source state ;
tomwalters@0 1734 ByteCount bytes ;
tomwalters@0 1735 float *buffer ;
tomwalters@0 1736 {
tomwalters@0 1737 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1738 register float *o = buffer ;
tomwalters@0 1739 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1740
tomwalters@0 1741 if( (Pointer) o < e )
tomwalters@0 1742 do
tomwalters@0 1743 *o++ = *i++ ;
tomwalters@0 1744 while( (Pointer) o < e ) ;
tomwalters@0 1745
tomwalters@0 1746 return ;
tomwalters@0 1747 }
tomwalters@0 1748
tomwalters@0 1749 FloatSource ShortFloatSource( source )
tomwalters@0 1750 FloatSource source ;
tomwalters@0 1751 {
tomwalters@0 1752 return( stdAutoSource( ( Pointer ) source, ShortFloatCallback ) ) ;
tomwalters@0 1753 }
tomwalters@0 1754
tomwalters@0 1755
tomwalters@0 1756
tomwalters@0 1757 static void IntFloatCallback( state, bytes, buffer )
tomwalters@0 1758 Source state ;
tomwalters@0 1759 ByteCount bytes ;
tomwalters@0 1760 float *buffer ;
tomwalters@0 1761 {
tomwalters@0 1762 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1763 register float *o = buffer ;
tomwalters@0 1764 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1765
tomwalters@0 1766 if( (Pointer) o < e )
tomwalters@0 1767 do
tomwalters@0 1768 *o++ = *i++ ;
tomwalters@0 1769 while( (Pointer) o < e ) ;
tomwalters@0 1770
tomwalters@0 1771 return ;
tomwalters@0 1772 }
tomwalters@0 1773
tomwalters@0 1774 FloatSource IntFloatSource( source )
tomwalters@0 1775 FloatSource source ;
tomwalters@0 1776 {
tomwalters@0 1777 return( stdAutoSource( ( Pointer ) source, IntFloatCallback ) ) ;
tomwalters@0 1778 }
tomwalters@0 1779
tomwalters@0 1780
tomwalters@0 1781
tomwalters@0 1782 static void FloatFloatCallback( state, bytes, buffer )
tomwalters@0 1783 Source state ;
tomwalters@0 1784 ByteCount bytes ;
tomwalters@0 1785 float *buffer ;
tomwalters@0 1786 {
tomwalters@0 1787 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1788 register float *o = buffer ;
tomwalters@0 1789 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1790
tomwalters@0 1791 if( (Pointer) o < e )
tomwalters@0 1792 do
tomwalters@0 1793 *o++ = *i++ ;
tomwalters@0 1794 while( (Pointer) o < e ) ;
tomwalters@0 1795
tomwalters@0 1796 return ;
tomwalters@0 1797 }
tomwalters@0 1798
tomwalters@0 1799 FloatSource FloatFloatSource( source )
tomwalters@0 1800 FloatSource source ;
tomwalters@0 1801 {
tomwalters@0 1802 return( stdAutoSource( ( Pointer ) source, FloatFloatCallback ) ) ;
tomwalters@0 1803 }
tomwalters@0 1804
tomwalters@0 1805
tomwalters@0 1806
tomwalters@0 1807 static void DoubleFloatCallback( state, bytes, buffer )
tomwalters@0 1808 Source state ;
tomwalters@0 1809 ByteCount bytes ;
tomwalters@0 1810 float *buffer ;
tomwalters@0 1811 {
tomwalters@0 1812 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( float) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 1813 register float *o = buffer ;
tomwalters@0 1814 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 1815
tomwalters@0 1816 if( (Pointer) o < e )
tomwalters@0 1817 do
tomwalters@0 1818 *o++ = *i++ ;
tomwalters@0 1819 while( (Pointer) o < e ) ;
tomwalters@0 1820
tomwalters@0 1821 return ;
tomwalters@0 1822 }
tomwalters@0 1823
tomwalters@0 1824 FloatSource DoubleFloatSource( source )
tomwalters@0 1825 FloatSource source ;
tomwalters@0 1826 {
tomwalters@0 1827 return( stdAutoSource( ( Pointer ) source, DoubleFloatCallback ) ) ;
tomwalters@0 1828 }
tomwalters@0 1829
tomwalters@0 1830
tomwalters@0 1831
tomwalters@0 1832
tomwalters@0 1833 Source SourceFloatSource( source )
tomwalters@0 1834 Source source ;
tomwalters@0 1835 {
tomwalters@0 1836 static Source (*converts[])() = {
tomwalters@0 1837 SourceSource,
tomwalters@0 1838 CharFloatSource,
tomwalters@0 1839 ShortFloatSource,
tomwalters@0 1840 IntFloatSource,
tomwalters@0 1841 FloatFloatSource,
tomwalters@0 1842 DoubleFloatSource
tomwalters@0 1843 } ;
tomwalters@0 1844
tomwalters@0 1845 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
tomwalters@0 1846 }
tomwalters@0 1847
tomwalters@0 1848
tomwalters@0 1849
tomwalters@0 1850
tomwalters@0 1851 static void doubleConstantCallback( state, bytes, buffer, end )
tomwalters@0 1852 double *state ;
tomwalters@0 1853 ByteCount *bytes ;
tomwalters@0 1854 double *buffer, *end ;
tomwalters@0 1855 {
tomwalters@0 1856 register double i, *optr = buffer, *eptr = end ;
tomwalters@0 1857
tomwalters@0 1858 i = *state ;
tomwalters@0 1859
tomwalters@0 1860 if( optr < eptr )
tomwalters@0 1861 do
tomwalters@0 1862 *optr++ = i ;
tomwalters@0 1863 while( optr < eptr ) ;
tomwalters@0 1864
tomwalters@0 1865 return ;
tomwalters@0 1866 }
tomwalters@0 1867
tomwalters@0 1868 DoubleSource ConstantDoubleSource( constant )
tomwalters@0 1869 double constant ;
tomwalters@0 1870 {
tomwalters@0 1871 double * state = ( double * ) stitch_malloc( (unsigned) ( ( sizeof * ( double * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 1872
tomwalters@0 1873 *state = constant ;
tomwalters@0 1874
tomwalters@0 1875 return ( newExternalSource( (Pointer) ( (Pointer) state ), doubleConstantCallback, stitch_free, "ops.type constant" ) ) ;
tomwalters@0 1876 }
tomwalters@0 1877
tomwalters@0 1878
tomwalters@0 1879 static void doubleIntegralCallback( integral, bytes, buffer, end, input )
tomwalters@0 1880 double *integral ;
tomwalters@0 1881 ByteCount *bytes ;
tomwalters@0 1882 double *buffer, *end, *input ;
tomwalters@0 1883 {
tomwalters@0 1884 register double *iptr = input ;
tomwalters@0 1885 register double *optr = buffer ;
tomwalters@0 1886 register double *eptr = end ;
tomwalters@0 1887
tomwalters@0 1888 if( optr < eptr )
tomwalters@0 1889 do {
tomwalters@0 1890 *optr++ = *integral ;
tomwalters@0 1891 *integral += *iptr++ ;
tomwalters@0 1892 } while( optr < eptr ) ;
tomwalters@0 1893
tomwalters@0 1894 return ;
tomwalters@0 1895 }
tomwalters@0 1896
tomwalters@0 1897 DoubleSource IntegrateDoubleSource( source, initial )
tomwalters@0 1898 DoubleSource source ;
tomwalters@0 1899 double initial ;
tomwalters@0 1900 {
tomwalters@0 1901 double * integral = ( double * ) stitch_malloc( (unsigned) ( ( sizeof * ( double * ) 0 ) ), stitchStructStr ) ;
tomwalters@0 1902
tomwalters@0 1903 *integral = initial ;
tomwalters@0 1904
tomwalters@0 1905 return ( newProcessingSource( (Pointer) ( (Pointer) integral ), doubleIntegralCallback, stitch_free, source, "ops.type integrating" ) ) ;
tomwalters@0 1906 }
tomwalters@0 1907
tomwalters@0 1908 static void doubleCallingCallback( function, bytes, buffer, end, input )
tomwalters@0 1909 double (*function)() ;
tomwalters@0 1910 ByteCount *bytes ;
tomwalters@0 1911 double *buffer, *end, *input ;
tomwalters@0 1912 {
tomwalters@0 1913 register double *iptr = input ;
tomwalters@0 1914 register double *optr = buffer ;
tomwalters@0 1915 register double *eptr = end ;
tomwalters@0 1916
tomwalters@0 1917 if( optr < eptr )
tomwalters@0 1918 do
tomwalters@0 1919 *optr++ = function( *iptr++ ) ;
tomwalters@0 1920 while( optr < eptr ) ;
tomwalters@0 1921
tomwalters@0 1922 return ;
tomwalters@0 1923 }
tomwalters@0 1924
tomwalters@0 1925 DoubleSource CallingDoubleSource( source, function )
tomwalters@0 1926 DoubleSource source ;
tomwalters@0 1927 double (*function)() ;
tomwalters@0 1928 {
tomwalters@0 1929 return ( newProcessingSource( (Pointer) ( (Pointer) function ), doubleCallingCallback, (void ( * )()) 0, source, "ops.type function" ) ) ;
tomwalters@0 1930 }
tomwalters@0 1931
tomwalters@0 1932 /* do operators */
tomwalters@0 1933
tomwalters@0 1934
tomwalters@0 1935 static void AddDoubleOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1936 Pointer *state ;
tomwalters@0 1937 ByteCount *bytes ;
tomwalters@0 1938 double *output, *end, *input1, *input2 ;
tomwalters@0 1939 {
tomwalters@0 1940 register double *optr = output ;
tomwalters@0 1941 register double *ipt1 = input1 ;
tomwalters@0 1942 register double *ipt2 = input2 ;
tomwalters@0 1943 register double *eptr = end ;
tomwalters@0 1944
tomwalters@0 1945 if( optr < eptr )
tomwalters@0 1946 do
tomwalters@0 1947 *optr++ = *ipt1++ + *ipt2++ ;
tomwalters@0 1948 while( optr < eptr ) ;
tomwalters@0 1949
tomwalters@0 1950 return ;
tomwalters@0 1951 }
tomwalters@0 1952
tomwalters@0 1953 Source AddDoubleSources( input1, input2 )
tomwalters@0 1954 Source input1, input2 ;
tomwalters@0 1955 {
tomwalters@0 1956 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 1957
tomwalters@0 1958 inputs[0] = input1 ;
tomwalters@0 1959 inputs[1] = input2 ;
tomwalters@0 1960
tomwalters@0 1961 inputs[2] = (struct _source *) 0 ;
tomwalters@0 1962
tomwalters@0 1963 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 1964 }
tomwalters@0 1965
tomwalters@0 1966 /* VARARGS2 */
tomwalters@0 1967 Source AddDoubleSourceArray( inputs )
tomwalters@0 1968 Source *inputs ;
tomwalters@0 1969 {
tomwalters@0 1970 int count = 0 ;
tomwalters@0 1971
tomwalters@0 1972 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 1973 count++ ;
tomwalters@0 1974
tomwalters@0 1975 return( newMergingSource( (Pointer) ( (Pointer) 0 ), AddDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 1976 }
tomwalters@0 1977
tomwalters@0 1978
tomwalters@0 1979
tomwalters@0 1980
tomwalters@0 1981 static void SubtractDoubleOp( state, bytes, output, end, input1, input2 )
tomwalters@0 1982 Pointer *state ;
tomwalters@0 1983 ByteCount *bytes ;
tomwalters@0 1984 double *output, *end, *input1, *input2 ;
tomwalters@0 1985 {
tomwalters@0 1986 register double *optr = output ;
tomwalters@0 1987 register double *ipt1 = input1 ;
tomwalters@0 1988 register double *ipt2 = input2 ;
tomwalters@0 1989 register double *eptr = end ;
tomwalters@0 1990
tomwalters@0 1991 if( optr < eptr )
tomwalters@0 1992 do
tomwalters@0 1993 *optr++ = *ipt1++ - *ipt2++ ;
tomwalters@0 1994 while( optr < eptr ) ;
tomwalters@0 1995
tomwalters@0 1996 return ;
tomwalters@0 1997 }
tomwalters@0 1998
tomwalters@0 1999 Source SubtractDoubleSources( input1, input2 )
tomwalters@0 2000 Source input1, input2 ;
tomwalters@0 2001 {
tomwalters@0 2002 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 2003
tomwalters@0 2004 inputs[0] = input1 ;
tomwalters@0 2005 inputs[1] = input2 ;
tomwalters@0 2006
tomwalters@0 2007 inputs[2] = (struct _source *) 0 ;
tomwalters@0 2008
tomwalters@0 2009 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 2010 }
tomwalters@0 2011
tomwalters@0 2012 /* VARARGS2 */
tomwalters@0 2013 Source SubtractDoubleSourceArray( inputs )
tomwalters@0 2014 Source *inputs ;
tomwalters@0 2015 {
tomwalters@0 2016 int count = 0 ;
tomwalters@0 2017
tomwalters@0 2018 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 2019 count++ ;
tomwalters@0 2020
tomwalters@0 2021 return( newMergingSource( (Pointer) ( (Pointer) 0 ), SubtractDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 2022 }
tomwalters@0 2023
tomwalters@0 2024
tomwalters@0 2025
tomwalters@0 2026
tomwalters@0 2027 static void MultiplyDoubleOp( state, bytes, output, end, input1, input2 )
tomwalters@0 2028 Pointer *state ;
tomwalters@0 2029 ByteCount *bytes ;
tomwalters@0 2030 double *output, *end, *input1, *input2 ;
tomwalters@0 2031 {
tomwalters@0 2032 register double *optr = output ;
tomwalters@0 2033 register double *ipt1 = input1 ;
tomwalters@0 2034 register double *ipt2 = input2 ;
tomwalters@0 2035 register double *eptr = end ;
tomwalters@0 2036
tomwalters@0 2037 if( optr < eptr )
tomwalters@0 2038 do
tomwalters@0 2039 *optr++ = *ipt1++ * *ipt2++ ;
tomwalters@0 2040 while( optr < eptr ) ;
tomwalters@0 2041
tomwalters@0 2042 return ;
tomwalters@0 2043 }
tomwalters@0 2044
tomwalters@0 2045 Source MultiplyDoubleSources( input1, input2 )
tomwalters@0 2046 Source input1, input2 ;
tomwalters@0 2047 {
tomwalters@0 2048 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 2049
tomwalters@0 2050 inputs[0] = input1 ;
tomwalters@0 2051 inputs[1] = input2 ;
tomwalters@0 2052
tomwalters@0 2053 inputs[2] = (struct _source *) 0 ;
tomwalters@0 2054
tomwalters@0 2055 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 2056 }
tomwalters@0 2057
tomwalters@0 2058 /* VARARGS2 */
tomwalters@0 2059 Source MultiplyDoubleSourceArray( inputs )
tomwalters@0 2060 Source *inputs ;
tomwalters@0 2061 {
tomwalters@0 2062 int count = 0 ;
tomwalters@0 2063
tomwalters@0 2064 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 2065 count++ ;
tomwalters@0 2066
tomwalters@0 2067 return( newMergingSource( (Pointer) ( (Pointer) 0 ), MultiplyDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 2068 }
tomwalters@0 2069
tomwalters@0 2070
tomwalters@0 2071 static void DivideDoubleOp( state, bytes, output, end, input1, input2 )
tomwalters@0 2072 Pointer *state ;
tomwalters@0 2073 ByteCount *bytes ;
tomwalters@0 2074 double *output, *end, *input1, *input2 ;
tomwalters@0 2075 {
tomwalters@0 2076 register double *optr = output ;
tomwalters@0 2077 register double *ipt1 = input1 ;
tomwalters@0 2078 register double *ipt2 = input2 ;
tomwalters@0 2079 register double *eptr = end ;
tomwalters@0 2080
tomwalters@0 2081 if( optr < eptr )
tomwalters@0 2082 do
tomwalters@0 2083 *optr++ = *ipt1++ / *ipt2++ ;
tomwalters@0 2084 while( optr < eptr ) ;
tomwalters@0 2085
tomwalters@0 2086 return ;
tomwalters@0 2087 }
tomwalters@0 2088
tomwalters@0 2089 Source DivideDoubleSources( input1, input2 )
tomwalters@0 2090 Source input1, input2 ;
tomwalters@0 2091 {
tomwalters@0 2092 Source * inputs = ( Source *) stitch_malloc( (unsigned) ( sizeof ( Source) * (unsigned) ( 3 ) ), "for 2 inputs" ) ;
tomwalters@0 2093
tomwalters@0 2094 inputs[0] = input1 ;
tomwalters@0 2095 inputs[1] = input2 ;
tomwalters@0 2096
tomwalters@0 2097 inputs[2] = (struct _source *) 0 ;
tomwalters@0 2098
tomwalters@0 2099 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideDoubleOp, (void ( * )()) 0, inputs, "binary operator" ) ) ;
tomwalters@0 2100 }
tomwalters@0 2101
tomwalters@0 2102 /* VARARGS2 */
tomwalters@0 2103 Source DivideDoubleSourceArray( inputs )
tomwalters@0 2104 Source *inputs ;
tomwalters@0 2105 {
tomwalters@0 2106 int count = 0 ;
tomwalters@0 2107
tomwalters@0 2108 while( inputs[count] != (struct _source *) 0 )
tomwalters@0 2109 count++ ;
tomwalters@0 2110
tomwalters@0 2111 return( newMergingSource( (Pointer) ( (Pointer) 0 ), DivideDoubleOp, (void ( * )()) 0, inputs, "operator" ) ) ;
tomwalters@0 2112 }
tomwalters@0 2113
tomwalters@0 2114
tomwalters@0 2115
tomwalters@0 2116
tomwalters@0 2117 /* create convertors */
tomwalters@0 2118
tomwalters@0 2119
tomwalters@0 2120 static void CharDoubleCallback( state, bytes, buffer )
tomwalters@0 2121 Source state ;
tomwalters@0 2122 ByteCount bytes ;
tomwalters@0 2123 double *buffer ;
tomwalters@0 2124 {
tomwalters@0 2125 register char *i = ( ( char *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( char *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 2126 register double *o = buffer ;
tomwalters@0 2127 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 2128
tomwalters@0 2129 if( (Pointer) o < e )
tomwalters@0 2130 do
tomwalters@0 2131 *o++ = *i++ ;
tomwalters@0 2132 while( (Pointer) o < e ) ;
tomwalters@0 2133
tomwalters@0 2134 return ;
tomwalters@0 2135 }
tomwalters@0 2136
tomwalters@0 2137 DoubleSource CharDoubleSource( source )
tomwalters@0 2138 DoubleSource source ;
tomwalters@0 2139 {
tomwalters@0 2140 return( stdAutoSource( ( Pointer ) source, CharDoubleCallback ) ) ;
tomwalters@0 2141 }
tomwalters@0 2142
tomwalters@0 2143
tomwalters@0 2144
tomwalters@0 2145
tomwalters@0 2146 static void ShortDoubleCallback( state, bytes, buffer )
tomwalters@0 2147 Source state ;
tomwalters@0 2148 ByteCount bytes ;
tomwalters@0 2149 double *buffer ;
tomwalters@0 2150 {
tomwalters@0 2151 register short *i = ( ( short *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( short *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 2152 register double *o = buffer ;
tomwalters@0 2153 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 2154
tomwalters@0 2155 if( (Pointer) o < e )
tomwalters@0 2156 do
tomwalters@0 2157 *o++ = *i++ ;
tomwalters@0 2158 while( (Pointer) o < e ) ;
tomwalters@0 2159
tomwalters@0 2160 return ;
tomwalters@0 2161 }
tomwalters@0 2162
tomwalters@0 2163 DoubleSource ShortDoubleSource( source )
tomwalters@0 2164 DoubleSource source ;
tomwalters@0 2165 {
tomwalters@0 2166 return( stdAutoSource( ( Pointer ) source, ShortDoubleCallback ) ) ;
tomwalters@0 2167 }
tomwalters@0 2168
tomwalters@0 2169
tomwalters@0 2170
tomwalters@0 2171 static void IntDoubleCallback( state, bytes, buffer )
tomwalters@0 2172 Source state ;
tomwalters@0 2173 ByteCount bytes ;
tomwalters@0 2174 double *buffer ;
tomwalters@0 2175 {
tomwalters@0 2176 register int *i = ( ( int *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( int *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 2177 register double *o = buffer ;
tomwalters@0 2178 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 2179
tomwalters@0 2180 if( (Pointer) o < e )
tomwalters@0 2181 do
tomwalters@0 2182 *o++ = *i++ ;
tomwalters@0 2183 while( (Pointer) o < e ) ;
tomwalters@0 2184
tomwalters@0 2185 return ;
tomwalters@0 2186 }
tomwalters@0 2187
tomwalters@0 2188 DoubleSource IntDoubleSource( source )
tomwalters@0 2189 DoubleSource source ;
tomwalters@0 2190 {
tomwalters@0 2191 return( stdAutoSource( ( Pointer ) source, IntDoubleCallback ) ) ;
tomwalters@0 2192 }
tomwalters@0 2193
tomwalters@0 2194
tomwalters@0 2195
tomwalters@0 2196
tomwalters@0 2197 static void FloatDoubleCallback( state, bytes, buffer )
tomwalters@0 2198 Source state ;
tomwalters@0 2199 ByteCount bytes ;
tomwalters@0 2200 double *buffer ;
tomwalters@0 2201 {
tomwalters@0 2202 register float *i = ( ( float *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( float *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 2203 register double *o = buffer ;
tomwalters@0 2204 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 2205
tomwalters@0 2206 if( (Pointer) o < e )
tomwalters@0 2207 do
tomwalters@0 2208 *o++ = *i++ ;
tomwalters@0 2209 while( (Pointer) o < e ) ;
tomwalters@0 2210
tomwalters@0 2211 return ;
tomwalters@0 2212 }
tomwalters@0 2213
tomwalters@0 2214 DoubleSource FloatDoubleSource( source )
tomwalters@0 2215 DoubleSource source ;
tomwalters@0 2216 {
tomwalters@0 2217 return( stdAutoSource( ( Pointer ) source, FloatDoubleCallback ) ) ;
tomwalters@0 2218 }
tomwalters@0 2219
tomwalters@0 2220
tomwalters@0 2221 static void DoubleDoubleCallback( state, bytes, buffer )
tomwalters@0 2222 Source state ;
tomwalters@0 2223 ByteCount bytes ;
tomwalters@0 2224 double *buffer ;
tomwalters@0 2225 {
tomwalters@0 2226 register double *i = ( ( double *) ( state ->returned = oldPull( state , (ByteCount ) ( ( ( char *) ( ( double *) 0l + ( ( ( bytes ) >> ( sizeof( double) >> 1 ) ) ) ) - ( char *) 0l ) ) ) ) ) ;
tomwalters@0 2227 register double *o = buffer ;
tomwalters@0 2228 register Pointer e = (Pointer) buffer + bytes ;
tomwalters@0 2229
tomwalters@0 2230 if( (Pointer) o < e )
tomwalters@0 2231 do
tomwalters@0 2232 *o++ = *i++ ;
tomwalters@0 2233 while( (Pointer) o < e ) ;
tomwalters@0 2234
tomwalters@0 2235 return ;
tomwalters@0 2236 }
tomwalters@0 2237
tomwalters@0 2238 DoubleSource DoubleDoubleSource( source )
tomwalters@0 2239 DoubleSource source ;
tomwalters@0 2240 {
tomwalters@0 2241 return( stdAutoSource( ( Pointer ) source, DoubleDoubleCallback ) ) ;
tomwalters@0 2242 }
tomwalters@0 2243
tomwalters@0 2244
tomwalters@0 2245
tomwalters@0 2246
tomwalters@0 2247 Source SourceDoubleSource( source )
tomwalters@0 2248 Source source ;
tomwalters@0 2249 {
tomwalters@0 2250 static Source (*converts[])() = {
tomwalters@0 2251 SourceSource,
tomwalters@0 2252 CharDoubleSource,
tomwalters@0 2253 ShortDoubleSource,
tomwalters@0 2254 IntDoubleSource,
tomwalters@0 2255 FloatDoubleSource,
tomwalters@0 2256 DoubleDoubleSource
tomwalters@0 2257 } ;
tomwalters@0 2258
tomwalters@0 2259 return ( converts[ typeEntryNumber( sourceType( (struct _source *) source ) ) ]( source ) ) ;
tomwalters@0 2260 }
tomwalters@0 2261
tomwalters@0 2262
tomwalters@0 2263
tomwalters@0 2264