soegaard2
2021-4-12 07:26:40

Here is an example (Racket 8.0 [cs]): #lang racket (require gui-widget-mixins racket/gui) (define tooltip-check-box% (tooltip-mixin check-box%)) (define clicks '()) (define (make-callback n) (λ _ (set! clicks (cons n clicks)))) (define f (new frame% [label "A Frame"])) (define vp (new vertical-panel% [parent f] )) (define tcb1 (new tooltip-check-box% [parent vp] [label "Button 1"] [callback (make-callback 1)] [tooltip "This is button 1"] [tooltip-delay 500])) (define tcb2 (new tooltip-check-box% [parent vp] [label "Button 2"] [callback (make-callback 2)] [tooltip "This is button 2"] [tooltip-delay 500])) (send f show #t)


enyala9733
2021-4-12 09:34:47

I retry 7.5 version. all the same. At this time last year, I directly executed build.bat. It took about half an hour and everything would be completed. At that time, it seemed that vcpkg was not installed on my computer. I thought it might be because I installed vcpkg, because when I opened it in visual studio, it would prompt me "Cannot identify debug or release, whether to close vcpkg, I chose yes. Then a new problem appeared.


enyala9733
2021-4-12 09:35:15

"C:\Users\mingy\Desktop\racket-7.5\racket\src\worksp\racket\racketX.sln" (default target) (1) -> “C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj” (default target) (2) -> (PostBuildEvent target) -> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MS B3073: The command " [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: if exist “C:\Users\mingy\Desktop\racket–7.5\racket\RacketCGC.exe” goto :MzOK [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp \racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: echo Error: did not find C:\Users\mingy\Desktop\racket–7.5\racket\RacketCGC.exe [C:\Users\mingy\Desktop\racket–7.5\racket\src\wor ksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: exit 1 [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: :MzOK [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: “C:\Users\mingy\Desktop\racket–7.5\racket\RacketCGC.exe” -cu ....\racket\mkincludes.rkt “C:\Users\mingy\Desktop\racket–7.5\racke t/include/” ....\racket .. [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: if errorlevel 1 exit 1 [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: cd ....\racket\dynsrc [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: call mkmzdyn.bat SRelease x64 [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: cd ....\worksp\racket [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: addman.bat [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3 073: :VCEnd" exited with code 1. [C:\Users\mingy\Desktop\racket–7.5\racket\src\worksp\racket\racketX.vcxproj]

1975 Warning(s)
1 Error(s)

Time Elapsed 00:01:34.29


enyala9733
2021-4-12 09:40:22

I also considered whether it was because the folder directory had "-", and then I renamed the folder to racket. The result was the same as above.


enyala9733
2021-4-12 09:44:47

I executed vcpkg integrate remove. I saw a familiar picture!


enyala9733
2021-4-12 09:49:58

It’s a success!


enyala9733
2021-4-12 09:57:29

Hello, if I want to know the implementation of racket, which version of the source code is most suitable for building a knowledge map, and what materials can I refer to?


alexharsanyi
2021-4-12 13:19:59

I could not reproduce the bug with the sample program (running on Windows), so perhaps Mac OS does not sent “mouse leave” events to the widget. I attempted to work around this on the “ah/leave” branch, https://github.com/alex-hhh/gui-widget-mixins/tree/ah/leave, you can check if this solves the problem…


soegaard2
2021-4-12 13:39:23

@alexharsanyi Thanks for looking into it. I see the same thing again. I cloned your repo. And (the second time…) remembered to checkout “ah/leave”. To make sure I was running the new version, I added a line that displays “tooltip-mixin”.


mflatt
2021-4-12 14:26:52

Good to know about vcpkg!

I recommend looking at the CS implementaton or Racket and ignoring the BC implementation. Depending on which layer you want to understand, start with either racket/src/ChezScheme/IMPLEMENTATION.md (that’s Chez Scheme, obviously) or racker/src/cs/README.txt (that describes the layers built on top of Chez Scheme).


enyala9733
2021-4-12 15:11:03

thanks!


josh803
2021-4-12 17:01:18

Hi! Does anybody have any idea why this doesn’t work? (let ([w (malloc _int)] [h (malloc _int)]) (sdl2:query-texture texture #f #f w h) (printf (format "Texture size: ~ax~a" (ptr-ref w _int) (ptr-ref h _int)))) According to the SDL docs, SDL_QueryTexture wants the address of the w (width) and h (height) variables, which this should provide. However, it bails, saying that “int*->C: argument is not `int*’ pointer”. However cpointer? says that it is. Thanks in advance!


soegaard2
2021-4-12 17:02:20

What’s the context? Are you writing your own bindings or using an existing set?


josh803
2021-4-12 17:10:01

@soegaard2 I am trying to use the sdl2 package from https://github.com/lockie/racket-sdl2.


josh803
2021-4-12 17:11:43

I’m using the “pretty” version of the library, which is supposed to be more lispy instead of just direct ffi C calls. However, I think I’d have the same problem with the bare ffi.


idraper
2021-4-12 17:14:56

@idraper has joined the channel


soegaard2
2021-4-12 17:17:58

@josh803 In most FFI bindings I have seen, that kind of detail is hidden. However, let’s try and figure out how racket-sdl2 binds the function. It looks a bit complicated at first sight.


josh803
2021-4-12 17:18:21

Hold on, I have that code.


soegaard2
2021-4-12 17:18:25

In “pretty.rkt” I see: (define-sdl2 query-texture (_fun _texture* _uint32*/null _int*/null _int*/null _int*/null -> _int))


josh803
2021-4-12 17:18:49

That was what I was about to paste…


soegaard2
2021-4-12 17:19:23

(define-ffi-definer define-sdl2 sdl2-lib #:make-c-id convention:uglify)


josh803
2021-4-12 17:19:24

This is what it interfaces to: https://wiki.libsdl.org/SDL_QueryTexture


soegaard2
2021-4-12 17:19:45

Let’s look up what #:make means.


soegaard2
2021-4-12 17:20:31

josh803
2021-4-12 17:21:41

As I understand it, that’s just what he’s using to “prettify” the library interface.


soegaard2
2021-4-12 17:22:16

True.


josh803
2021-4-12 17:22:39

He specifies the pointer to int arguments as _int*/null, which I think is supposed to mean it can be a pointer to _int (from ffi) or null (#f).


soegaard2
2021-4-12 17:23:39

Maybe you just need to cast the value to an _int*/null ?


josh803
2021-4-12 17:23:45

So, when I malloc an _int, it’s a pointer to allocated memory. So it should be what’s wanted there, but it dies on the type conversion.


soegaard2
2021-4-12 17:24:34

In the code, I see: (define-cpointer-type _int*) So the cpointers are tagged with their type, there _int*.


josh803
2021-4-12 17:25:15

Maybe I should malloc an _int* instead? But that doesn’t seem to make sense (from what I remember of C) — because it would be a pointer to an int instead of an actual int?


josh803
2021-4-12 17:26:21

Yeah, it doesn’t like that either:


josh803
2021-4-12 17:26:42

Here’s the error:


massung
2021-4-12 17:27:16

I don’t want to distract from the discussion (which is good regardless), but - ./shameless_plug - if you’re having issues with SDL2, you may want to consider the CSFML bindings: https://pkgs.racket-lang.org/package/csfml. I put a lot of effort into them handling all sorts of things for you (like automatically releasing FFI memory when no longer being used).


soegaard2
2021-4-12 17:27:46

Maybe _cpointer/null is useful?


massung
2021-4-12 17:28:04

#f should map to null always in the FFI.


josh803
2021-4-12 17:28:12

Thanks @massung! I actually have that up in another tab (after hearing about the r-cade project)…


josh803
2021-4-12 17:28:53

@soegaard2, I can use #f for null, but in this case, I need to pass in the pointer to the int so that it can load it with the width and height information.


josh803
2021-4-12 17:29:25

So null is not what I want.


soegaard2
2021-4-12 17:30:20

I think, _cpointer/null handles the Racket #f to C null conversion automatically.


soegaard2
2021-4-12 17:35:26

Wait a minute… Isn’t it _ptr the thing you need?


soegaard2
2021-4-12 17:39:41

The code says: (define-cpointer-type _int*) and the documentation of define-cpointer-type says, that it uses _cpointer and _cpointer/null to _int* and _int*/null. Given (define-sdl2 query-texture (_fun _texture* _uint32*/null _int*/null _int*/null _int*/null -> _int)) I think your cpointer needs to be tagged with ’_int*/null.


soegaard2
2021-4-12 17:39:48

Even when it isn’t a null pointer.


massung
2021-4-12 17:45:02

Obviously it’s a 3rd party binding, but @josh803, you may want to try defining your own function here and seeing if you can get what you need that way. The issue is that these are being used as (optional) outputs. The FFI code can handle all of that for you.

This is an example of what I mean from CSFML:

(define-sfml sfRenderWindow_waitEvent (_fun _sfRenderWindow* (e : (_ptr o _sfEvent)) -> (ok : _bool) -> (and ok e))) Notice how the event is an output (the o in (_ptr o _dfEvent)? And the the binding is actually handling all the allocation and even returning of the value for you? In this case, it returns the AND of the boolean return value and whether or not the even was non-null (non-#f), but the binding could just as easily have returned a list or multiple values.

Untested, but you could try something like:

(define-sdl2 query-texture (_fun _texture* _int* _int* (w : (_ptr o _int)) (h : (_ptr o _int)) -> (ok : _int) -> (and (zero? ok) (list w h))) I don’t remember the SDL2 API off-hand, but the above assumes the return value is 0 if successful.


massung
2021-4-12 17:46:08

And I don’t know what those first two _int* parameters are meant to be, I just stuck them in there for consistency


samdphillips
2021-4-12 17:46:22

Running the original program with a fresh raco install --auto gui-widget-mixins crashes on my Mac.


samdphillips
2021-4-12 17:46:47

That’s running from the command line, not in DrRacket


samdphillips
2021-4-12 17:52:19

I would type unsafe- into the search bar and it should turn up all of the documented ones.


soegaard2
2021-4-12 17:53:18

Also version 8.0 cs ?


samdphillips
2021-4-12 17:56:54

Yes


samdphillips
2021-4-12 17:57:14

Catalina 10.15.7


soegaard2
2021-4-12 17:57:41

same here


samdphillips
2021-4-12 17:59:01

Not crashing on DrRacket, but the window was not letting me transfer focus back to Slack.


soegaard2
2021-4-12 17:59:26

I saw that too.


samdphillips
2021-4-12 18:09:05

Crash: $ racket gui-tooltip.rkt objc[12503]: autorelease pool page 0x7ffd2595c000 corrupted magic 0x00000000 0x00000000 0x00000000 0x00000000 should be 0xa1a1a1a1 0x4f545541 0x454c4552 0x21455341 pthread 0x10aadedc0 should be 0x10aadedc0


soegaard2
2021-4-12 18:50:05

I wonder why quadmath doesn’t need to be moved.


rajan.yadav
2021-4-12 19:12:24

I didn’t really had to move quadmath up. However, quadmath then started looking for libgfortran4 (libblas was looking for libgfortran3). So, I had to put both fortran 3&4 versions in libs/ and add another ffi load for it: (define gfortran-lib (case dist [(fedora) (ffi-lib "libgfortran" '("5" #f))] ; Untested [else (ffi-lib "libgfortran" '("3" #f))])) (define gfortran-lib-1 (case dist [(fedora) (ffi-lib "libgfortran" '("5" #f))] ; Untested [else (ffi-lib "libgfortran" '("4" #f))]))


rajan.yadav
2021-4-12 19:13:34

I am hoping it is this messy because I experimented with quite a few library versions - install & uninstall


dan.ml.901
2021-4-13 00:25:11

Has anyone written a for generator that provides the 2 values of a cons cell from an assoc list?


dan.ml.901
2021-4-13 00:25:37

something like: (define items `((a . 1) (b . 2) (c . 3))) (for/list ([(k v) (in-assoc-list items)]) (format "~a: ~a~n" k v))


jaz
2021-4-13 00:29:33

in-dict will do that


dan.ml.901
2021-4-13 00:33:54

Ah, so it will… thanks!


notjack
2021-4-13 01:46:21

note that it will not do it fast


jaz
2021-4-13 02:27:31

True — if speed is a big concern you can do a lot better with make-do-sequence, like: (define (in-alist alist) (make-do-sequence (λ () (values ;; pos->element (λ (xs) (values (caar xs) (cdar xs))) ;; next-pos cdr ;; initial-position alist ;; continue-with-pos? (λ (xs) (not (null? xs))) ;; continue-with-val? #f ;; continue-after-pos+val? #f))))


josh803
2021-4-13 03:20:56

@massung, I was able to modify sdl2’s pretty module like this: ;(define-sdl2 query-texture ; (_fun _texture* _uint32*/null _int*/null _int*/null _int*/null -> _int)) (define-sdl2 query-texture (_fun _texture* (format : (_ptr o _uint32)) (access : (_ptr o _int)) (w : (_ptr o _int)) (h : (_ptr o _int)) -> (ok : _int) -> (and (zero? ok) (list format access w h)))) (The commented out part at the top is the original function we were all looking at.) So now, it’s pretty much as you suggested, except I also added in format and access (because why not, right?). This seems pretty straightforward (now that you’ve explained it and I’ve bashed my head on the docs some more), so I’m not sure why the original author didn’t set it up that way. I certainly didn’t have any luck at all with my attempts to call it directly without the ffi helpers. I guess he may not have needed it for his use case? Or maybe there’s a performance implication I’m not aware of. Apparently “access” is an enum, so this could probably be developed further to be even more informative, but this works and I’m quite done for tonight!


josh803
2021-4-13 03:21:31

@soegaard2, thanks for taking a look and your suggestions as well!


hufangyu123
2021-4-13 04:30:27

@hufangyu123 has joined the channel