Check-in [e3d41fdce5]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixed prepare_call() and cb_callback() not counting return pointers correctly
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:e3d41fdce5827b5c91f36bb22b756aaac1f4b58894c2b19a6505823d6393c922
User & Date: grable 2018-11-01 04:53:39
Context
2018-11-01
04:59
moved last commit to better place check-in: 74e82127a9 user: grable tags: trunk
04:53
fixed prepare_call() and cb_callback() not counting return pointers correctly check-in: e3d41fdce5 user: grable tags: trunk
04:39
removed old todo check-in: 175cec980d user: grable tags: trunk
Changes

Changes to jimff-call.c.

42
43
44
45
46
47
48
49
50



51
52
53
54
55
56
57
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
	} else if(sym->typeinfo.returntype == JIMFF_TYPE_STRUCT) {
		av_start_struct( AV, sym->addr, sym->typeinfo.pointersizes[0], result);
		numptrs++;
	} else {
		av_start( AV, sym->addr, result, sym->typeinfo.returntype);
	}
	
	if(sym->typeinfo.typetag[0] == 'x') numcbs++;
	else if(sym->typeinfo.returntype == JIMFF_TYPE_VOIDP) numptrs++;



	
	int arg = 0;
	const char* t;
	for( t = sym->typeinfo.typetag + 1; ; t++) {
		if(arg >= argc) goto done_with_args;
		switch(*t) {
			case '\0':	goto done_with_args;
................................................................................
				else av_float( AV, (float)tmp.d);
				break;
			
			case 'p':
			case 'P': {
				int size;
				void* p;
				if(*t == 'T')
					p = jimff_forget_pointer( ctx, argv[arg], &size, sym->typeinfo.pointersizes[numptrs]);
				else
					p = jimff_getpointer( ctx, argv[arg], &size, 0);
				if(size == -1) goto err_invalid_pointer;
				if(sym->typeinfo.pointersizes[numptrs] && sym->typeinfo.pointersizes[numptrs] != size) goto err_invalid_ptrsize;
				numptrs++;
				av_ptr( AV, void*, p);







|
|
>
>
>







 







|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
	} else if(sym->typeinfo.returntype == JIMFF_TYPE_STRUCT) {
		av_start_struct( AV, sym->addr, sym->typeinfo.pointersizes[0], result);
		numptrs++;
	} else {
		av_start( AV, sym->addr, result, sym->typeinfo.returntype);
	}
	
	switch(sym->typeinfo.typetag[0]) {
		case 'x':	numcbs++; break;
		case 'p':
		case 'P':	numptrs++; break;
	}
	
	int arg = 0;
	const char* t;
	for( t = sym->typeinfo.typetag + 1; ; t++) {
		if(arg >= argc) goto done_with_args;
		switch(*t) {
			case '\0':	goto done_with_args;
................................................................................
				else av_float( AV, (float)tmp.d);
				break;
			
			case 'p':
			case 'P': {
				int size;
				void* p;
				if(*t == 'P')
					p = jimff_forget_pointer( ctx, argv[arg], &size, sym->typeinfo.pointersizes[numptrs]);
				else
					p = jimff_getpointer( ctx, argv[arg], &size, 0);
				if(size == -1) goto err_invalid_pointer;
				if(sym->typeinfo.pointersizes[numptrs] && sym->typeinfo.pointersizes[numptrs] != size) goto err_invalid_ptrsize;
				numptrs++;
				av_ptr( AV, void*, p);

Changes to jimff-callback.c.

121
122
123
124
125
126
127
128
129



130
131
132
133
134
135
136
		vacall_start_struct( valist, cb->typeinfo.pointersizes[0], 4, 0, __VA_START_FLAGS);
		numptrs++;
	} else {
		//NOTE:  have to do -1 on VA-types because they are 1 less than AV-types
		vacall_start( valist, cb->typeinfo.returntype - 1, __VA_START_FLAGS);
	}
	
	if(cb->typeinfo.typetag[0] == 'x') numcbs++;
	else if(cb->typeinfo.returntype == JIMFF_TYPE_VOIDP) numptrs++;



		
#define INTERP			(cb->ctx->interp)
#define DPFLAGS(t)	(((t) == 'P') ? JIMFF_DYNAMIC_POINTER_FLAGS : 0)

// set an error on the jimff context, hopefully it will be picked up by the caller
#define SETERR(err, msg)																							\
	({	Jim_SetResultFormatted( INTERP,																		\







|
|
>
>
>







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
		vacall_start_struct( valist, cb->typeinfo.pointersizes[0], 4, 0, __VA_START_FLAGS);
		numptrs++;
	} else {
		//NOTE:  have to do -1 on VA-types because they are 1 less than AV-types
		vacall_start( valist, cb->typeinfo.returntype - 1, __VA_START_FLAGS);
	}
	
	switch(cb->typeinfo.typetag[0]) {
		case 'x':	numcbs++; break;
		case 'p':
		case 'P':	numptrs++; break;
	}
		
#define INTERP			(cb->ctx->interp)
#define DPFLAGS(t)	(((t) == 'P') ? JIMFF_DYNAMIC_POINTER_FLAGS : 0)

// set an error on the jimff context, hopefully it will be picked up by the caller
#define SETERR(err, msg)																							\
	({	Jim_SetResultFormatted( INTERP,																		\

Changes to jimff.c.

212
213
214
215
216
217
218



219
220
221
222



223
224
225
226
227
228
229
	if(!gotrtype) return 0; // error
	buffer[len] = '\0';
	typeinfo->typetag = strdup(buffer);
	typeinfo->argc = argc;
	if(numptrsizes > 0) {
		typeinfo->pointersizes = memcpy( malloc(sizeof(int) * numptrsizes), ptrsizes, sizeof(int) * numptrsizes);
		typeinfo->numpointers = numptrsizes;



	}	
	if(numcallbacks > 0) {
		typeinfo->callbacks = memcpy( malloc(sizeof(int) * numcallbacks), callbacks, sizeof(int) * numcallbacks);
		typeinfo->numcallbacks = numcallbacks;



	}
	return 1;
}

static unsigned long jimff_context_epoch = 0;









>
>
>
|



>
>
>







212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
	if(!gotrtype) return 0; // error
	buffer[len] = '\0';
	typeinfo->typetag = strdup(buffer);
	typeinfo->argc = argc;
	if(numptrsizes > 0) {
		typeinfo->pointersizes = memcpy( malloc(sizeof(int) * numptrsizes), ptrsizes, sizeof(int) * numptrsizes);
		typeinfo->numpointers = numptrsizes;
	} else {
		typeinfo->pointersizes = NULL;
		typeinfo->numpointers = 0;
	}
	if(numcallbacks > 0) {
		typeinfo->callbacks = memcpy( malloc(sizeof(int) * numcallbacks), callbacks, sizeof(int) * numcallbacks);
		typeinfo->numcallbacks = numcallbacks;
	} else {
		typeinfo->callbacks = NULL;
		typeinfo->numcallbacks = 0;
	}
	return 1;
}

static unsigned long jimff_context_epoch = 0;