Check-in [1c412155ba]

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

Overview
Comment:updated BlitzMax test
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:1c412155bae4944315900b7aacbaddf547b26952ab2a18e77e1dec95cfdf8e61
User & Date: grable 2018-11-01 19:16:31
Context
2018-11-01
19:24
added BlitzMax test to makefile check-in: a52e2db53b user: grable tags: trunk
19:16
updated BlitzMax test check-in: 1c412155ba user: grable tags: trunk
19:01
moved last file to tests and tweaked the makefile to fit check-in: 7c24c9d52b user: grable tags: trunk
Changes

Changes to jimff.bmx.

32
33
34
35
36
37
38
39
40





41
42
43
44
45
46
47
..
56
57
58
59
60
61
62
63
64





65
66
67
68
69
70
71
..
73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
	Const JIMFF_TYPE_STRUCT:Int = AV_TYPE_STRUCT
	
	Type TJimFFSymbol
		'Field Tag:Int
		Field Flags:Int
		Field Name:Byte Ptr
		Field TypeTag:Byte Ptr
		Field ReturnType:Int
		Field ArgC:Int





		Field Addr:Byte Ptr
		Field Size:Int
		Field Link:TJimFFSymbol
		Field NumLinks:Int
		Field Library:TJimFFLibrary
	EndType
	
................................................................................
		Field Context:TJimFFContext
	EndType
	
	Type TJimFFCallback
		'Field Flags:Int
		Field Name:Byte Ptr
		Field TypeTag:Byte Ptr
		Field ReturnType:Int
		Field ArgC:Int





		Field Fn:Byte Ptr
		Field Command:TJimObj
		Field Context:TJimFFContext
	EndType

	Type TJimFFContext
		'Field Flags:Int
................................................................................
		Field Name:Byte Ptr
		Field LibsLen:Int
		Field LibsMax:Int
		Field Libs:TJimFFLibrary Ptr
		Field CbsLen:Int
		Field CbsMax:Int
		Field Cbs:TJimFFCallback Ptr

	EndType
	
	Type TJimFFNoValue
	EndType
	
	Function jimff_typetag_type:Int( typetag:Byte)
	Function jimff_jimff_typetag_valid:Int( typetag:Byte Ptr)
	
	Function jimff_newcontext:TJimFFContext( interp:TJimInterp, name:Byte Ptr, flags:Int = 0)
	Function jimff_freecontext( ctx:TJimFFContext)
	
	Function jimff_load_library:TJimFFLibrary( ctx:TJimFFContext, path$z, flags:Int = 0)
	Function jimff_find_library:TJimFFLibrary( ctx:TJimFFContext, path$z)
	Function jimff_getlibrary:TJimFFLibrary( ctx:TJimFFContext, obj:TJimObj)	
		
	Function jimff_import_symbol:TJimFFSymbol( lib:TJimFFLibrary, tag:Int, name$z, _alias$z, typetag$z)
	Function jimff_find_symbol:TJimFFSymbol( ctx:TJimFFLibrary, name$z)
	Function jimff_delete_symbol:TJimFFSymbol( ctx:TJimFFLibrary, name$z)
	
	Function jimff_prepare_call:Int( ctx:TJimFFContext, avlist:TAvList, sym:TJimFFSymbol, argc:Int, argv:TJimObj Ptr, result:Byte Ptr)
	Function jimff_finish_call:TJimObj( ctx:TJimFFContext, avlist:TAvList, sym:TJimFFSymbol, result:Byte Ptr)
................................................................................
	
	Function jimff_set:TJimObj( ctx:TJimFFContext, sym:TJimFFSymbol, value:TJimObj)
	
	Function jimff_create_callback:TJimFFCallback( ctx:TJimFFContext, name:Byte Ptr, typetag:Byte Ptr)
	Function jimff_register_callback:TJimObj( ctx:TJimFFContext, callback:TJimFFCallback, command:TJimObj)
	Function jimff_find_callback:TJimFFCallback( ctx:TJimFFContext, name$z)
	Function jimff_delete_callback:TJimFFCallback( ctx:TJimFFContext, name$z)	
	Function jimff_getcallback:TJimFFCallback( ctx:TJimFFContext, obj:TJimObj)
	
	Function Jim_jimffInit:Int( interp:TJimInterp)
EndExtern

Function jimff_get:TJimObj( ctx:TJimFFContext, sym:TJimFFSymbol)
	Return jimff_set( ctx, sym, Null)
EndFunction







<

>
>
>
>
>







 







<

>
>
>
>
>







 







>













|







 







|







32
33
34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50
51
..
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74
75
76
77
78
79
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
	Const JIMFF_TYPE_STRUCT:Int = AV_TYPE_STRUCT
	
	Type TJimFFSymbol
		'Field Tag:Int
		Field Flags:Int
		Field Name:Byte Ptr
		Field TypeTag:Byte Ptr

		Field ArgC:Int
		Field ReturnType:Int
		Field NumPointers:Int
		Field NumCallbacks:Int
		Field PointerSizes:Int Ptr
		Field Callbacks:Byte Ptr Ptr
		Field Addr:Byte Ptr
		Field Size:Int
		Field Link:TJimFFSymbol
		Field NumLinks:Int
		Field Library:TJimFFLibrary
	EndType
	
................................................................................
		Field Context:TJimFFContext
	EndType
	
	Type TJimFFCallback
		'Field Flags:Int
		Field Name:Byte Ptr
		Field TypeTag:Byte Ptr

		Field ArgC:Int
		Field ReturnType:Int
		Field NumPointers:Int
		Field NumCallbacks:Int
		Field PointerSizes:Int Ptr
		Field Callbacks:Byte Ptr Ptr
		Field Fn:Byte Ptr
		Field Command:TJimObj
		Field Context:TJimFFContext
	EndType

	Type TJimFFContext
		'Field Flags:Int
................................................................................
		Field Name:Byte Ptr
		Field LibsLen:Int
		Field LibsMax:Int
		Field Libs:TJimFFLibrary Ptr
		Field CbsLen:Int
		Field CbsMax:Int
		Field Cbs:TJimFFCallback Ptr
		Field CbError:TJimObj
	EndType
	
	Type TJimFFNoValue
	EndType
	
	Function jimff_typetag_type:Int( typetag:Byte)
	Function jimff_jimff_typetag_valid:Int( typetag:Byte Ptr)
	
	Function jimff_newcontext:TJimFFContext( interp:TJimInterp, name:Byte Ptr, flags:Int = 0)
	Function jimff_freecontext( ctx:TJimFFContext)
	
	Function jimff_load_library:TJimFFLibrary( ctx:TJimFFContext, path$z, flags:Int = 0)
	Function jimff_find_library:TJimFFLibrary( ctx:TJimFFContext, path$z)
	Function jimff_getlibrary:TJimFFLibrary( ctx:TJimFFContext, obj:TJimObj, update:Int)	
		
	Function jimff_import_symbol:TJimFFSymbol( lib:TJimFFLibrary, tag:Int, name$z, _alias$z, typetag$z)
	Function jimff_find_symbol:TJimFFSymbol( ctx:TJimFFLibrary, name$z)
	Function jimff_delete_symbol:TJimFFSymbol( ctx:TJimFFLibrary, name$z)
	
	Function jimff_prepare_call:Int( ctx:TJimFFContext, avlist:TAvList, sym:TJimFFSymbol, argc:Int, argv:TJimObj Ptr, result:Byte Ptr)
	Function jimff_finish_call:TJimObj( ctx:TJimFFContext, avlist:TAvList, sym:TJimFFSymbol, result:Byte Ptr)
................................................................................
	
	Function jimff_set:TJimObj( ctx:TJimFFContext, sym:TJimFFSymbol, value:TJimObj)
	
	Function jimff_create_callback:TJimFFCallback( ctx:TJimFFContext, name:Byte Ptr, typetag:Byte Ptr)
	Function jimff_register_callback:TJimObj( ctx:TJimFFContext, callback:TJimFFCallback, command:TJimObj)
	Function jimff_find_callback:TJimFFCallback( ctx:TJimFFContext, name$z)
	Function jimff_delete_callback:TJimFFCallback( ctx:TJimFFContext, name$z)	
	Function jimff_getcallback:TJimFFCallback( ctx:TJimFFContext, obj:TJimObj, update:Int)
	
	Function Jim_jimffInit:Int( interp:TJimInterp)
EndExtern

Function jimff_get:TJimObj( ctx:TJimFFContext, sym:TJimFFSymbol)
	Return jimff_set( ctx, sym, Null)
EndFunction

Deleted jimff_test.s.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
format MS COFF

extrn _malloc
extrn _bb_test_cb

section '.reloc' data readable discardable ;fixups 
section '.edata' data readable ;export
	dd 0,0,0,RVA _lib_name,1
	dd 2,2,RVA _address_table,RVA _name_table,RVA _ordinal_table

	_address_table:
		dd RVA _malloc
		dd RVA _bb_test_cb

	_name_table:
		dd RVA _name_1
		dd RVA _name_2

	_ordinal_table:
		dw 0, 1

	_lib_name db 'jimff_test.exe',0
	_name_1 db 'malloc',0
	_name_2 db 'test_cb',0
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































Name change from jimff_test.bmx to tests/jimff_test.bmx.

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
41
42
43
44
45
46
47
48
' testing jimff package
'
Local jim:TJimInterp = Jim_CreateInterp()
Jim_RegisterCoreCommands jim
Jim_InitStaticExtensions jim
Jim_jimffInit(jim)




















Function test_cb( msg:Byte Ptr, cb:Int( i:Int, z$z, f:Float)) 'DLLEXPORT
	Print "begin test_cb " + String.FromCString(msg)
	Print "result=" + cb( 1, "2", 3.0)
	Print "end"
EndFunction

eval jim, "proc test_1 {i s f} { puts ~q\ti=$i\n\tz=\~q$s\~q\n\tf=$f~q; expr $i + 1 }"

eval jim, "jimff ff"
eval jim, "ff::load test_lib.dll"
eval jim, "ff::import test_callback vzx"
eval jim, "set cb [ff::callback test_1 iizf]"
eval jim, "test_callback message $cb"
eval jim, "ff::free"

eval jim, "jimff ff"
eval jim, "ff::load -self"
eval jim, "ff::import test_cb vzx"
eval jim, "set cb [ff::callback test_1 iizf]"
eval jim, "test_cb message $cb"
eval jim, "ff::free"


Jim_FreeInterp jim
End


Function eval:Int( interp:TJimInterp, script:String, context:String = "IDE")
	Global line:Int = 0







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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
41
42
43
44
















45
46
47
48
49
50
51
' testing jimff package
'
Local jim:TJimInterp = Jim_CreateInterp()
Jim_RegisterCoreCommands jim
Jim_InitStaticExtensions jim
Jim_jimffInit(jim)

eval jim, "proc test_1 {i s f} { puts ~q\ti=$i\n\tz=\~q$s\~q\n\tf=$f~q; expr $i + 1 }"

' run callback through C function
eval jim, "jimff ff"
eval jim, "ff::load test_lib.dll"
eval jim, "ff::import test_callback vzx(iizd)"
eval jim, "set cb [ff::callback test_1 iizd]"	;# note 'd' instead of 'f' since C promotes to double when uncertain
eval jim, "test_callback message $cb"
eval jim, "ff::free"

' run callback through BlitzMax function
eval jim, "jimff ff"
eval jim, "ff::load -self"
eval jim, "ff::import test_cb vzx(iizf)"
eval jim, "set cb [ff::callback test_1 iizf]"		;# note the 'f' instead of 'd' since BlitzMax does float when it says it will
eval jim, "test_cb message $cb"
eval jim, "ff::free"

' same as "test_lib.dll/test_callback"
Function test_cb( msg:Byte Ptr, cb:Int( i:Int, z$z, f:Float)) 'DLLEXPORT
	Print "begin test_cb " + String.FromCString(msg)
	Print "result=" + cb( 1, "2", 3.0)
	Print "end"
EndFunction


















Jim_FreeInterp jim
End


Function eval:Int( interp:TJimInterp, script:String, context:String = "IDE")
	Global line:Int = 0