Check-in [48c68babfd]

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

Overview
Comment:replaced the build script with an equivalently crude makefile, also fixed some old asserts
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:48c68babfd587e936b9047771333fd1157f5e09183e80026731bb3938e365c88
User & Date: grable 2018-10-30 18:06:25
Context
2018-10-30
20:26
the missing makefile check-in: 0321cad1e3 user: grable tags: trunk
18:06
replaced the build script with an equivalently crude makefile, also fixed some old asserts check-in: 48c68babfd user: grable tags: trunk
2018-10-29
22:59
removed backups from build script, no need for this now that fossil has taken over check-in: 95dab16c92 user: grable tags: trunk
Changes

Deleted build.cmd.

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
@echo off
setlocal
set INCLUDE=-Ic:/BlitzMax/mod/grb.mod/jimtcl.mod/jimtcl -Ic:/BlitzMax/mod/grb.mod/ffcall.mod/ffcall/include
set LIB=-Lc:/BlitzMax/mod/grb.mod/ffcall.mod/ffcall/lib
set LIBJIM=c:/BlitzMax/mod/grb.mod/jimtcl.mod/jimtcl/libjim.dll
set LIBS=-l:libffcall.dll.a
set FLAGS=-m32 -std=gnu11 -march=native -mtune=generic
rem set STRIP=-s

call :build_extras
if [%1] == [release] (
	set STRIP=-s
	goto build_lib
)
if [%1] == [small] goto build_lib_small
if [%1] == [debug] goto build_lib_debug
goto build_lib

:build_lib
gcc %FLAGS% -Ofast %STRIP% -DNDEBUG -w %INCLUDE% %LIB% %LIBJIM% -shared -DJIMFF_DLL jimff.c %LIBS% -o jimff.so
if errorlevel 1 goto :eof
goto exit_ok

:build_lib_small
gcc %FLAGS% -Os -s -DNDEBUG -w %INCLUDE% %LIB% %LIBJIM% -shared -DJIMFF_DLL jimff.c %LIBS% -o jimff.so
if errorlevel 1 goto :eof
goto exit_ok

:build_lib_debug
gcc %FLAGS% -Og -g %INCLUDE% %LIB% %LIBJIM% -shared -DJIMFF_DLL jimff.c %LIBS% -o jimff.so
if errorlevel 1 goto :eof
goto exit_ok

:build_extras
gcc %FLAGS% -Os %STRIP% -DNDEBUG -shared test_lib.c -o test_lib.dll
if errorlevel 1 goto :eof
goto exit_ok

:exit_ok
exit /b 0
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































Changes to jimff-call.c.

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
	return JIM_ERR;
	
#undef AV
}

JIMFF_API Jim_Obj* jimff_newresult( struct jimff_context* ctx, const struct jimff_symbol* sym, const union jimff_result* result) {
	assert( ctx );
	assert( type >= JIMFF_TYPE_VOID && type <= JIMFF_TYPE_VOIDP );
	assert( typetag && *typetag );
	assert( result );

	switch(sym->returntype) {
		case JIMFF_TYPE_VOID:
			return ctx->interp->emptyObj;
		case JIMFF_TYPE_CHAR ... JIMFF_TYPE_ULONGLONG:
			//TODO: figure out if shunting all integer types to long long works as expected







<
|







176
177
178
179
180
181
182

183
184
185
186
187
188
189
190
	return JIM_ERR;
	
#undef AV
}

JIMFF_API Jim_Obj* jimff_newresult( struct jimff_context* ctx, const struct jimff_symbol* sym, const union jimff_result* result) {
	assert( ctx );

	assert( sym );
	assert( result );

	switch(sym->returntype) {
		case JIMFF_TYPE_VOID:
			return ctx->interp->emptyObj;
		case JIMFF_TYPE_CHAR ... JIMFF_TYPE_ULONGLONG:
			//TODO: figure out if shunting all integer types to long long works as expected

Changes to jimff.c.

124
125
126
127
128
129
130
131

132
133
134
135
136
137
138
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
453
454
455
456
457
458
459
460
461
462
463
464
465

466
467
468
469
470
471
472
473
474
475
	}
}

//NOTE: checks if a typetag  string is valid, compresses it in the process and stores it in result, allso stores the returntype, returns 1=success or 0=failure
static int jimff_validate_typetag( const char* typetag, int* returntype, char** rtypetag, int** rptrsizes) {
	assert( typetag );
	assert( returntype );
	assert( result );

	
	int gotrtype = 0;
	int type;
	char ch;
	int len = 0;
	char* tmp;
	char* end;
................................................................................
	tmp = malloc(len + 1);
	memcpy( tmp, buffer, len);
	tmp[len] = '\0';
	*rtypetag = tmp;
	if(numptrsizes > 0) {
		tmp = malloc(sizeof(int) * numptrsizes);
		memcpy( tmp, ptrsizes, sizeof(int) * numptrsizes);
		*rptrsizes = tmp;
	} else {
		*rptrsizes = NULL;
	}
	return 1;
}

static unsigned long jimff_context_epoch = 0;
................................................................................
			break;
		}
	}
}

JIMFF_API struct jimff_symbol* jimff_import_symbol( struct jimff_library* lib, int tag, const char* name, const char* alias, union jimff_argument argument) {
	assert( lib && lib->handle );
	assert( name && *name );
	assert( tag >= JIMFF_SYM_FUNCTION && tag <= JIMFF_SYM_POINTER );
	assert( typetag && *typetag );
	
	struct jimff_symbol* link = NULL;
	struct jimff_symbol* sym;
	int returntype;
	const void* addr;
	int size = 0;
	const char* typetag;
	int* ptrsizes;
	
	// check if symbol is already imported
	if(sym = jimff_find_symbol( lib, name)) {
		if(!alias || !strcmp( name, alias)) {
			// only return symbols if they match exactly
			if(tag == JIMFF_SYM_POINTER) {
................................................................................
		}
	}
}

//NOTE: cb_callback() marshals callback arguments, calls assigned command and marhalls its result back to the callback
static void cb_callback( void* data, va_alist valist);

JIMFF_API struct jimff_callback* jimff_create_callback( struct jimff_context* ctx, const char* name, const char* typetag) {	
	assert( ctx );
	assert( name );
	
	struct jimff_callback* cb;
	int returntype;

	int* ptrsizes;
	
	if(!jimff_validate_typetag( typetag, &returntype, &typetag, &ptrsizes)) return JIMFF_INVALID_TYPETAG;
	if(jimff_find_callback( ctx, name)) return NULL;
	
	cb = malloc(sizeof(*cb));
	cb->flags = 0;
	cb->name = strdup(name);
	cb->typetag = typetag;
	cb->ptrsizes = ptrsizes;







|
>







 







|







 







|
|
<




|

|







 







|





>


|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
...
353
354
355
356
357
358
359
360
361

362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
	}
}

//NOTE: checks if a typetag  string is valid, compresses it in the process and stores it in result, allso stores the returntype, returns 1=success or 0=failure
static int jimff_validate_typetag( const char* typetag, int* returntype, char** rtypetag, int** rptrsizes) {
	assert( typetag );
	assert( returntype );
	assert( rtypetag );
	assert( rptrsizes );
	
	int gotrtype = 0;
	int type;
	char ch;
	int len = 0;
	char* tmp;
	char* end;
................................................................................
	tmp = malloc(len + 1);
	memcpy( tmp, buffer, len);
	tmp[len] = '\0';
	*rtypetag = tmp;
	if(numptrsizes > 0) {
		tmp = malloc(sizeof(int) * numptrsizes);
		memcpy( tmp, ptrsizes, sizeof(int) * numptrsizes);
		*rptrsizes = (int*)tmp;
	} else {
		*rptrsizes = NULL;
	}
	return 1;
}

static unsigned long jimff_context_epoch = 0;
................................................................................
			break;
		}
	}
}

JIMFF_API struct jimff_symbol* jimff_import_symbol( struct jimff_library* lib, int tag, const char* name, const char* alias, union jimff_argument argument) {
	assert( lib && lib->handle );
	assert( name );
	assert( alias );

	
	struct jimff_symbol* link = NULL;
	struct jimff_symbol* sym;
	int returntype;
	void* addr;
	int size = 0;
	char* typetag;
	int* ptrsizes;
	
	// check if symbol is already imported
	if(sym = jimff_find_symbol( lib, name)) {
		if(!alias || !strcmp( name, alias)) {
			// only return symbols if they match exactly
			if(tag == JIMFF_SYM_POINTER) {
................................................................................
		}
	}
}

//NOTE: cb_callback() marshals callback arguments, calls assigned command and marhalls its result back to the callback
static void cb_callback( void* data, va_alist valist);

JIMFF_API struct jimff_callback* jimff_create_callback( struct jimff_context* ctx, const char* name, const char* _typetag) {	
	assert( ctx );
	assert( name );
	
	struct jimff_callback* cb;
	int returntype;
	char* typetag;
	int* ptrsizes;
	
	if(!jimff_validate_typetag( _typetag, &returntype, &typetag, &ptrsizes)) return JIMFF_INVALID_TYPETAG;
	if(jimff_find_callback( ctx, name)) return NULL;
	
	cb = malloc(sizeof(*cb));
	cb->flags = 0;
	cb->name = strdup(name);
	cb->typetag = typetag;
	cb->ptrsizes = ptrsizes;