wash

          programming ruby 2nd--extending ruby 1

          1.Ruby Object? in c
          2.juke box extension
          3.memory allocation
          4.ruby type system
          5.create an exception
          6embed a ruby interpreter
          7.bridge to other language
          8.c api
          1.
          p269
          Sometimes, though, life is more complicated. Perhaps you want to define a global variable
          whose valuemust be calculated when it is accessed. You do this by defining hooked
          and virtual variables. A hooked variable is a real variable that is initialized by a named
          function when the corresponding Ruby variable is accessed. Virtual variables are similar
          but are never stored: their value purely comes from evaluating the hook function.
          See the API section that begins on page 294 for details.
          If you create a Ruby object from C and store it in a C global variable without exporting
          it to Ruby, you must at least tell the garbage collector about it, lest ye be reaped
          inadvertently.
          static VALUE obj;
          // ...
          obj = rb_ary_new();
          rb_global_variable(obj);

          posted on 2006-06-15 14:53 wash 閱讀(262) 評論(0)  編輯  收藏 所屬分類: ruby rails

          主站蜘蛛池模板: 卢龙县| 宁海县| 定日县| 沅陵县| 南阳市| 社旗县| 庆城县| 宝清县| 项城市| 南充市| 榆林市| 当涂县| 安乡县| 梓潼县| 咸丰县| 屯昌县| 桂东县| 延津县| 开原市| 太湖县| 迁西县| 东乡| 鄯善县| 林芝县| 潼南县| 来安县| 曲周县| 阳东县| 航空| 南安市| 崇信县| 安阳市| 金塔县| 衡水市| 平乡县| 益阳市| 大埔县| 巴青县| 巧家县| 元谋县| 思茅市|