jwharm / java-gi

GObject-Introspection bindings generator for Java
GNU Lesser General Public License v2.1
84 stars 7 forks source link

Implement instance cache #51

Closed jwharm closed 1 year ago

jwharm commented 1 year ago

Add an InstanceCache class that saves a mapping of memory addresses with proxy object instances in a HashMap. Expired entries are removed with toggle references.

This also removes the fromAddress method from the generated class definitions. Proxy objects can now simply be instantiated with InstanceCache.get(address, fallbackConstructor) or if you don't want to have a cached object, simply with the default MemoryAddress constructor in the proxy class.