-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardized geometries and unsigned dimensions #2331
Conversation
797f8a3
to
2820f7a
Compare
Sorry I have not been following the project. (busy with work and my own projects) https://docs.python.org/3/c-api/arg.html#numbers All the PS. I did not expect this project API to change so rapidly when I first joined. (usually breaking changes are reserved for x.0.0 major versions) |
.nodnod, we're doing the 3.0.0 release in two weeks, and all of this is prep for that move to abi3. |
alright, i just converted all the python, and i eliminated all compiler warnings earlier today. let's see if we get green builds... |
b6eb461
to
e10a8fb
Compare
136 files changed, jesus |
5e2c632
to
cac98ed
Compare
alright, everything looks about as good as it's going to look, i suspect. are we doing this? |
cac98ed
to
2c67da9
Compare
so the only real question is whether we want to cut a 2.4.9 before merging this. once it's merged, i think a 2.4.9 is largely impossible, and we ought plow ahead to 3.0.0 ASAP. the only downside of cutting a 2.4.9 now would be the earlier unsigned work. maybe i ought make a branch from right before that, and cherry-pick a few things? hrmmm. |
i made a branch |
fire in the hole! |
any chance to change the type of |
probably. you don't want |
also it would probably be |
done in |
Mmmm I really meant "an unsigned large enough to hold a pointer" thinking on the equivalent to rust's But this particular type translation is somewhat confusing and I'm see a couple of problems. Currently the type definition of size_t coming from bindgen is a cty::c_ulong which is a u64. pub type size_t = cty::c_ulong; in cty: pub type c_ulong = u64; but in cty, a size_t is a usize! pub type size_t = usize; Also look at this rust-lang/rust-bindgen#1903 Maybe updating our version of bindgen (from 0.57) would help this (not sure) but I think we couldn't update yet because higher versions where not available on certain platforms/distributions? For now I'm gonna go with how things are right now, and try to make it work without any more changes. |
More background:
After reading some discussions I've enabled the option |
an index into an array is not a pointer; the array itself is the pointer, and the index is...an index. multiplied by the size of the data being pointed to, it is an offset. arrays and pointers as arguments in C are pretty much the same thing. you never copy an array as an argument, so char a[5];
foo(a); is only passing a
i would write void foo(char* crap); or void foo(const char* crap) i could also unidiomatically write: void foo(const char crap[]); but people would look at me weirdly. remember -- C supports only one parameter-passing mechanism, call by value. if i want to change the value in my external scope, i must pass a pointer. so if i have unsigned foo;
bar(foo);
unsigned foo;
bar(&foo); together with void bar(unsigned* qux); i can now modify
void quuux_good(size_t* arp){
*arp = 5;
}
void quuux_bad(uintptr_t arp){
*(size_t *)arp = 5;
}
size_t vroom;
quuux_good(&vroom);
quuux_bad((uintptr_t)&vroom); but the latter throws away just about all type information, losing you performance and safety, and requiring casts all over the place, which are very much to be avoided. |
you might want a |
that guy in bindgen #1903 seems a bit confused as to the relationship of |
https://en.cppreference.com/w/c/types/size_t
https://en.cppreference.com/w/cpp/types/integer
i don't understand why https://internals.rust-lang.org/t/pre-rfc-usize-is-not-size-t/15369 seems to conflate int a;
int b;
int* pa = &a;
int* pb = &b;
ptrdiff_t d = pa - pb; this is illegal. |
https://en.cppreference.com/w/cpp/types/ptrdiff_t
|
basically just about every correct C program in the world makes use of |
Ok. I see. I'm grateful Rust just uses an
funny how culture goes. I like that one better because it gives more information of intent.
maybe you want to leave them a msg with your perspective? Thanks for all the awesome insider info about C nick! |
how so? i cannot think of any way in which it does. btw since c99 you can use |
by using one syntax to indicate an array is expected, and the other one to indicate a single value is expected? that's what I was thinking anyway |
As discussed in #1696, #2324, and #2320, the default semantics for arguments are now:
Furthermore, most dimensions are now unsigned, whether return values or parameters, fulfilling one of @joseluis's dreams as old as time. There might be further conversions of this nature.
Remove recursion from
ncplane_polyfill_yx()
just as we didncvisual_polyfill_yx()
a few days ago, to defend against small stacks.Use
ncmetric()
in the HUD ofnotcurses-demo
.This is a tremendous amount of churn. I think it improves things overall, but goddamn, there are something like a hundred files touched here. The
NOTES
update is almost certainly incomplete. I probably missed a function or two for conversion. I would be shocked if I have not introduced at least three subtle bugs with this PR. Please give it a scan, watching for things like copy-and-paste bugs etc.@igo95862 , I still need to convert the python. If you could get to it, that would be awesome; if not, I'll handle it. There are still a great many compiler warnings being issued which I must remedy before merging.