Skip to content

Commit

Permalink
Allow loading reflection database dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekkonot committed Jan 14, 2025
1 parent 359e32f commit e224f9d
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 20 deletions.
46 changes: 37 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ memofs = { version = "0.3.0", path = "crates/memofs" }
# rbx_reflection_database = { path = "../rbx-dom/rbx_reflection_database" }
# rbx_xml = { path = "../rbx-dom/rbx_xml" }

rbx_binary = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "b07a3ec92ced430a2370f8653fd9e112ce930849" }
rbx_dom_weak = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "b07a3ec92ced430a2370f8653fd9e112ce930849" }
rbx_reflection = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "b07a3ec92ced430a2370f8653fd9e112ce930849" }
rbx_reflection_database = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "b07a3ec92ced430a2370f8653fd9e112ce930849" }
rbx_xml = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "b07a3ec92ced430a2370f8653fd9e112ce930849" }
rbx_binary = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "7328ded99e9f076ae6d7efa5cddf83ce0ac503f1" }
rbx_dom_weak = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "7328ded99e9f076ae6d7efa5cddf83ce0ac503f1" }
rbx_reflection = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "7328ded99e9f076ae6d7efa5cddf83ce0ac503f1" }
rbx_reflection_database = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "7328ded99e9f076ae6d7efa5cddf83ce0ac503f1" }
rbx_xml = { git = "https://github.com/UpliftGames/rbx-dom.git", rev = "7328ded99e9f076ae6d7efa5cddf83ce0ac503f1" }

# rbx_binary = "0.7.7"
# rbx_dom_weak = "2.9.0"
Expand Down
6 changes: 3 additions & 3 deletions src/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl UnresolvedValue {
Variant::Enum(rbx_enum) => {
if let Some(property) = descriptor {
if let DataType::Enum(enum_name) = &property.data_type {
let database = rbx_reflection_database::get();
let database = rbx_reflection_database::get().unwrap();
if let Some(enum_descriptor) = database.enums.get(enum_name) {
for (variant_name, id) in &enum_descriptor.items {
if *id == rbx_enum.to_u32() {
Expand Down Expand Up @@ -149,7 +149,7 @@ impl AmbiguousValue {

match &property.data_type {
DataType::Enum(enum_name) => {
let database = rbx_reflection_database::get();
let database = rbx_reflection_database::get().unwrap();

let enum_descriptor = database.enums.get(enum_name).ok_or_else(|| {
format_err!("Unknown enum {}. This is a Rojo bug!", enum_name)
Expand Down Expand Up @@ -287,7 +287,7 @@ fn find_descriptor(
class_name: &str,
prop_name: &str,
) -> Option<&'static PropertyDescriptor<'static>> {
let database = rbx_reflection_database::get();
let database = rbx_reflection_database::get().unwrap();
let mut current_class_name = class_name;

loop {
Expand Down
1 change: 1 addition & 0 deletions src/snapshot_middleware/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn snapshot_lua(
script_type: ScriptType,
) -> anyhow::Result<Option<InstanceSnapshot>> {
let run_context_enums = &rbx_reflection_database::get()
.unwrap()
.enums
.get("RunContext")
.expect("Unable to get RunContext enums!")
Expand Down
2 changes: 1 addition & 1 deletion src/snapshot_middleware/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ fn infer_class_name(name: &str, parent_class: Option<&str>) -> Option<Ustr> {
// Members of DataModel with names that match known services are
// probably supposed to be those services.

let descriptor = rbx_reflection_database::get().classes.get(name)?;
let descriptor = rbx_reflection_database::get().unwrap().classes.get(name)?;

if descriptor.tags.contains(&ClassTag::Service) {
return Some(ustr(name));
Expand Down
1 change: 1 addition & 0 deletions src/syncback/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fn hash_inst_prefilled<'inst>(
prop_list.sort_unstable_by_key(|(name, _)| *name);

let descriptor = rbx_reflection_database::get()
.unwrap()
.classes
.get(inst.class.as_str());

Expand Down
2 changes: 1 addition & 1 deletion src/syncback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ fn get_property_filter(project: &Project, new_inst: &Instance) -> Option<HashSet
let filter = &project.syncback_rules.as_ref()?.ignore_properties;
let mut set = HashSet::new();

let database = rbx_reflection_database::get();
let database = rbx_reflection_database::get().unwrap();
let mut current_class_name = new_inst.class;

loop {
Expand Down
3 changes: 2 additions & 1 deletion src/syncback/property_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn filter_properties_preallocated<'inst>(
.unwrap_or(true);

let class_data = rbx_reflection_database::get()
.unwrap()
.classes
.get(inst.class.as_str());

Expand Down Expand Up @@ -79,7 +80,7 @@ pub fn filter_properties_preallocated<'inst>(
}

fn should_property_serialize(class_name: Ustr, prop_name: Ustr) -> bool {
let database = rbx_reflection_database::get();
let database = rbx_reflection_database::get().unwrap();
let mut current_class_name = class_name;

loop {
Expand Down
7 changes: 7 additions & 0 deletions src/web/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ impl UiService {
humantime::format_duration(elapsed).to_string()
};

let database = rbx_reflection_database::get().unwrap();
let database_version = format!(
"{}.{}.{}.{}",
database.version[0], database.version[1], database.version[2], database.version[3],
);
Self::page(html! {
<div class="root">
<header class="header">
Expand All @@ -249,6 +254,8 @@ impl UiService {
</a>
<div class="stats">
{ Self::stat_item("Server Version", SERVER_VERSION) }
{ Self::stat_item("Reflection Database", database_version)}
{ Self::stat_item("Local Database", rbx_reflection_database::get_local().unwrap().is_some().to_string())}
{ Self::stat_item("Project", project_name) }
{ Self::stat_item("Server Uptime", uptime) }
</div>
Expand Down

0 comments on commit e224f9d

Please sign in to comment.