Ticket #551: nci_V_fix.patch

File nci_V_fix.patch, 5.7 KB (added by cotto, 13 years ago)

fix NCI calls with V in their signatures

  • src/nci_test.c

     
    104104PARROT_EXPORT void   nci_vpii(Outer *, int, int); 
    105105PARROT_EXPORT void   nci_vv(void); 
    106106PARROT_EXPORT void   nci_vVi(Opaque**, int); 
    107 PARROT_EXPORT void   nci_vp(Opaque*); 
     107PARROT_EXPORT void   nci_vp(Opaque**); 
    108108PARROT_EXPORT char * nci_ttt(char *, char *); 
    109109PARROT_EXPORT void   nci_vfff(float, float, float); 
    110110PARROT_EXPORT void   nci_vV(const char **); 
     
    10871087/* 
    10881088 
    10891089=item C<PARROT_EXPORT int 
    1090 nci_vp(Opaque*)> 
     1090nci_vp(Opaque**)> 
    10911091 
    10921092Test that a previously generated opaque struct gets passed back 
    10931093to an NCI function correctly. 
     
    10971097*/ 
    10981098 
    10991099PARROT_EXPORT void 
    1100 nci_vp(Opaque *inOpaque) 
     1100nci_vp(Opaque **inOpaque) 
    11011101{ 
    1102     if (inOpaque) 
    1103         printf("got %d\n", inOpaque->x); 
     1102    if (*inOpaque) 
     1103        printf("got %d\n", (*inOpaque)->x); 
    11041104    else 
    11051105        printf("got null"); 
    11061106} 
  • src/pmc/pointer.pmc

     
    2323#include "parrot/parrot.h" 
    2424 
    2525pmclass Pointer need_ext { 
    26     ATTR void * mark_function; 
    27     ATTR void * pointer; 
     26    ATTR void  * mark_function; 
     27    ATTR void ** pointer; 
    2828 
    2929/* 
    3030 
     
    6969    VTABLE void mark() { 
    7070        void (*mark_function)(Interp *, void *) = 
    7171            (void (*)(Interp *, void *))D2FPTR(PARROT_POINTER(SELF)->mark_function); 
    72         void * data = PARROT_POINTER(SELF)->pointer; 
     72        void * data = *PARROT_POINTER(SELF)->pointer; 
    7373        if (data && mark_function) 
    7474            (*mark_function)(INTERP, data); 
    7575    } 
     
    102102*/ 
    103103 
    104104    VTABLE void set_pointer(void *ptr) { 
    105         PARROT_POINTER(SELF)->pointer = ptr; 
     105        *PARROT_POINTER(SELF)->pointer = ptr; 
    106106    } 
    107107 
    108108/* 
     
    116116*/ 
    117117 
    118118    VTABLE void *get_pointer() { 
    119         return PARROT_POINTER(SELF)->pointer; 
     119        return &(PARROT_POINTER(SELF)->pointer); 
    120120    } 
    121121 
    122122/* 
     
    130130*/ 
    131131 
    132132    VTABLE INTVAL get_integer() { 
    133         return (INTVAL)(PARROT_POINTER(SELF)->pointer); 
     133        return (INTVAL)&(PARROT_POINTER(SELF)->pointer); 
    134134    } 
    135135 
    136136/* 
     
    144144*/ 
    145145 
    146146    VTABLE FLOATVAL get_number() { 
    147         return (FLOATVAL)(INTVAL)(PARROT_POINTER(SELF)->pointer); 
     147        return (FLOATVAL)(INTVAL)&(PARROT_POINTER(SELF)->pointer); 
    148148    } 
    149149 
    150150/* 
     
    158158*/ 
    159159 
    160160    VTABLE STRING *get_repr() { 
    161         return Parrot_sprintf_c(INTERP, "Pointer = 0x%p", PARROT_POINTER(SELF)->pointer); 
     161        return Parrot_sprintf_c(INTERP, "Pointer = 0x%p", &PARROT_POINTER(SELF)->pointer); 
    162162    } 
    163163 
    164164 
     
    166166 
    167167=item C<STRING *get_string()> 
    168168 
    169 Returns the pointer value as a Parrot string. 
     169Returns the pointer value as a Parrot C<STRING*>. 
    170170 
    171171=cut 
    172172 
     
    187187*/ 
    188188 
    189189    VTABLE INTVAL get_bool() { 
    190         return (INTVAL)(PMC_data(SELF) != NULL); 
     190        return (INTVAL)(*PARROT_POINTER(SELF)->pointer != NULL); 
    191191    } 
    192192 
    193193/* 
  • src/jit/i386/jit_defs.c

     
    22732273                emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(VTABLE, get_pointer)); 
    22742274                emitm_callr(pc, emit_EAX); 
    22752275                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, args_offset); 
     2276                /* reset ESP(4) */ 
     2277                emitm_lea_m_r(interp, pc, emit_EAX, emit_EBP, 0, 1, st_offset); 
     2278                emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 4); 
    22762279                break; 
    22772280            case 'b':   /* buffer (void*) pass PObj_bufstart(SReg) */ 
    22782281                emitm_call_cfunc(pc, get_nci_S); 
  • t/pmc/nci.t

     
    264726473 
    26482648OUTPUT 
    26492649 
    2650 { 
    2651     local $TODO = 0; 
    2652     if ($PConfig{jitcapable}){ 
    2653         $TODO = "TT #551 - jitted NCI sig with V is broken"; 
    2654     } 
    26552650pir_output_is( << 'CODE', << 'OUTPUT', "nci_vVi - void** out parameter" ); 
    26562651.sub test :main 
    26572652    .local string library_name 
     
    26742669CODE 
    26752670got 10 
    26762671OUTPUT 
    2677 } 
    26782672 
    26792673pir_output_is( << 'CODE', << 'OUTPUT', "nci_ttt - t_tt parameter" ); 
    26802674.sub test :main 
     
    271227061 
    27132707OUTPUT 
    27142708 
    2715 { 
    2716     local $TODO = 0; 
    2717     if ($PConfig{jitcapable}){ 
    2718         $TODO = "TT #551 - jitted NCI sig with V is broken"; 
    2719     } 
    27202709pir_output_is( << 'CODE', << 'OUTPUT', "nci_vV - char** out parameter" ); 
    27212710.sub test :main 
    27222711    .local string library_name 
     
    27642753It is a beautiful day! 
    27652754Go suck a lemon. 
    27662755OUTPUT 
    2767 } 
    27682756 
    27692757# Local Variables: 
    27702758#   mode: cperl 
  • tools/build/nativecall.pl

     
    353353    }; 
    354354    /V/ && do { 
    355355        push @{$temps_ref},          "PMC *t_$temp_num;"; 
    356         push @{$temps_ref},          "void *v_$temp_num;"; 
     356        push @{$temps_ref},          "void **v_$temp_num;"; 
    357357        push @{$extra_preamble_ref}, "t_$temp_num = GET_NCI_P($reg_num);"; 
    358         push @{$extra_preamble_ref}, "v_$temp_num = VTABLE_get_pointer(interp, t_$temp_num);"; 
    359         push @{$extra_postamble_ref}, "VTABLE_set_pointer(interp, t_$temp_num, v_$temp_num);"; 
    360         return "&v_$temp_num"; 
     358        push @{$extra_preamble_ref}, "v_$temp_num = (void **) VTABLE_get_pointer(interp, t_$temp_num);"; 
     359        return "v_$temp_num"; 
    361360    }; 
    362361    /[ilIscfdNS]/ && do { 
    363362        my $ret_type = $sig_table{$_}{return_type};