This file is indexed.

/usr/include/openturns/WrapperMacros.h is in libopenturns-dev 1.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
/*                                               -*- C -*- */
/**
 * @file  WrapperMacros.h
 * @brief This file provides macros to ease wrapper writing
 *
 * Copyright (C) 2005-2013 EDF
 *
 * Permission to copy, use, modify, sell and distribute this software
 * is granted provided this copyright notice appears in all copies.
 * This software is provided "as is" without express or implied
 * warranty, and with no claim as to its suitability for any purpose.
 *
 *
 * @author dutka
 * @date   2007-11-06 19:01:18 +0100 (mar, 06 nov 2007)
 */

#ifndef OPENTURNS_WRAPPERMACROS_H
#define OPENTURNS_WRAPPERMACROS_H

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "OTdebug.h"

#ifdef HAVE_PTHREAD_H
#include "OTthread.hxx"
#include <signal.h>
#define CHECK_MULTITHREAD
#else
#define CHECK_MULTITHREAD const char _Multithread_NOT_available_[-1];
#endif

#include "WrapperInterface.h"

/***************************************************************************************
 *                                                                                     *
 *                               Various macros                                        *
 *                                                                                     *
 ***************************************************************************************/

#ifdef __cplusplus
# define C_DECL extern "C"
#else
# define C_DECL extern
#endif


#ifdef DEBUG
#define dbg_printMessage( fname, msg )                        printMessage((fname), (msg))
#define dbg_printEntrance( fname )                            printEntrance((fname))
#define dbg_printExit( fname )                                printExit((fname))
#define dbg_printState( fname, state )                        printState((fname), (state))
#define dbg_printWrapperExchangedData( fname, exchangedData ) printWrapperExchangedData((fname), (exchangedData))
#define dbg_printWrapperInformation( fname, info )            printWrapperInformation((fname), (info))
#define dbg_printPoint( fname, point )                        printPoint((fname), (point))
#define dbg_printSample( fname, sample )                      printSample((fname), (sample))
#define dbg_printMatrix( fname, matrix )                      printMatrix((fname), (matrix))
#define dbg_printTensor( fname, tensor )                      printTensor((fname), (tensor))
#else
#define dbg_printMessage( fname, msg )
#define dbg_printEntrance( fname )
#define dbg_printExit( fname )
#define dbg_printState( fname, state )
#define dbg_printWrapperExchangedData( fname, exchangedData )
#define dbg_printWrapperInformation( fname, info )
#define dbg_printPoint( fname, point )
#define dbg_printSample( fname, sample )
#define dbg_printMatrix( fname, matrix )
#define dbg_printTensor( fname, tensor )
#endif

#if defined(__cplusplus)
#define CAST( type, arg ) reinterpret_cast< type >(arg)
#else
#define CAST( type, arg ) ((type) (arg))
#endif /* defined(__cplusplus) */


#define FIND_EXCHANGED_DATA_IN_INTERNAL_STATE( pointer ) FIND_EXCHANGED_DATA_IN_INTERNAL_STATE_DEF( pointer )
#define FIND_EXCHANGED_DATA_IN_INTERNAL_STATE_DEF( pointer ) CAST(struct WrapperExchangedData *, pointer)

#define SET_INFORMATION_FROM_EXCHANGED_DATA( p_exchangedData )          \
  do {                                                                  \
    p_info->inSize_  = getNumberOfVariables( (p_exchangedData), WRAPPER_IN); \
    p_info->outSize_ = getNumberOfVariables( (p_exchangedData), WRAPPER_OUT); \
  } while (0);

#define GET_EXCHANGED_DATA_FROM( pointer ) GET_EXCHANGED_DATA_FROM_DEF( pointer )
#define GET_EXCHANGED_DATA_FROM_DEF( pointer )                          \
  struct WrapperExchangedData * p_exchangedData = FIND_EXCHANGED_DATA_IN_INTERNAL_STATE( pointer );

#define COPY_EXCHANGED_DATA_TO( pointer ) COPY_EXCHANGED_DATA_TO_DEF( pointer )
#define COPY_EXCHANGED_DATA_TO_DEF( pointer )                           \
  copyWrapperExchangedData( CAST(struct WrapperExchangedData **, pointer) \
                            , p_exchangedData                           \
                            , p_error);

#define DELETE_EXCHANGED_DATA_FROM( pointer ) DELETE_EXCHANGED_DATA_FROM_DEF( pointer )
#define DELETE_EXCHANGED_DATA_FROM_DEF( pointer )                       \
  freeWrapperExchangedData( CAST(struct WrapperExchangedData *, pointer) );

#define CHECK_WRAPPER_MODE( mode ) if ( p_exchangedData->parameters_->mode_ != (mode) )  { \
    printMessage( FUNCTIONNAME, "Incorrrect mode for wrapper" );        \
    return WRAPPER_USAGE_ERROR;                                         \
  }
#define CHECK_WRAPPER_IN( mode )   if ( p_exchangedData->parameters_->in_   != (mode) )  { \
    printMessage( FUNCTIONNAME, "Incorrrect 'in' parameter for wrapper" ); \
    return WRAPPER_USAGE_ERROR;                                         \
  }
#define CHECK_WRAPPER_OUT( mode )  if ( p_exchangedData->parameters_->out_  != (mode) )  { \
    printMessage( FUNCTIONNAME, "Incorrrect 'out' parameter for wrapper" ); \
    return WRAPPER_USAGE_ERROR;                                         \
  }

#define PRINT(...) printUserMessage( FUNCTIONNAME, __VA_ARGS__ );
#define SETERROR(...) setError( p_error, __VA_ARGS__ );
#define MIN(a, b) ( ( (a) < (b) ) ? (a) : (b) )
#define MAX(a, b) ( ( (a) > (b) ) ? (a) : (b) )

#define DEF_STRUCT_ARGUMENTS                            \
  struct AdapterArguments {                             \
    void * p_state;                                     \
    struct WrapperExchangedData * p_exchangedData;      \
    void * p_error;                                     \
    const struct sample * inSample;                     \
    struct sample * outSample;                          \
    long begin;                                         \
    long end;                                           \
    long threadId;                                      \
    enum WrapperErrorCode rc;                           \
    volatile long * p_errorEncountered;                 \
  };



#define INPOINT_ARRAY  (inPoint->data_)
#define OUTPOINT_ARRAY (outPoint->data_)

#define INPOINT_SIZE  (inPoint->size_)
#define OUTPOINT_SIZE (outPoint->size_)

#define INPOINT_COORD( i )  (inPoint->data_[  (i) ])
#define OUTPOINT_COORD( i ) (outPoint->data_[ (i) ])

#define OUTMATRIX_ARRAY (outMatrix->data_)
#define OUTMATRIX_ROWS  (outMatrix->nbrows_)
#define OUTMATRIX_COLS  (outMatrix->nbcols_)
#define OUTMATRIX_COORD( i, j ) (outMatrix->data_[ (i) + (j) * outMatrix->nbrows_ ])

#define OUTTENSOR_ARRAY  (outTensor->data_)
#define OUTTENSOR_ROWS   (outTensor->nbrows_)
#define OUTTENSOR_COLS   (outTensor->nbcols_)
#define OUTTENSOR_SHEETS (outTensor->nbsheets_)
#define OUTTENSOR_COORD( i, j, k ) (outTensor->data_[ (i) + (j) * outMatrix->nbrows_ + (k) *  outMatrix->nbrows_ * outMatrix->nbcols_ ])

#define INSAMPLE_ARRAY  (inSample->data_)
#define OUTSAMPLE_ARRAY (outSample->data_)

#define INSAMPLE_SIZE  (inSample->size_)
#define OUTSAMPLE_SIZE (outSample->size_)

#define INSAMPLE_VALUES( i )  (&(inSample->data_[  (i) * inSample->size_  ]))
#define OUTSAMPLE_VALUES( i ) (&(outSample->data_[ (i) * outSample->size_ ]))

#define INTIMESERIES_ARRAY  (inTimeSeries->data_)
#define OUTTIMESERIES_ARRAY (outTimeSeries->data_)

#define INTIMESERIES_TIME( i )  (inTimeSeries->data_[  (i) * inTimeSeries->size_  ])
#define OUTTIMESERIES_TIME( i ) (outTimeSeries->data_[ (i) * outTimeSeries->size_ ])

#define INTIMESERIES_VALUES( i )  (&(inTimeSeries->data_[  (i) * inTimeSeries->size_  + 1 ]))
#define OUTTIMESERIES_VALUES( i ) (&(outTimeSeries->data_[ (i) * outTimeSeries->size_ + 1 ]))

#define INTIMESERIES_SIZE  (inTimeSeries->size_)
#define OUTTIMESERIES_SIZE (outTimeSeries->size_)

#define INTIMESERIES_DIMENSION  (inTimeSeries->dimension_)
#define OUTTIMESERIES_DIMENSION (outTimeSeries->dimension_)


/***************************************************************************************
 *                                                                                     *
 *                               Function macros                                       *
 *                                                                                     *
 ***************************************************************************************/

#define BIND_METHODS_FUNCTION               __wrapper_bind_methods
#define BIND_METHODS_FUNCTION_NAME         "__wrapper_bind_methods"
#define BIND_METHODS_FUNCTION_HIDDEN        __wrapper_bind_methods_hidden
#define BIND_METHODS_FUNCTION_HIDDEN_NAME  "__wrapper_bind_methods_hidden"

#define BIND_METHODS_FUNCTION_DEF                                       \
  C_DECL                                                                \
  RETURNCODE BIND_METHODS_FUNCTION ( METHODS methods[] )                \
  {                                                                     \
    RETURNCODE BIND_METHODS_FUNCTION_HIDDEN ( METHODS methods[] );      \
    return BIND_METHODS_FUNCTION_HIDDEN( methods );                     \
  }

#define WRAPPER_BEGIN                           \
  BIND_METHODS_FUNCTION_DEF

#define WRAPPER_END                             \
  /* Nothing to do */


#define FUNC_INFO( name , code )     FUNC_INFO_DEF( name, code )
#define FUNC_INFO_DEF( name , code )                                    \
  C_DECL                                                                \
  RETURNCODE func_getInfo_ ## name (STATE p_state,                      \
                                    INFORMATION p_info,                 \
                                    EXCHANGEDDATA p_exchangedData,      \
                                    ERROR p_error)                      \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "func_getInfo_" #name ;          \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printState(FUNCTIONNAME, p_state);                              \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printWrapperInformation(FUNCTIONNAME, p_info);                  \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define FUNC_CREATESTATE( name , code )     FUNC_CREATESTATE_DEF( name, code )
#define FUNC_CREATESTATE_DEF( name , code )                             \
  C_DECL                                                                \
  RETURNCODE func_createState_ ## name (NEW_STATE p_p_state,            \
                                        EXCHANGEDDATA p_exchangedData,  \
                                        ERROR p_error)                  \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "func_createState_" #name ;      \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printWrapperExchangedData(FUNCTIONNAME, p_exchangedData);       \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printState(FUNCTIONNAME, *p_p_state);                           \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define FUNC_DELETESTATE( name , code )     FUNC_DELETESTATE_DEF( name, code )
#define FUNC_DELETESTATE_DEF( name , code )                             \
  C_DECL                                                                \
  RETURNCODE func_deleteState_ ## name (STATE p_state,                  \
                                        EXCHANGEDDATA p_exchangedData,  \
                                        ERROR p_error)                  \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "func_deleteState_" #name ;      \
    dbg_printEntrance(FUNCTIONNAME);                                    \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printState(FUNCTIONNAME, p_state);                              \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define FUNC_INIT( name , code )     FUNC_INIT_DEF( name, code )
#define FUNC_INIT_DEF( name , code )                            \
  C_DECL                                                        \
  RETURNCODE func_init_ ## name (STATE p_state,                 \
                                 EXCHANGEDDATA p_exchangedData, \
                                 ERROR p_error)                 \
  {                                                             \
    const char FUNCTIONNAME[] UNUSED = "func_init_" #name ;     \
    dbg_printEntrance(FUNCTIONNAME);                            \
    dbg_printState(FUNCTIONNAME, p_state);                      \
                                                                \
    code ;                                                      \
                                                                \
    dbg_printExit(FUNCTIONNAME);                                \
                                                                \
    return WRAPPER_OK;                                          \
  }

/* If prefix is NULL (= 0) then get user prefix either in wrapper description file or in resource map */
#define FUNC_EXEC_BODY_CALLING_COMMAND_IN_TEMP_DIR( prefix ) FUNC_EXEC_BODY_CALLING_COMMAND_IN_TEMP_DIR_DEF( prefix )
#define FUNC_EXEC_BODY_CALLING_COMMAND_IN_TEMP_DIR_DEF( prefix )        \
  {                                                                     \
    long rc = 0;                                                        \
    char * temporaryDirectory = 0;                                      \
    char * cmd = 0;                                                     \
    char * currentWorkingDirectory = 0;                                 \
                                                                        \
    /* We save the current working directory for a future come back */  \
    currentWorkingDirectory = getCurrentWorkingDirectory( p_error );    \
    if (currentWorkingDirectory == NULL) return WRAPPER_EXECUTION_ERROR; \
                                                                        \
    /* We build a temporary directory in which we will work */          \
    temporaryDirectory = createTemporaryDirectory( (prefix) ? (prefix) : getUserPrefix(p_exchangedData), \
                                                   p_exchangedData, p_error ); \
    if (temporaryDirectory == NULL) return WRAPPER_EXECUTION_ERROR;     \
                                                                        \
    /* We create the input files for the external code in the temporary directory */ \
    if (createInputFiles(temporaryDirectory, p_exchangedData, inPoint, p_error )) \
      return WRAPPER_EXECUTION_ERROR;                                   \
                                                                        \
    /* The real computation is here */                                  \
    rc = runInsulatedCommand(temporaryDirectory, p_exchangedData, inPoint, p_error ); \
                                                                        \
    /* Read the output values */                                        \
    if ( rc == 0 )                                                      \
      if (readOutputFiles(temporaryDirectory, p_exchangedData, outPoint, p_error )) { \
        const char * msg = getError( p_error );                         \
        setError( p_error, "Can't read output files. Reason: %s", msg ); \
        free( (void *) msg );                                           \
        return WRAPPER_EXECUTION_ERROR;                                 \
      }                                                                 \
                                                                        \
    /* We kill the temporary directory */                               \
    deleteTemporaryDirectory(temporaryDirectory, rc, p_error );         \
                                                                        \
    free( currentWorkingDirectory );                                    \
                                                                        \
    if ( rc != 0 ) {                                                    \
      const char * msg = getError( p_error );                           \
      setError( p_error, "Code returned error %d. Reason: %s", rc, msg ); \
      free( (void *) msg );                                             \
      return WRAPPER_EXECUTION_ERROR;                                   \
    }                                                                   \
  }


#define FUNC_EXEC( name , code )     FUNC_EXEC_DEF( name, code )
#define FUNC_EXEC_DEF( name , code )                            \
  C_DECL                                                        \
  RETURNCODE func_exec_ ## name (STATE p_state,                 \
                                 INPOINT inPoint,               \
                                 OUTPOINT outPoint,             \
                                 EXCHANGEDDATA p_exchangedData, \
                                 ERROR p_error)                 \
  {                                                             \
    const char FUNCTIONNAME[] UNUSED = "func_exec_" #name ;     \
    dbg_printEntrance(FUNCTIONNAME);                            \
    dbg_printState(FUNCTIONNAME, p_state);                      \
    dbg_printPoint(FUNCTIONNAME, inPoint);                      \
                                                                \
    code ;                                                      \
                                                                \
    dbg_printPoint(FUNCTIONNAME, outPoint);                     \
    dbg_printExit(FUNCTIONNAME);                                \
                                                                \
    return WRAPPER_OK;                                          \
  }


#define FUNC_EXEC_SAMPLE( name , code )     FUNC_EXEC_SAMPLE_DEF( name, code )
#define FUNC_EXEC_SAMPLE_DEF( name , code )                             \
  C_DECL                                                                \
  RETURNCODE func_exec_sample_ ## name (STATE p_state,                  \
                                        INSAMPLE inSample,              \
                                        OUTSAMPLE outSample,            \
                                        EXCHANGEDDATA p_exchangedData,  \
                                        ERROR p_error)                  \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "func_exec_sample_" #name ;      \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printState(FUNCTIONNAME, p_state);                              \
    dbg_printSample(FUNCTIONNAME, inSample);                            \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printSample(FUNCTIONNAME, outSample);                           \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }


#define FUNC_EXEC_TIMESERIES( name , code )     FUNC_EXEC_TIMESERIES_DEF( name, code )
#define FUNC_EXEC_TIMESERIES_DEF( name , code )                         \
  C_DECL                                                                \
  RETURNCODE func_exec_timeseries_ ## name (STATE p_state,              \
                                            INTIMESERIES inTimeSeries,  \
                                            OUTTIMESERIES outTimeSeries, \
                                            EXCHANGEDDATA p_exchangedData, \
                                            ERROR p_error)              \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "func_exec_timeseries_" #name ;  \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printState(FUNCTIONNAME, p_state);                              \
    dbg_printTimeseries(FUNCTIONNAME, inTimeSeries);                    \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printTimeseries(FUNCTIONNAME, outTimeSeries);                   \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }


#define FUNC_FINALIZE( name , code )     FUNC_FINALIZE_DEF( name, code )
#define FUNC_FINALIZE_DEF( name , code )                                \
  C_DECL                                                                \
  RETURNCODE func_finalize_ ## name (STATE p_state,                     \
                                     EXCHANGEDDATA p_exchangedData,     \
                                     ERROR p_error)                     \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "func_finalize_" #name ;         \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printState(FUNCTIONNAME, p_state);                              \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }





/***************************************************************************************
 *                                                                                     *
 *                               Gradient macros                                       *
 *                                                                                     *
 **************************************************************************************/


#define GRAD_INFO( name , code )     GRAD_INFO_DEF( name, code )
#define GRAD_INFO_DEF( name , code )                                    \
  C_DECL                                                                \
  RETURNCODE grad_getInfo_ ## name (STATE p_state,                      \
                                    INFORMATION p_info,                 \
                                    EXCHANGEDDATA p_exchangedData,      \
                                    ERROR p_error)                      \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "grad_getInfo_" #name ;          \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printState(FUNCTIONNAME, p_state);                              \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define GRAD_CREATESTATE( name , code )     GRAD_CREATESTATE_DEF( name, code )
#define GRAD_CREATESTATE_DEF( name , code )                             \
  C_DECL                                                                \
  RETURNCODE grad_createState_ ## name (NEW_STATE p_p_state,            \
                                        EXCHANGEDDATA p_exchangedData,  \
                                        ERROR p_error)                  \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "grad_createState_" #name ;      \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printWrapperExchangedData(FUNCTIONNAME, p_exchangedData);       \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printState(FUNCTIONNAME, *p_p_state);                           \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define GRAD_DELETESTATE( name , code )     GRAD_DELETESTATE_DEF( name, code )
#define GRAD_DELETESTATE_DEF( name , code )                             \
  C_DECL                                                                \
  RETURNCODE grad_deleteState_ ## name (STATE p_state,                  \
                                        EXCHANGEDDATA p_exchangedData,  \
                                        ERROR p_error)                  \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "grad_deleteState_" #name ;      \
    dbg_printEntrance(FUNCTIONNAME);                                    \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printState(FUNCTIONNAME, p_state);                              \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define GRAD_INIT( name , code )     GRAD_INIT_DEF( name, code )
#define GRAD_INIT_DEF( name , code )                            \
  C_DECL                                                        \
  RETURNCODE grad_init_ ## name (STATE p_state,                 \
                                 EXCHANGEDDATA p_exchangedData, \
                                 ERROR p_error)                 \
  {                                                             \
    const char FUNCTIONNAME[] UNUSED = "grad_init_" #name ;     \
    dbg_printEntrance(FUNCTIONNAME);                            \
    dbg_printState(FUNCTIONNAME, p_state);                      \
                                                                \
    code ;                                                      \
                                                                \
    dbg_printExit(FUNCTIONNAME);                                \
                                                                \
    return WRAPPER_OK;                                          \
  }

#define GRAD_EXEC( name , code )     GRAD_EXEC_DEF( name, code )
#define GRAD_EXEC_DEF( name , code )                            \
  C_DECL                                                        \
  RETURNCODE grad_exec_ ## name (STATE p_state,                 \
                                 INPOINT inPoint,               \
                                 OUTMATRIX outMatrix,           \
                                 EXCHANGEDDATA p_exchangedData, \
                                 ERROR p_error)                 \
  {                                                             \
    const char FUNCTIONNAME[] UNUSED = "grad_exec_" #name ;     \
    dbg_printEntrance(FUNCTIONNAME);                            \
    dbg_printState(FUNCTIONNAME, p_state);                      \
    dbg_printPoint(FUNCTIONNAME, inPoint);                      \
                                                                \
    code ;                                                      \
                                                                \
    dbg_printMatrix(FUNCTIONNAME, outMatrix);                   \
    dbg_printExit(FUNCTIONNAME);                                \
                                                                \
    return WRAPPER_OK;                                          \
  }

#define GRAD_FINALIZE( name , code )     GRAD_FINALIZE_DEF( name, code )
#define GRAD_FINALIZE_DEF( name , code )                                \
  C_DECL                                                                \
  RETURNCODE grad_finalize_ ## name (STATE p_state,                     \
                                     EXCHANGEDDATA p_exchangedData,     \
                                     ERROR p_error)                     \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "grad_finalize_" #name ;         \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printState(FUNCTIONNAME, p_state);                              \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }




/***************************************************************************************
 *                                                                                     *
 *                               Hessian macros                                        *
 *                                                                                     *
 **************************************************************************************/


#define HESS_INFO( name , code )     HESS_INFO_DEF( name, code )
#define HESS_INFO_DEF( name , code )                                    \
  C_DECL                                                                \
  RETURNCODE hess_getInfo_ ## name (STATE p_state,                      \
                                    INFORMATION p_info,                 \
                                    EXCHANGEDDATA p_exchangedData,      \
                                    ERROR p_error)                      \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "hess_getInfo_" #name ;          \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printState(FUNCTIONNAME, p_state);                              \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define HESS_CREATESTATE( name , code )     HESS_CREATESTATE_DEF( name, code )
#define HESS_CREATESTATE_DEF( name , code )                             \
  C_DECL                                                                \
  RETURNCODE hess_createState_ ## name (NEW_STATE p_p_state,            \
                                        EXCHANGEDDATA p_exchangedData,  \
                                        ERROR p_error)                  \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "hess_createState_" #name ;      \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printWrapperExchangedData(FUNCTIONNAME, p_exchangedData);       \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printState(FUNCTIONNAME, *p_p_state);                           \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define HESS_DELETESTATE( name , code )     HESS_DELETESTATE_DEF( name, code )
#define HESS_DELETESTATE_DEF( name , code )                             \
  C_DECL                                                                \
  RETURNCODE hess_deleteState_ ## name (STATE p_state,                  \
                                        EXCHANGEDDATA p_exchangedData,  \
                                        ERROR p_error)                  \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "hess_deleteState_" #name ;      \
    dbg_printEntrance(FUNCTIONNAME);                                    \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printState(FUNCTIONNAME, p_state);                              \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }

#define HESS_INIT( name , code )     HESS_INIT_DEF( name, code )
#define HESS_INIT_DEF( name , code )                            \
  C_DECL                                                        \
  RETURNCODE hess_init_ ## name (STATE p_state,                 \
                                 EXCHANGEDDATA p_exchangedData, \
                                 ERROR p_error)                 \
  {                                                             \
    const char FUNCTIONNAME[] UNUSED = "hess_init_" #name ;     \
    dbg_printEntrance(FUNCTIONNAME);                            \
    dbg_printState(FUNCTIONNAME, p_state);                      \
                                                                \
    code ;                                                      \
                                                                \
    dbg_printExit(FUNCTIONNAME);                                \
                                                                \
    return WRAPPER_OK;                                          \
  }

#define HESS_EXEC( name , code )     HESS_EXEC_DEF( name, code )
#define HESS_EXEC_DEF( name , code )                            \
  C_DECL                                                        \
  RETURNCODE hess_exec_ ## name (STATE p_state,                 \
                                 INPOINT inPoint,               \
                                 OUTTENSOR outTensor,           \
                                 EXCHANGEDDATA p_exchangedData, \
                                 ERROR p_error)                 \
  {                                                             \
    const char FUNCTIONNAME[] UNUSED = "hess_exec_" #name ;     \
    dbg_printEntrance(FUNCTIONNAME);                            \
    dbg_printState(FUNCTIONNAME, p_state);                      \
    dbg_printPoint(FUNCTIONNAME, inPoint);                      \
                                                                \
    code ;                                                      \
                                                                \
    dbg_printTensor(FUNCTIONNAME, outTensor);                   \
    dbg_printExit(FUNCTIONNAME);                                \
                                                                \
    return WRAPPER_OK;                                          \
  }

#define HESS_FINALIZE( name , code )     HESS_FINALIZE_DEF( name, code )
#define HESS_FINALIZE_DEF( name , code )                                \
  C_DECL                                                                \
  RETURNCODE hess_finalize_ ## name (STATE p_state,                     \
                                     EXCHANGEDDATA p_exchangedData,     \
                                     ERROR p_error)                     \
  {                                                                     \
    const char FUNCTIONNAME[] UNUSED = "hess_finalize_" #name ;         \
    dbg_printEntrance(FUNCTIONNAME);                                    \
    dbg_printState(FUNCTIONNAME, p_state);                              \
                                                                        \
    code ;                                                              \
                                                                        \
    dbg_printExit(FUNCTIONNAME);                                        \
                                                                        \
    return WRAPPER_OK;                                                  \
  }


#endif /* OPENTURNS_WRAPPERMACROS_H */