Ticket #551: nci_V_fix.patch
File nci_V_fix.patch, 5.7 KB (added by cotto, 13 years ago) |
---|
-
src/nci_test.c
104 104 PARROT_EXPORT void nci_vpii(Outer *, int, int); 105 105 PARROT_EXPORT void nci_vv(void); 106 106 PARROT_EXPORT void nci_vVi(Opaque**, int); 107 PARROT_EXPORT void nci_vp(Opaque* );107 PARROT_EXPORT void nci_vp(Opaque**); 108 108 PARROT_EXPORT char * nci_ttt(char *, char *); 109 109 PARROT_EXPORT void nci_vfff(float, float, float); 110 110 PARROT_EXPORT void nci_vV(const char **); … … 1087 1087 /* 1088 1088 1089 1089 =item C<PARROT_EXPORT int 1090 nci_vp(Opaque* )>1090 nci_vp(Opaque**)> 1091 1091 1092 1092 Test that a previously generated opaque struct gets passed back 1093 1093 to an NCI function correctly. … … 1097 1097 */ 1098 1098 1099 1099 PARROT_EXPORT void 1100 nci_vp(Opaque * inOpaque)1100 nci_vp(Opaque **inOpaque) 1101 1101 { 1102 if ( inOpaque)1103 printf("got %d\n", inOpaque->x);1102 if (*inOpaque) 1103 printf("got %d\n", (*inOpaque)->x); 1104 1104 else 1105 1105 printf("got null"); 1106 1106 } -
src/pmc/pointer.pmc
23 23 #include "parrot/parrot.h" 24 24 25 25 pmclass Pointer need_ext { 26 ATTR void * mark_function;27 ATTR void * pointer;26 ATTR void * mark_function; 27 ATTR void ** pointer; 28 28 29 29 /* 30 30 … … 69 69 VTABLE void mark() { 70 70 void (*mark_function)(Interp *, void *) = 71 71 (void (*)(Interp *, void *))D2FPTR(PARROT_POINTER(SELF)->mark_function); 72 void * data = PARROT_POINTER(SELF)->pointer;72 void * data = *PARROT_POINTER(SELF)->pointer; 73 73 if (data && mark_function) 74 74 (*mark_function)(INTERP, data); 75 75 } … … 102 102 */ 103 103 104 104 VTABLE void set_pointer(void *ptr) { 105 PARROT_POINTER(SELF)->pointer = ptr;105 *PARROT_POINTER(SELF)->pointer = ptr; 106 106 } 107 107 108 108 /* … … 116 116 */ 117 117 118 118 VTABLE void *get_pointer() { 119 return PARROT_POINTER(SELF)->pointer;119 return &(PARROT_POINTER(SELF)->pointer); 120 120 } 121 121 122 122 /* … … 130 130 */ 131 131 132 132 VTABLE INTVAL get_integer() { 133 return (INTVAL) (PARROT_POINTER(SELF)->pointer);133 return (INTVAL)&(PARROT_POINTER(SELF)->pointer); 134 134 } 135 135 136 136 /* … … 144 144 */ 145 145 146 146 VTABLE FLOATVAL get_number() { 147 return (FLOATVAL)(INTVAL) (PARROT_POINTER(SELF)->pointer);147 return (FLOATVAL)(INTVAL)&(PARROT_POINTER(SELF)->pointer); 148 148 } 149 149 150 150 /* … … 158 158 */ 159 159 160 160 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); 162 162 } 163 163 164 164 … … 166 166 167 167 =item C<STRING *get_string()> 168 168 169 Returns the pointer value as a Parrot string.169 Returns the pointer value as a Parrot C<STRING*>. 170 170 171 171 =cut 172 172 … … 187 187 */ 188 188 189 189 VTABLE INTVAL get_bool() { 190 return (INTVAL)( PMC_data(SELF)!= NULL);190 return (INTVAL)(*PARROT_POINTER(SELF)->pointer != NULL); 191 191 } 192 192 193 193 /* -
src/jit/i386/jit_defs.c
2273 2273 emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(VTABLE, get_pointer)); 2274 2274 emitm_callr(pc, emit_EAX); 2275 2275 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); 2276 2279 break; 2277 2280 case 'b': /* buffer (void*) pass PObj_bufstart(SReg) */ 2278 2281 emitm_call_cfunc(pc, get_nci_S); -
t/pmc/nci.t
2647 2647 3 2648 2648 OUTPUT 2649 2649 2650 {2651 local $TODO = 0;2652 if ($PConfig{jitcapable}){2653 $TODO = "TT #551 - jitted NCI sig with V is broken";2654 }2655 2650 pir_output_is( << 'CODE', << 'OUTPUT', "nci_vVi - void** out parameter" ); 2656 2651 .sub test :main 2657 2652 .local string library_name … … 2674 2669 CODE 2675 2670 got 10 2676 2671 OUTPUT 2677 }2678 2672 2679 2673 pir_output_is( << 'CODE', << 'OUTPUT', "nci_ttt - t_tt parameter" ); 2680 2674 .sub test :main … … 2712 2706 1 2713 2707 OUTPUT 2714 2708 2715 {2716 local $TODO = 0;2717 if ($PConfig{jitcapable}){2718 $TODO = "TT #551 - jitted NCI sig with V is broken";2719 }2720 2709 pir_output_is( << 'CODE', << 'OUTPUT', "nci_vV - char** out parameter" ); 2721 2710 .sub test :main 2722 2711 .local string library_name … … 2764 2753 It is a beautiful day! 2765 2754 Go suck a lemon. 2766 2755 OUTPUT 2767 }2768 2756 2769 2757 # Local Variables: 2770 2758 # mode: cperl -
tools/build/nativecall.pl
353 353 }; 354 354 /V/ && do { 355 355 push @{$temps_ref}, "PMC *t_$temp_num;"; 356 push @{$temps_ref}, "void * v_$temp_num;";356 push @{$temps_ref}, "void **v_$temp_num;"; 357 357 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"; 361 360 }; 362 361 /[ilIscfdNS]/ && do { 363 362 my $ret_type = $sig_table{$_}{return_type};