Thread: help with binary strings?

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    3

    help with binary strings?

    Hey all, Sorry for the burden but you might as well welcome another C newb. Dah.

    Anyway, I'm extending the Ruby language and defining a new Ruby object(AMFSerializer). I'm going to be able to pass Ruby values to methods on that Ruby object.. that in the C code implement the functionality.

    What its doing is passing Ruby values and serializing those values into a binary AMF form. AMF is for the Flash player object format. I don't have a problem understanding the Ruby C API. More or less what I'm having troubles with is finding everything needed to do this with C.. I haven't written a lick of C so I need a little push in the right direction is all. With some more questions here and there..

    So I guess here is the first question::

    if I take a ruby value into a C function:

    Code:
    static VALUE write_amf3_string(VALUE self, VALUE str)
    {
      //where do I get an api for writing binary value to strings?
    }
    hmmmmm.
    Thanks

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    You'll have to write the simple function yourself. Exactly what kind of value is self? How is VALUE defined?
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    3
    VALUE represents any ruby object. "VALUE str" would be a ruby string. I realize I have to write one myself. Is there C libraries or something I need to use? I guess i'm just lost not knowing any C. dah.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    3
    Quote Originally Posted by Salem View Post
    Thanks for that. I do understand the Ruby C API. I just don't know enough C. Everything is so easy with high level languages. I get to C and go, huh? Ha

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    So what you should be doing is approaching the problem from the other end.

    Start by going through some of the tutorials on this site, then asking questions about them when you get stuck.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 11-04-2006, 11:07 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  3. Problems with strings as key in STL maps
    By all_names_taken in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:34 AM
  4. Strings and binary
    By Flip in forum C++ Programming
    Replies: 13
    Last Post: 12-04-2005, 01:12 PM
  5. Array, Linked List, or Binary Tree?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 01-05-2002, 10:07 PM