Skip to content

Commit

Permalink
move to mln namespace, debug enum
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Feb 9, 2025
1 parent 5c7045b commit da15a2e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
7 changes: 4 additions & 3 deletions platform/rust/build_support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ pub fn parse_deps(deps_contents: &str, static_lib_base: &Path, include_args: boo
let mut added_search_paths = HashSet::new();
let mut token_iter = deps_contents.split_whitespace().peekable();

instructions.push(format!(
"cargo::warning=debugging cmake string = {deps_contents}"
));
// FIXME: For debugging - need to figure out why tests do not compile
// instructions.push(format!(
// "cargo::warning=debugging cmake string = {deps_contents}"
// ));

while let Some(token) = token_iter.next() {
if token == "-framework" {
Expand Down
4 changes: 2 additions & 2 deletions platform/rust/include/map_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <vector>
#include <stdexcept>

namespace ml {
namespace mln {
namespace bridge {

class MapRenderer {
Expand Down Expand Up @@ -83,4 +83,4 @@ inline void MapRenderer_setStyleUrl(MapRenderer& self, const rust::Str url) {
}

} // namespace bridge
} // namespace ml
} // namespace mln
4 changes: 2 additions & 2 deletions platform/rust/include/tile_server_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "rust/cxx.h"
#include "mbgl/util/tile_server_options.hpp"

namespace ml {
namespace mln {
namespace bridge {

using namespace mbgl;
Expand Down Expand Up @@ -100,4 +100,4 @@ inline void TileServerOptions_withDefaultStyle(TileServerOptions& self, const ru
}

} // namespace bridge
} // namespace ml
} // namespace mln
24 changes: 19 additions & 5 deletions platform/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,42 @@ mod tile_server_options;
pub use map_renderer::{Image, ImageRenderer, ImageRendererOptions, Static, Tile};
pub use tile_server_options::TileServerOptions;

#[cxx::bridge(namespace = "ml::bridge")]
#[cxx::bridge(namespace = "mln::bridge")]
mod ffi {
// CXX validates this type against the C++ definition during compilation
//
// CXX validates enum types against the C++ definition during compilation
//

#[repr(u32)]
enum MapMode {
Continuous,
Static,
Tile,
}

#[repr(u32)]
enum MapDebugOptions {
NoDebug = 0,
TileBorders = 0b0000_0010, // 1 << 1
ParseStatus = 0b0000_0100, // 1 << 2
Timestamps = 0b0000_1000, // 1 << 3
Collision = 0b0001_0000, // 1 << 4
Overdraw = 0b0010_0000, // 1 << 5
StencilClip = 0b0100_0000, // 1 << 6
DepthBuffer = 0b1000_0000, // 1 << 7
}

#[namespace = "mbgl"]
unsafe extern "C++" {
include!("mbgl/map/mode.hpp");

#[namespace = "mbgl"]
type MapMode;
type MapDebugOptions;
}

unsafe extern "C++" {
include!("maplibre-native/include/tile_server_options.h");

#[namespace = "mbgl"]
type TileServerOptions;

fn TileServerOptions_new() -> UniquePtr<TileServerOptions>;
Expand Down Expand Up @@ -106,7 +121,6 @@ mod ffi {
unsafe extern "C++" {
include!("maplibre-native/include/map_renderer.h");

#[namespace = "ml::bridge"]
type MapRenderer;

fn MapRenderer_new() -> UniquePtr<MapRenderer>;
Expand Down
4 changes: 2 additions & 2 deletions platform/rust/src/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "maplibre-native/include/map_renderer.h"
#include "maplibre-native/src/lib.rs.h"

namespace ml {
namespace mln {
namespace bridge {

std::string MapRenderer::render() {
Expand Down Expand Up @@ -39,4 +39,4 @@ std::string MapRenderer::render() {
}

} // namespace bridge
} // namespace ml
} // namespace mln

0 comments on commit da15a2e

Please sign in to comment.