Skip to content

Commit

Permalink
std::sys: use integrated Jule as much as possible instead of C++ linking
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 24, 2024
1 parent e44eefb commit 889405f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
21 changes: 0 additions & 21 deletions std/sys/syscall_unix.hpp

This file was deleted.

12 changes: 3 additions & 9 deletions std/sys/syscall_unix.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@
// Use of this source code is governed by a BSD 3-Clause
// license that can be found in the LICENSE file.

use std::jule::integrated::{Char}
use integ for std::jule::integrated::{Char}

cpp use "<dirent.h>"
cpp use "<fcntl.h>"
cpp use "<unistd.h>"

cpp use "syscall_unix.hpp"

#typedef
cpp struct DIR{}

cpp struct dirent {
pub d_name: *Char
}

// This function actually equals to stat,
// just interface to ignore identifier already exist error of compiler.
cpp unsafe fn __jule_stat(path: *Char, mut handle: *cpp.stat): int

cpp unsafe fn opendir(path: *Char): *cpp.DIR
cpp unsafe fn closedir(mut dir: *cpp.DIR): int
cpp unsafe fn readdir(mut dir: *cpp.DIR): *cpp.dirent
Expand All @@ -38,13 +32,13 @@ pub type Dir: cpp.DIR
// C's dirent.
pub type Dirent: cpp.dirent

pub static STDIN: uintptr = 0
pub static STDIN: uintptr = 0
pub static STDOUT: uintptr = 1
pub static STDERR: uintptr = 2

// Calls C's stat function.
pub unsafe fn stat(path: *byte, mut stat: *Stat): int {
ret cpp.__jule_stat((*Char)(path), stat)
ret integ::emit[int]("stat({}, {})", (*Char)(path), stat)
}

// Wrapper for C's open function.
Expand Down

0 comments on commit 889405f

Please sign in to comment.