Code Monkey home page Code Monkey logo

Comments (4)

Dekkonot avatar Dekkonot commented on August 14, 2024

We probably don't want to serialize Archivable to begin with, but I don't want to mark properties unnecessarily as non-serializable, so 2 is the best option IMO.

I think the idea of Roblox deserializing Instance.archivable is really funny though. Under what circumstances would that even come up, ha ha?

from rbx-dom.

Dekkonot avatar Dekkonot commented on August 14, 2024

After giving this a shot, I've ran into a minor hiccup: the way we handle default properties is per-class right now. This means that in order to override a default for an abstract class like Instance, we'd need to override it for every class that inherits from it. That's a much bigger change than I was hoping for due to the nature of Instance.

I don't really have any good ideas to fix this. I have no problem cascading patches down to every inherited class, but it would mean we'd need to be careful with new patches to Instance's defaults since every one would result in a rather large addition to the database.

from rbx-dom.

kennethloeffler avatar kennethloeffler commented on August 14, 2024

It is a little weird how we that information duplicated... but maybe instead of adding the default value patches to all subclasses, we could change the way rbx_binary's serializer finds default properties? e.g., replace this:

class
.default_properties
.get(&canonical_name)

with a call to a function like:

    fn find_default_value(
        database: &'db ReflectionDatabase,
        mut class: &'db ClassDescriptor<'db>,
        canonical_property_name: &str,
    ) -> Option<&'db Variant> {
        loop {
            match class.default_properties.get(canonical_property_name) {
                None => {
                    class = database
                        .classes
                        .get(class.superclass.as_deref()?)
                        .expect("superclass that is Some should exist in reflection database")
                }
                default_value => return default_value,
            }
        }
    }

We wouldn't have to move any existing defaults if we did this (although it's probably a good idea to deduplicate all the defaults in the future), but it would work with the obvious implementation of property default value patches

from rbx-dom.

kennethloeffler avatar kennethloeffler commented on August 14, 2024

Downside: more overhead for inherited properties (especially if we eventually do move default property values into their respective classes), since this does multiple hashmap lookups for each inherited property

from rbx-dom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.