Changeset 586

Show
Ignore:
Timestamp:
08/19/08 15:42:32
Author:
ben
Message:

Fix Rachel's untested change. Fix caster to work with modern compilers.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openpgpsdk/trunk/include/openpgpsdk/util.h

    r585 r586  
    5555 * This is a copy of the macro defined in openssl/asn1.h. 
    5656 */ 
    57 #ifndef CHECKED_PTR_OF(type, p) 
    58 #define CHECKED_PTR_OF(type, p) \ 
    59     ((void*) (1 ? p : (type *)0))  
     57#ifndef CHECKED_PTR_OF 
     58#define CHECKED_PTR_OF(type, p) ((void*) (1 ? p : (type *)0)) 
    6059#endif  
     60#define CHECKED_INSTANCE_OF(type, p) (1 ? p : (type)0)  
    6161#define DECONST(type,p) ((type *)CHECKED_PTR_OF(const type, p)) 
    6262 
  • openpgpsdk/trunk/util/caster.pl

    r191 r586  
    3737    print O "/* (line $lineno) $line */\n"; 
    3838    print O "$from;\n"; 
     39 
    3940    print O "#define $tname("; 
    4041    print_list($targs,1,1); 
    41     print O ") (($ttype(*)("; 
    42     print_list($targs,0); 
    43     print O "))ops_fcast($fname))("; 
    44     print_list($fargs,1); 
     42    print O ") $fname("; 
     43    print_checked_list($targs, $fargs); 
    4544    print O ")\n"; 
    4645 
     
    9291    } 
    9392} 
     93 
     94sub print_checked_list { 
     95    my $types=shift; 
     96    my $args=shift; 
     97 
     98    for(my $n=0 ; $n <= $#$types ; ++$n) { 
     99        print O ',' if $n; 
     100        my $type=$types->[$n]->[0]; 
     101        $type =~ s/^\+//; 
     102        my $arg=$args->[$n]->[1]; 
     103        $arg =~ s/^\+//; 
     104        print O "CHECKED_INSTANCE_OF($type, $arg)"; 
     105    } 
     106}