Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

A C version of the marshalling code for Mruby

Here is my humble contribution to Mruby, marshalling code written in C.

The current marshalling code for Mruby is written in c++. I am in the process of creating a small-footprint linux environment. One of its prerequisites is that the c++ compiler is not even generated.

The current marshalling code is the only part of Mruby that I use that is written in c++. Furthermore, I had problems with the code in the past, and deeply regretted not being able to easily see what was going on, due to the well-known opaqueness of many c++ colloquialisms.

Having bounced on this problem again yesterday morning, I decided to see if I could write something. As what is inside here (less than 600 lines of C code) has been the result of barely one and a half days' work, I am quite satisfied. The code matches my needs.

The following are marshalled:

  • nil
  • true
  • false
  • integers
  • floating-points
  • strings
  • symbols
  • arrays
  • hashes
  • classes
  • modules
  • objects:
    • if the object defines functions marshal_dump and marshal_load, marshals whatever object is returned from marshal_dump, and restores the object passing to marshal_load that object,
    • otherwise, backs up and restores all instance variables.
  • regular expressions

About regular expressions: I only tested this when using the mruby-onig-regexp gem. If you use another gem, you have to change the class definition at L.32 of base.c, and I am not sure everything will work...

In the directory you find a quick-and-dirty exerciser, that can also be run under Ruby (MRI).

Usage:

Just add a line like this one:

  conf.gem(:github=>'asfluido/mruby-marshal-c')

into your build_config.rb file.

About

A marshal gem for Mruby written in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published