Beispiel #1
0
Encoding* Encoding::from_index(STATE, int index) {
    if(Encoding* enc = try_as<Encoding>(encoding_list(state)->get(state, index))) {
        return enc;
    } else {
        return nil<Encoding>();
    }
}
Beispiel #2
0
  Encoding* Encoding::alias(STATE, const char* name, const char* original) {
    int index = find_index(state, original);
    if(index < 0) return nil<Encoding>();

    Tuple* ref = encoding_reference(state, index, name);
    encoding_map(state)->store(state, encoding_symbol(state, name), ref);
    add_constant(state, name, from_index(state, index));

    return as<Encoding>(encoding_list(state)->get(state, index));
  }
Beispiel #3
0
  Encoding* Encoding::create_bootstrap(STATE, const char* name,
                                       Index index, OnigEncodingType* enc)
  {
    Encoding* e = create(state, enc);
    Tuple* ref = encoding_reference(state, index);
    encoding_map(state)->store(state, encoding_symbol(state, name), ref);
    encoding_list(state)->set(state, index, e);
    add_constant(state, name, e);

    return e;
  }
Beispiel #4
0
  Encoding* Encoding::define(STATE, const char* name,
                             OnigEncodingType* enc, Object* dummy)
  {
    Encoding* e = create(state, enc, dummy);

    e->name(state, String::create(state, name));

    Array* list = encoding_list(state);
    size_t index = list->size();

    Tuple* ref = encoding_reference(state, index);
    encoding_map(state)->store(state, encoding_symbol(state, name), ref);
    list->set(state, index, e);
    add_constant(state, name, e);

    return e;
  }
Beispiel #5
0
 Encoding* Encoding::find(STATE, const char* name) {
   int index = find_index(state, name);
   if(index < 0) return nil<Encoding>();
   return as<Encoding>(encoding_list(state)->get(state, index));
 }
Beispiel #6
0
 Encoding* Encoding::ascii8bit_encoding(STATE) {
   return as<Encoding>(encoding_list(state)->get(state, eBinary));
 }
Beispiel #7
0
 Encoding* Encoding::utf8_encoding(STATE) {
   return as<Encoding>(encoding_list(state)->get(state, eUtf8));
 }
Beispiel #8
0
 Encoding* Encoding::usascii_encoding(STATE) {
   return as<Encoding>(encoding_list(state)->get(state, eAscii));
 }