Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Feb 4, 2025
1 parent 07041ff commit 157f6aa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions platform/rust/include/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "mbgl/util/tile_server_options.hpp"

namespace ml {
namespace rust {
namespace bridge {

uint32_t get_42();

Expand All @@ -24,5 +24,5 @@ const int8_t* TileServerOptions_spritesVersionPrefix(const TileServerOptions& se
const int8_t* TileServerOptions_glyphsVersionPrefix(const TileServerOptions& self);
const int8_t* TileServerOptions_tileVersionPrefix(const TileServerOptions& self);

} // namespace rust
} // namespace bridge
} // namespace ml
8 changes: 6 additions & 2 deletions platform/rust/src/bin/render.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use clap::Parser;
use maplibre_native::TileServerOptions;

/// MapLibre Native render tool
#[derive(Parser, Debug)]
Expand Down Expand Up @@ -69,7 +70,10 @@ struct Args {
}

fn main() {
let args = Args::parse();
// let args = Args::parse();
// println!("Parsed arguments: {:?}", args);

println!("Parsed arguments: {:?}", args);
let s = TileServerOptions::default_maplibre();
let val = s.source_version_prefix();
println!("Parsed arguments: {:?}", val);
}
8 changes: 4 additions & 4 deletions platform/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt::Debug;

use cxx::UniquePtr;

#[cxx::bridge(namespace = "ml::rust")]
#[cxx::bridge(namespace = "ml::bridge")]
mod ffi {
// C++ types exposed to Rust.
unsafe extern "C++" {
Expand All @@ -19,7 +19,7 @@ mod ffi {
#[namespace = "mbgl::util"]
pub fn ceil_log2(x: u64) -> u32;

// A function defined in the C++ rust wrapper rather than the core lib.
// A function defined in the C++ Rust wrapper rather than the core lib.
pub fn get_42() -> u32;

#[namespace = "mbgl"]
Expand Down Expand Up @@ -314,7 +314,7 @@ mod tests {
source_template: "/{domain}.json",
source_domain_name: "",
source_version_prefix: Some(
"0\xe9\x9f",
"/v4",
),
style_template: "/styles/v1{path}",
style_domain_name: "styles",
Expand All @@ -328,7 +328,7 @@ mod tests {
tile_template: "{path}",
tile_domain_name: "tiles",
tile_version_prefix: Some(
"0\xe9\x9f",
"/v4",
),
api_key_parameter_name: "access_token",
requires_api_key: true,
Expand Down
14 changes: 7 additions & 7 deletions platform/rust/src/wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "maplibre-native/src/lib.rs.h"

namespace ml {
namespace rust {
namespace bridge {

uint32_t get_42() {
return 42;
Expand All @@ -24,25 +24,25 @@ std::unique_ptr<TileServerOptions> TileServerOptions_maptiler() {
// FIXME: there should be a helper function to convert std::optional<std::string> to const int8_t *

const int8_t * TileServerOptions_sourceVersionPrefix(const TileServerOptions& self) {
auto v = self.sourceVersionPrefix();
auto const &v = self.sourceVersionPrefix();
return (const int8_t *)(v.has_value() ? v->c_str() : nullptr);
}
const int8_t * TileServerOptions_styleVersionPrefix(const TileServerOptions& self) {
auto v = self.styleVersionPrefix();
auto const &v = self.styleVersionPrefix();
return (const int8_t *)(v.has_value() ? v->c_str() : nullptr);
}
const int8_t * TileServerOptions_spritesVersionPrefix(const TileServerOptions& self) {
auto v = self.spritesVersionPrefix();
auto const &v = self.spritesVersionPrefix();
return (const int8_t *)(v.has_value() ? v->c_str() : nullptr);
}
const int8_t * TileServerOptions_glyphsVersionPrefix(const TileServerOptions& self) {
auto v = self.glyphsVersionPrefix();
auto const &v = self.glyphsVersionPrefix();
return (const int8_t *)(v.has_value() ? v->c_str() : nullptr);
}
const int8_t * TileServerOptions_tileVersionPrefix(const TileServerOptions& self) {
auto v = self.tileVersionPrefix();
auto const &v = self.tileVersionPrefix();
return (const int8_t *)(v.has_value() ? v->c_str() : nullptr);
}

} // namespace rust
} // namespace bridge
} // namespace ml

0 comments on commit 157f6aa

Please sign in to comment.