01:20
Blukunfando has quit [Ping timeout: 240 seconds]
07:55
mtsd has joined #picolisp
07:55
orivej has quit [Ping timeout: 272 seconds]
08:07
orivej has joined #picolisp
08:58
orivej_ has joined #picolisp
08:58
orivej has quit [Ping timeout: 272 seconds]
09:21
mtsd has quit [Quit: Leaving]
10:47
<
aw- >
Regenaxer: here?
10:48
<
Regenaxer >
Hi aw- :)
10:48
<
aw- >
i'm trying to figure out something strange with C/native
10:49
<
aw- >
i use (struct P '(B . 8)) to extract a structure but it always gives strange values
10:49
<
aw- >
whereas when i use (struct P '(S)) then i get a string
10:50
<
aw- >
(B . 8) gets me a list with 8 integers, but they always change
10:50
<
Regenaxer >
(struct P 'S) should give the string
10:51
<
Regenaxer >
if P points to it
10:51
<
aw- >
it doesnt.. i have to use '(S)
10:51
<
aw- >
(struct P '(S))
10:51
<
Regenaxer >
then you have a pointer at P
10:51
<
Regenaxer >
and '(B . 8) gives the bytes of the
*pointer*
10:52
<
aw- >
yes that makes sense
10:52
<
Regenaxer >
Is it pil21?
10:52
<
Regenaxer >
cause 'S was not supported iirc
10:52
<
aw- >
ugh.. i'm still reading (native) docs for pil64.. maybe i'll switch it now
10:53
<
Regenaxer >
yeah, it is not public yet
10:53
<
Regenaxer >
I use (doc 'native) in the repl, this works
10:53
<
aw- >
i usually load them locally
10:53
<
aw- >
so if I get a pointer, then I need to extract the pointer?
10:54
<
Regenaxer >
hmm, does '((B . 8)) work?
10:54
<
Regenaxer >
I don't remember
10:54
<
aw- >
still random numbers
10:57
<
Regenaxer >
you have do inderect the pointer first
10:57
<
Regenaxer >
(struct P '(P))
10:57
<
Regenaxer >
so this should work:
10:57
<
Regenaxer >
(struct (struct P '(P)) '(B . ...
10:58
<
Regenaxer >
(struct (struct P 'P) '(B . ...
10:58
<
Regenaxer >
I think ;)
10:58
<
Regenaxer >
or (val (adr P))
10:58
<
Regenaxer >
(struct (val (adr P)) '(B .
10:59
<
Regenaxer >
val (adr is probably more efficient
11:46
<
aw- >
ok i'll try that
12:03
Blukunfando has joined #picolisp
12:42
<
aw- >
Regenaxer: need to update native.html as well
12:42
<
aw- >
under '<p>Examples for function calls, with their corresponding C prototypes:'
12:43
orivej_ has quit [Ping timeout: 256 seconds]
12:43
<
Regenaxer >
Ah, ok, thanks!
12:44
<
Regenaxer >
hmm, it is I think
12:44
<
Regenaxer >
(native "lib.so" "fun" 'P)
12:44
<
Regenaxer >
in pil21/doc
12:45
<
Regenaxer >
in pil64 it was 'N
14:24
<
aw- >
(adr P) segfaults
14:25
<
Regenaxer >
I don't think so. It is probably 'val'
14:26
<
Regenaxer >
adr does not access memory
14:26
<
Regenaxer >
Don't try (val (adr P))
14:26
<
Regenaxer >
it is
*not* a Lisp expression
14:26
<
Regenaxer >
the repl tries to print after ->
14:27
<
Regenaxer >
So it is also not good to pass to 'struct'
14:27
<
aw- >
(struct (val (adr P)) '(B . 8))
14:27
<
Regenaxer >
same reason
14:27
<
Regenaxer >
also not good to pass to 'struct'
14:28
<
Regenaxer >
yes, a quick and dirty shortcut
14:28
<
Regenaxer >
wrong idea
14:28
<
Regenaxer >
stay with the first one
14:28
<
Regenaxer >
(struct (struct P '(P)) '(B . ...
14:28
<
Regenaxer >
I thought to avoid the inner 'struct'
14:29
<
Regenaxer >
I don't see a simpler way atm
14:30
<
Regenaxer >
double indirection
14:30
<
Regenaxer >
you have a 'S' pointer
14:30
<
Regenaxer >
but want bytes
14:30
<
aw- >
but it's really just a pointer in a C struct
14:30
<
Regenaxer >
a pointer to
*another* struct
14:31
<
Regenaxer >
a string is an array of bytes
14:31
<
aw- >
maybe i should change the definition
14:31
<
Regenaxer >
in a separate memory area
14:31
<
Regenaxer >
Why do you need bytes (I asked already ;)?
14:31
<
aw- >
i'm just trying things
14:31
<
aw- >
proof-of-concept
14:31
<
Regenaxer >
(chop (struct 'S)) better
14:32
<
aw- >
that doesn't work with multibyte strings
14:32
<
Regenaxer >
What is a multibyte string?
14:33
<
Regenaxer >
this is a multi-byte
*character*
14:33
<
aw- >
yes yes that's what i mean
14:33
<
Regenaxer >
'chop' works good
14:33
<
Regenaxer >
(chop "東京")
14:34
<
Regenaxer >
multi-char
14:34
<
Regenaxer >
the bytes are not useful usually
14:34
<
Regenaxer >
it is characters
14:34
<
aw- >
yeah.. it's fine.. this discussion is just going in circles. Sorry, let's just forget it
15:49
emacsomancer has quit [Quit: WeeChat 2.9]
15:51
emacsomancer has joined #picolisp
15:54
orivej has joined #picolisp
16:00
<
beneroth >
sounds like aw- talked about C++ wide characters?
16:00
<
Regenaxer >
I think it is UTF-8
16:01
<
Regenaxer >
He wants to process them byte-wise
16:01
<
Regenaxer >
(but doesn't tell us his secret ;)
16:01
<
Regenaxer >
(but doesn't tell us his secret plans ;)
16:36
<
Regenaxer >
Switching this IRC client to pil21 now ...
16:36
Regenaxer has left #picolisp [#picolisp]
16:37
Regenaxer has joined #picolisp
16:37
<
Regenaxer >
OK, let's see if all works as before
17:04
<
beneroth >
Regenaxer, I think you might be wrong about UTF-8. because C/C++ has no notion of UTF-8 (or well, many different ones, every library coming with another string type...)
17:05
<
beneroth >
but even when it is UTF-8, there are cases where such stuff needs to be handled byte-wise, to ensure and check (security) message sizes etc.
17:05
<
beneroth >
to deal with untrusted client/peer
17:06
<
beneroth >
of course if the interface/input/user can be trusted, then your approaches are way easier, more efficient and better.
17:06
<
beneroth >
but as soon as you need to interface with foreign software this is not to be guaranteed anymore
17:19
<
Regenaxer >
But aw- asked several times how to convert unicode to utf8 bytes