New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sitar

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sitar

0.0.1
Rubygems
Version published
Maintainers
1
Created
Source

Sitar

Sitar is easy to use the fiddle.

Build Status

Installation

Add this line to your application's Gemfile:

gem 'sitar'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sitar

Usage

You can used C method only to extend sitar and load shared library like follow:

C function in libsample.so

int add(int a, int b) {
  return a + b;
}

Use in ruby.

module M
  extend Sitar

  load 'libsample.so'
end

M.add(1, 2).ret_i # => 3
  • List of function return type mthod like ret_XXX.
MethodReturn Type in CReturn Type in RubyDescription
callvoidnilNot returned value.
ret_iintIntegerReturned int value.
ret_schar *StringReturn string pointer.
ret_wswchar_t *StringReturn wide char string pointer.
ret_ffloatFloatReturn float value.
ret_ddoubleFloatReturn double value.

Struct

You can easy to use struct by Sitar::Types::StructFactory.

e.g.

module M
  extend Sitar
  extend Sitar::Types::StructFactory

  # struct Car {
  #   int id;
  #   char name[20];
  # };
  define 'Car', ["int id", "char name[20]"]

  # struct Owner {
  #   int seq;
  #   struct Car cars[3];
  # };
  define 'Owner', ["int seq", "Car cars[3]"]

  define_eval(self)
end

M::CAR.malloc

owner = M::OWNER.malloc
# Car cars[3] is expanded like follow:
# struct Owner {
#   int seq;
#   int id_1;
#   char name_1[20];
#   int id_2;
#   char name_2[20];
#   int id_3;
#   char name_3[20];
# }
owner.id_1
owner.name_1

License

The gem is available as open source under the terms of the MIT License.

Author

slowhand0309

FAQs

Package last updated on 28 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts