Updated api bootstrap
This commit is contained in:
@@ -9,11 +9,11 @@ use crate::transpiler::MistConfig;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub class Module {
|
||||
pub name String;
|
||||
pub path PathBuf;
|
||||
pub children Vec<Module>;
|
||||
pub String name;
|
||||
pub PathBuf path;
|
||||
pub Vec<Module> children;
|
||||
|
||||
pub constructor(mist_path PathBuf, config *MistConfig) {
|
||||
pub constructor(PathBuf mist_path, MistConfig& config) {
|
||||
self.children = Vec::new();
|
||||
self.name = mist_path.file_stem()
|
||||
.and_then(fn(s) -> s.to_str())
|
||||
@@ -37,7 +37,7 @@ pub class Module {
|
||||
}
|
||||
}
|
||||
|
||||
fn void scan_directory(*mut self, search_dir *Path, config *MistConfig) {
|
||||
void scan_directory(&mut self, Path& search_dir, MistConfig& config) {
|
||||
let entries = match fs::read_dir(search_dir) {
|
||||
Ok(entries) => entries;
|
||||
Err(e) => {
|
||||
@@ -65,11 +65,11 @@ pub class Module {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bool is_package(*self) {
|
||||
pub bool is_package(&self) {
|
||||
self.path.file_name().map(fn(v) -> v.to_str()).unwrap_or_default() == Some("package.mist")
|
||||
}
|
||||
|
||||
pub fn PathBuf output_dir(*self, parent_dir *PathBuf) {
|
||||
pub PathBuf output_dir(&self, PathBuf& parent_dir) {
|
||||
if self.path.is_dir() || self.is_package() {
|
||||
parent_dir.join(&self.name)
|
||||
} else {
|
||||
@@ -77,7 +77,13 @@ pub class Module {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn PathBuf output_path(*self, parent_dir *PathBuf, curr_mod_decl *Option<(mist_parser::ast::Visibility, mist_parser::ast::Identifier)>) {
|
||||
pub PathBuf output_path(&self,
|
||||
PathBuf& parent_dir,
|
||||
Option<(
|
||||
mist_parser::ast::Visibility,
|
||||
mist_parser::ast::Identifier
|
||||
)>& curr_mod_decl
|
||||
) {
|
||||
let name = if let Some((_, name)) = curr_mod_decl {
|
||||
&name.0
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user