Quote:
Originally Posted by rhelgeby
This stuff looks interesting. Imagine if we can create dynamic objects based on a JSON Schema and then parse a JSON file with validation. I tried to do something similar to this with plain keyvalue files, before the transitional syntax was announced.
|
Currently Dynamic can read\write Flat Configs and KeyValues.
I could write a JSON interpreter, it's little trickier reading JSON compared to KeyValues.
Quote:
Originally Posted by rhelgeby
I'm concerned about crashing plugins. Will this also result in memory leaks? Say a plugin creates several objects and then for some reason crashes. Then it can't dispose those objects. I suppose the Dynamic plugin could track which plugin that owns each object and watch if a plugin is unloaded and automatically dispose it.[/PHP][/SPOILER]
|
Very good concern.
I know that a plugins handle is parsed through a natives callback parameters. I figure I would need a way to check if a plugins handle is still valid (the plugin is loaded and running) and to find the best hook where I can iterate the object collection and Dispose objects owned by the terminated plugin.
I might focus on this sooner rather than later.
Quote:
Originally Posted by rhelgeby
I was just experimenting with methodmaps myself and did make a simple "class" based on StringMap. This is static objects, but my simple benchmarks shows that it reads a property/key in 70-110 nanoseconds, so it's pretty fast.
|
Funny that, I just made this a few days ago for basic storage.
Before writing any code for Dynamic I had carefully planned out what I was looking to achieve. One key feature I wanted was type conversion. Using a Trie/StringMap didn't meet the criteria as it doesn't store type information (like the rest of sourcepawn). After lots of different methods the fastest method I've currently found is to use a StringMap to store an offset to the position in the array where the members data is stored. The offset cell is the members type, and the following cell(s) are the members data.
This means regardless of type usage (Get/Set Int/Float/Bool/String), Dynamic reads the actual datatype at the offset and then converts the result if required to the requested type.
I've also implemented type discovery which can read an input string and determine a safe storage type. This is used with ReadConfig/KeyValues to prevent all member types from being stored as string's internally.
So quickly going back to your JSON question. I don't believe Dynamic will require a schema as Dynamic will store member data based on it's discovered type and can safely convert any types on Get/Set if required.
Edit: I just implemented some
basic garbage collection for objects owned by terminated plugins. If you know a better way to implement this (eg: a forward/hook for terminating plugins) let me know.
__________________