mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	Fix ffi/defbind for non-lazy bindings.
Add testing to bind to symbols in current binary.
This commit is contained in:
		| @@ -3670,7 +3670,7 @@ | ||||
|     (defn make-sig [] | ||||
|       (ffi/signature :default ret-type ;computed-type-args)) | ||||
|     (defn make-ptr [] | ||||
|       (assert (ffi/lookup (llib) raw-symbol) "failed to find symbol")) | ||||
|       (assert (ffi/lookup (if lazy (llib) lib) raw-symbol) "failed to find symbol")) | ||||
|     (if lazy | ||||
|         ~(defn ,name ,;meta [,;formal-args] | ||||
|            (,ffi/call (,(delay (make-ptr))) (,(delay (make-sig))) ,;formal-args)) | ||||
|   | ||||
| @@ -28,5 +28,16 @@ | ||||
| (assert (= (thunk) 1) "delay 3") | ||||
| (assert (= counter 1) "delay 4") | ||||
|  | ||||
| # FFI check | ||||
| (compwhen (dyn 'ffi/native) | ||||
|   (ffi/context)) | ||||
| (compwhen (dyn 'ffi/native) | ||||
|   (ffi/defbind memcpy :ptr [dest :ptr src :ptr n :size])) | ||||
| (compwhen (dyn 'ffi/native) | ||||
|   (def buffer1 @"aaaa") | ||||
|   (def buffer2 @"bbbb") | ||||
|   (memcpy buffer1 buffer2 4) | ||||
|   (assert (= (string buffer1) "bbbb") "ffi 1 - memcpy")) | ||||
|  | ||||
| (end-suite) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose