Code Monkey home page Code Monkey logo

rustkit's Introduction

RustKit

Fast and ergonomic Rust bindings for ObjC APIs

RustKit is currently under development. Please try it if you want to contribute or provide feedback on the generated bindings.

Prerequisites

Clang 8.0 (currently trunk) with a patch is currently required. Build clang and set the LIBCLANG_PATH environmental variable to the directory that libclang.dylib is in, which should be in the lib directory of your clang/llvm build directory.

Example

extern crate rustkit;

use rustkit::NSObject;

fn main() {
    let obj = NSObject::new();
    
    let desc = NSObject::description();
    let desc = desc.unwrap();
    let desclen = desc.length();
    let ruststr: String =
        (0..desclen).map(|i|
                         std::char::from_u32(desc.characterAtIndex_(i) as u32).
                         unwrap()).collect();
    println!("NSObject::description(): {}", ruststr);
}

rustkit's People

Contributors

michaelwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rustkit's Issues

Status?

Is this project still maintained or dead?

Fails to build

I get

error: failed to run custom build command for `rustkit v0.0.1 (file:///Users/jrmuizel/src/RustKit)`
process didn't exit successfully: `/Users/jrmuizel/src/RustKit/target/debug/build/rustkit-788ef6dab66cb415/build-script-build` (exit code: 101)
--- stdout
unhandled typedef pointing to SChar named __int8_t
unhandled typedef pointing to UChar named __uint8_t
unhandled typedef pointing to Short named __int16_t
unhandled typedef pointing to UShort named __uint16_t
unhandled typedef pointing to Int named __int32_t
unhandled typedef pointing to UInt named __uint32_t
unhandled typedef pointing to LongLong named __int64_t
unhandled typedef pointing to ULongLong named __uint64_t
unhandled typedef pointing to Long named __darwin_intptr_t
unhandled typedef pointing to UInt named __darwin_natural_t
unhandled typedef pointing to Int named __darwin_ct_rune_t
Skipping anonymous record
- Found FieldDecl with name "__mbstate8" ty kind "ConstantArray" []
  - Found IntegerLiteral with name "" ty kind "Int" []
- Found FieldDecl with name "_mbstateL" ty kind "LongLong" []
unhandled typedef pointing to Long named __darwin_ptrdiff_t
unhandled typedef pointing to ULong named __darwin_size_t
unhandled typedef pointing to Int named __darwin_wchar_t
unhandled typedef pointing to Int named __darwin_wint_t
unhandled typedef pointing to ULong named __darwin_clock_t
unhandled typedef pointing to Long named __darwin_ssize_t
unhandled typedef pointing to Long named __darwin_time_t
unhandled typedef pointing to SChar named int8_t
unhandled typedef pointing to Short named int16_t
unhandled typedef pointing to Int named int32_t
unhandled typedef pointing to LongLong named int64_t
unhandled typedef pointing to UChar named u_int8_t
unhandled typedef pointing to UShort named u_int16_t
unhandled typedef pointing to UInt named u_int32_t
unhandled typedef pointing to ULongLong named u_int64_t
unhandled typedef pointing to ULong named uintptr_t
unhandled typedef pointing to UInt named __darwin_fsblkcnt_t
unhandled typedef pointing to UInt named __darwin_fsfilcnt_t
unhandled typedef pointing to ConstantArray named __darwin_uuid_t
unhandled typedef pointing to ConstantArray named __darwin_uuid_string_t
Unhandled type named void (void *) with type kind Unexposed
unhandled typedef pointing to ULong named __darwin_pthread_key_t
unhandled typedef pointing to UChar named u_char
unhandled typedef pointing to UShort named u_short
unhandled typedef pointing to UInt named u_int
unhandled typedef pointing to ULong named u_long
unhandled typedef pointing to UShort named ushort
unhandled typedef pointing to UInt named uint
unhandled typedef pointing to Int named errno_t
unhandled typedef pointing to SChar named BOOL
unhandled typedef pointing to Long named NSInteger
unhandled typedef pointing to ULong named NSUInteger
NSObject

--- stderr
thread 'main' panicked at 'function not loaded: clang_Cursor_getObjCPropertyGetterName', /Users/jrmuizel/.cargo/registry/src/github.com-1ecc6299db9ec823/rustkit-clang-sys-0.24.0/src/lib.rs:1594:1
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Build broken due to duplicate 'new' method generation

Hi, I tried building against the Xcode 11.3 SDK. The build errors out with numerous errors of this kind:

error[E0201]: duplicate definitions with name `new`:
     --> src/RustKit/target/debug/build/rustkit-74ad679636d80c03/out/Foundation.rs:75054:5
      |
75042 | /     pub fn new() -> Arc<Self> {
75043 | |         unsafe {
75044 | |             let send: unsafe extern "C" fn(*mut Object, SelectorRef) -> *mut Self =
75045 | |                 mem::transmute(objc_msgSend as *const u8);
...     |
75052 | |         }
75053 | |     }
      | |_____- previous definition of `new` here
75054 | /     pub fn new() -> Arc<Self> {
75055 | |         unsafe {
75056 | |             let send: unsafe extern "C" fn(*mut Object, SelectorRef) -> *mut Self =
75057 | |                 mem::transmute(objc_msgSend as *const u8);
...     |
75064 | |         }
75065 | |     }
      | |_____^ duplicate definition

I think it is trying to generate the same method for the init and new Objective-C methods, both of which are marked deprecated, by the way.

Appreciate any assistance. Thanks!

Lots of snake_case warnings

e.g.

warning: structure field `decodeTimeStamp` should have a snake case name such as `decode_time_stamp`
     --> /Users/jrmuizel/src/RustKit/target/debug/build/rustkit-aac91a27cd0abb1d/out/CoreMedia.rs:13876:5

feature RK_AppKit, produces aliased parameters

Compiling with feature RK_AppKit

Produces

pub fn renameFontCollectionWithName_visibility_toName_error_(
         name: &NSString,
         visibility: NSFontCollectionVisibility,
         name: &NSString,
         error: Option<&mut &Option<Arc<NSError>>>,
     ) -> bool {

Resulting in
error[E0415]: identifier `name` is bound more than once in this parameter list

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.