add support for the simpler functions in Xresources.h#5
Conversation
|
Hi, thanks for the contribution!
|
|
Thanks for the quick reply. To your points:
I'm not sure I follow you here; it is required, (and is implemented). |
|
Let me elaborate a bit on So, I came up with a cache of objects in the Display, so that any time the typemap is trying to wrap a pointer, it checks the Display object's cache to see if that pointer was already wrapped. To make things a little more flexible I decided that I would represent the objects with a blessed hashref and then attach the C pointer with Magic. That gives me the option to store my own attributes in the object, like a flag whether the perl object should be in charge of freeing it. I managed to wrap up most of that in a reusable function. For the x resource managers, it is almost the same, but the pool of objects would need to be global instead of associated per-display. Most of the code can probably be re-used, and just need to add some kind of flag to tell it to look in the global pool. If you use a hashref for the objects, you could then add a flag that tracks whether it needs freed or not. Then you could set or unset that flag depending on which API calls the user makes. |
|
For the other points:
|
I think we're on the same page with this; I've implemented this.
I haven't had time to look through this yet.
That was exactly the problem. Thanks for the suggestion.
The initialization it performs is really minor. It creates a couple of entries in a hash table for fast string lookup, so the first time it is called there are some minor allocations, but after that calling it again is essentially a no-op. One approach may be to have it run from |
|
I completely reworked the way Xlib objects get their Magic assigned. Now they all get a struct of fields attached and we can add fields as needed. The objects no longer need to be associated with a Display, and there is a more generic "dependency" concept where if a parent C-level object becomes invalid, all the dependent C-level pointers get set to NULL and their host objects can reliably handle what to do about that. (such as if a Resource manager was attached to the life of a Display* connection) |
|
Is this PR still applicable given that structural change? |
I can't answer to that, but I'm no longer working on the project this was attached to, so am not able to provide any resources on this going forward. |
|
As I remember, the XResources API requires some awkward memory management, and would take a bit of effort to really ensure that the wrapped API wasn't going to leak things or crash. Meanwhile, the concept behind XResources is basically just a serializable Hashref, and could more ideally be implemented in pure perl. (unless there's some function somewhere that specifically requires an XResources pointer and does something nontrivial with it, which there could be) I hate to let the work here go to waste, but I don't really have time or motivation for it either, yet. I was just going to leave it here for whoever needs the feature next to pick up where we left off. |
This PR adds support for the more straightforward X resource manager functions in Xresources.h.
It doesn't expose the Quark versions of the functions, or the enumeration capability.
It adds new test dependencies on Test::TempDir::Tiny as well as a version of Test:::More which supports
subtest(which has been around for a while!).I've tested it on Perl 5.10.1 and 5.30.0.