commit 8afa6355db522255e2d9a8e9471e6d874e84a1f0
Author: Mark Glines <mark@glines.org>
Date: Sun Feb 8 09:23:09 2009 -0800
Split the labeling of charsets and encodings until after the init functions have been called.
diff --git a/include/parrot/encoding.h b/include/parrot/encoding.h
index 55118db..3c70ae0 100644
|
a
|
b
|
|
| 152 | 152 | __attribute__nonnull__(3); |
| 153 | 153 | |
| 154 | 154 | void parrot_deinit_encodings(void); |
| 155 | | void parrot_init_encodings_2(void); |
| | 155 | void Parrot_str_internal_register_encoding_names(PARROT_INTERP) |
| | 156 | __attribute__nonnull__(1); |
| | 157 | |
| 156 | 158 | #define ASSERT_ARGS_Parrot_default_encoding __attribute__unused__ int _ASSERT_ARGS_CHECK = 0 |
| 157 | 159 | #define ASSERT_ARGS_Parrot_encoding_c_name __attribute__unused__ int _ASSERT_ARGS_CHECK = 0 |
| 158 | 160 | #define ASSERT_ARGS_Parrot_encoding_name __attribute__unused__ int _ASSERT_ARGS_CHECK = 0 |
| … |
… |
|
| 180 | 182 | || PARROT_ASSERT_ARG(encodingname) \ |
| 181 | 183 | || PARROT_ASSERT_ARG(encoding) |
| 182 | 184 | #define ASSERT_ARGS_parrot_deinit_encodings __attribute__unused__ int _ASSERT_ARGS_CHECK = 0 |
| 183 | | #define ASSERT_ARGS_parrot_init_encodings_2 __attribute__unused__ int _ASSERT_ARGS_CHECK = 0 |
| | 185 | #define ASSERT_ARGS_Parrot_str_internal_register_encoding_names \ |
| | 186 | __attribute__unused__ int _ASSERT_ARGS_CHECK = \ |
| | 187 | PARROT_ASSERT_ARG(interp) |
| 184 | 188 | /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ |
| 185 | 189 | /* HEADERIZER END: src/string/encoding.c */ |
| 186 | 190 | |
diff --git a/include/parrot/string_funcs.h b/include/parrot/string_funcs.h
index 8dccd81..96dbe1c 100644
|
a
|
b
|
|
| 298 | 298 | ARGIN_NULLOK(const char *buffer), |
| 299 | 299 | UINTVAL len, |
| 300 | 300 | ARGIN(const ENCODING *encoding), |
| 301 | | ARGIN_NULLOK(const CHARSET *charset), |
| | 301 | ARGIN(const CHARSET *charset), |
| 302 | 302 | UINTVAL flags) |
| 303 | 303 | __attribute__nonnull__(1) |
| 304 | | __attribute__nonnull__(4); |
| | 304 | __attribute__nonnull__(4) |
| | 305 | __attribute__nonnull__(5); |
| 305 | 306 | |
| 306 | 307 | PARROT_EXPORT |
| 307 | 308 | PARROT_CANNOT_RETURN_NULL |
| … |
… |
|
| 638 | 639 | || PARROT_ASSERT_ARG(s) |
| 639 | 640 | #define ASSERT_ARGS_Parrot_str_new_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \ |
| 640 | 641 | PARROT_ASSERT_ARG(interp) \ |
| 641 | | || PARROT_ASSERT_ARG(encoding) |
| | 642 | || PARROT_ASSERT_ARG(encoding) \ |
| | 643 | || PARROT_ASSERT_ARG(charset) |
| 642 | 644 | #define ASSERT_ARGS_Parrot_str_new_noinit __attribute__unused__ int _ASSERT_ARGS_CHECK = \ |
| 643 | 645 | PARROT_ASSERT_ARG(interp) |
| 644 | 646 | #define ASSERT_ARGS_Parrot_str_not_equal __attribute__unused__ int _ASSERT_ARGS_CHECK = \ |
diff --git a/src/string/api.c b/src/string/api.c
index e87b87a..57a6397 100644
|
a
|
b
|
|
| 762 | 762 | PARROT_CANNOT_RETURN_NULL |
| 763 | 763 | STRING * |
| 764 | 764 | Parrot_str_new_init(PARROT_INTERP, ARGIN_NULLOK(const char *buffer), UINTVAL len, |
| 765 | | ARGIN(const ENCODING *encoding), ARGIN_NULLOK(const CHARSET *charset), UINTVAL flags) |
| | 765 | ARGIN(const ENCODING *encoding), ARGIN(const CHARSET *charset), UINTVAL flags) |
| 766 | 766 | { |
| 767 | 767 | ASSERT_ARGS(Parrot_str_new_init) |
| 768 | 768 | DECL_CONST_CAST; |
diff --git a/src/string/charset.c b/src/string/charset.c
index 4a25e6d..c9ad004 100644
|
a
|
b
|
|
| 63 | 63 | /* HEADERIZER BEGIN: static */ |
| 64 | 64 | /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ |
| 65 | 65 | |
| | 66 | static void Parrot_str_internal_register_charset_names(PARROT_INTERP) |
| | 67 | __attribute__nonnull__(1); |
| | 68 | |
| 66 | 69 | static INTVAL register_charset(PARROT_INTERP, |
| 67 | 70 | ARGIN(const char *charsetname), |
| 68 | 71 | ARGIN(CHARSET *charset)) |
| … |
… |
|
| 73 | 76 | static void register_static_converters(PARROT_INTERP) |
| 74 | 77 | __attribute__nonnull__(1); |
| 75 | 78 | |
| | 79 | #define ASSERT_ARGS_Parrot_str_internal_register_charset_names \ |
| | 80 | __attribute__unused__ int _ASSERT_ARGS_CHECK = \ |
| | 81 | PARROT_ASSERT_ARG(interp) |
| 76 | 82 | #define ASSERT_ARGS_register_charset __attribute__unused__ int _ASSERT_ARGS_CHECK = \ |
| 77 | 83 | PARROT_ASSERT_ARG(interp) \ |
| 78 | 84 | || PARROT_ASSERT_ARG(charsetname) \ |
| … |
… |
|
| 340 | 346 | (n + 1) * sizeof (One_charset)); |
| 341 | 347 | all_charsets->n_charsets++; |
| 342 | 348 | all_charsets->set[n].charset = charset; |
| 343 | | all_charsets->set[n].name = Parrot_str_new_constant(interp, charsetname); |
| 344 | 349 | all_charsets->set[n].n_converters = 0; |
| 345 | 350 | |
| 346 | 351 | return 1; |
| … |
… |
|
| 348 | 353 | |
| 349 | 354 | /* |
| 350 | 355 | |
| | 356 | =item C<static void Parrot_str_internal_register_charset_names> |
| | 357 | |
| | 358 | Helper function for initializing characterset names. We can't create the |
| | 359 | STRING names until the default encodings and charsets are already initted, |
| | 360 | so the name generation is split into a second init stage. |
| | 361 | |
| | 362 | =cut |
| | 363 | |
| | 364 | */ |
| | 365 | |
| | 366 | static void |
| | 367 | Parrot_str_internal_register_charset_names(PARROT_INTERP) |
| | 368 | { |
| | 369 | ASSERT_ARGS(Parrot_str_internal_register_charset_names) |
| | 370 | int n; |
| | 371 | for (n = 0; n < all_charsets->n_charsets; n++) |
| | 372 | all_charsets->set[n].name = |
| | 373 | Parrot_str_new_constant(interp, all_charsets->set[n].charset->name); |
| | 374 | } |
| | 375 | |
| | 376 | /* |
| | 377 | |
| 351 | 378 | =item C<static void register_static_converters> |
| 352 | 379 | |
| 353 | 380 | Registers several standard converters between common charsets, including: |
| … |
… |
|
| 462 | 489 | Parrot_charset_binary_init(interp); |
| 463 | 490 | Parrot_charset_unicode_init(interp); |
| 464 | 491 | |
| 465 | | /* |
| 466 | | * now encoding strings don't have a charset yet - set default |
| | 492 | /* Now that the plugins are registered, we can create STRING |
| | 493 | * names for them. |
| 467 | 494 | */ |
| 468 | | parrot_init_encodings_2(); |
| | 495 | Parrot_str_internal_register_encoding_names(interp); |
| | 496 | Parrot_str_internal_register_charset_names(interp); |
| | 497 | |
| 469 | 498 | /* |
| 470 | 499 | * now install charset converters |
| 471 | 500 | */ |
diff --git a/src/string/encoding.c b/src/string/encoding.c
index 425d687..b2f95ff 100644
|
a
|
b
|
|
| 58 | 58 | |
| 59 | 59 | /* |
| 60 | 60 | |
| 61 | | =item C<void parrot_init_encodings_2> |
| 62 | | |
| 63 | | Helper function for initializing characterset encodings. Initializes the |
| 64 | | C<all_encodings> array. |
| 65 | | |
| 66 | | =cut |
| 67 | | |
| 68 | | */ |
| 69 | | |
| 70 | | void |
| 71 | | parrot_init_encodings_2(void) |
| 72 | | { |
| 73 | | ASSERT_ARGS(parrot_init_encodings_2) |
| 74 | | const int n = all_encodings->n_encodings; |
| 75 | | int i; |
| 76 | | |
| 77 | | for (i = 0; i < n; ++i) { |
| 78 | | all_encodings->enc[i].name->charset = Parrot_default_charset_ptr; |
| 79 | | } |
| 80 | | } |
| 81 | | |
| 82 | | /* |
| 83 | | |
| 84 | 61 | =item C<void parrot_deinit_encodings> |
| 85 | 62 | |
| 86 | 63 | Deinitialize encodings and free all memory used by them. |
| … |
… |
|
| 338 | 315 | (n + 1) * sizeof (One_encoding)); |
| 339 | 316 | all_encodings->n_encodings++; |
| 340 | 317 | all_encodings->enc[n].encoding = encoding; |
| 341 | | all_encodings->enc[n].name = Parrot_str_new_constant(interp, encodingname); |
| 342 | 318 | |
| 343 | 319 | return 1; |
| 344 | 320 | } |
| 345 | 321 | |
| 346 | 322 | /* |
| 347 | 323 | |
| | 324 | =item C<void Parrot_str_internal_register_encoding_names> |
| | 325 | |
| | 326 | Helper function for initializing characterset encoding names. We can't create |
| | 327 | the STRING names until the default encodings and charsets are already initted, |
| | 328 | so the name generation is split into a second init stage. |
| | 329 | |
| | 330 | =cut |
| | 331 | |
| | 332 | */ |
| | 333 | |
| | 334 | |
| | 335 | void |
| | 336 | Parrot_str_internal_register_encoding_names(PARROT_INTERP) |
| | 337 | { |
| | 338 | ASSERT_ARGS(Parrot_str_internal_register_encoding_names) |
| | 339 | int n; |
| | 340 | for (n = 0; n < all_encodings->n_encodings; n++) |
| | 341 | all_encodings->enc[n].name = |
| | 342 | Parrot_str_new_constant(interp, all_encodings->enc[n].encoding->name); |
| | 343 | } |
| | 344 | |
| | 345 | /* |
| | 346 | |
| 348 | 347 | =item C<INTVAL Parrot_register_encoding> |
| 349 | 348 | |
| 350 | 349 | Registers a character encoding C<encoding> with name C<encodingname>. |