comparison src/file-coding.c @ 5140:e5380fdaf8f1

merge
author Ben Wing <ben@xemacs.org>
date Sat, 13 Mar 2010 05:38:34 -0600
parents 7be849cb8828
children f965e31a35f0
comparison
equal deleted inserted replaced
5139:a48ef26d87ee 5140:e5380fdaf8f1
1 /* Text encoding conversion functions; coding-system object. 1 /* Text encoding conversion functions; coding-system object.
2 #### rename me to coding-system.c or coding.c 2 #### rename me to coding-system.c or coding.c
3 Copyright (C) 1991, 1995 Free Software Foundation, Inc. 3 Copyright (C) 1991, 1995 Free Software Foundation, Inc.
4 Copyright (C) 1995 Sun Microsystems, Inc. 4 Copyright (C) 1995 Sun Microsystems, Inc.
5 Copyright (C) 2000, 2001, 2002, 2003, 2005 Ben Wing. 5 Copyright (C) 2000, 2001, 2002, 2003, 2005, 2010 Ben Wing.
6 6
7 This file is part of XEmacs. 7 This file is part of XEmacs.
8 8
9 XEmacs is free software; you can redistribute it and/or modify it 9 XEmacs is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the 10 under the terms of the GNU General Public License as published by the
316 write_ascstring (printcharfun, "]"); 316 write_ascstring (printcharfun, "]");
317 } 317 }
318 318
319 #ifndef NEW_GC 319 #ifndef NEW_GC
320 static void 320 static void
321 finalize_coding_system (void *header, int for_disksave) 321 finalize_coding_system (Lisp_Object obj)
322 { 322 {
323 Lisp_Object cs = wrap_coding_system ((Lisp_Coding_System *) header);
324 /* Since coding systems never go away, this function is not 323 /* Since coding systems never go away, this function is not
325 necessary. But it would be necessary if we changed things 324 necessary. But it would be necessary if we changed things
326 so that coding systems could go away. */ 325 so that coding systems could go away. */
327 if (!for_disksave) /* see comment in lstream.c */ 326 MAYBE_XCODESYSMETH (obj, finalize, (obj));
328 MAYBE_XCODESYSMETH (cs, finalize, (cs));
329 } 327 }
330 #endif /* not NEW_GC */ 328 #endif /* not NEW_GC */
331 329
332 static Bytecount 330 static Bytecount
333 sizeof_coding_system (const void *header) 331 sizeof_coding_system (Lisp_Object obj)
334 { 332 {
335 const Lisp_Coding_System *p = (const Lisp_Coding_System *) header; 333 const Lisp_Coding_System *p = XCODING_SYSTEM (obj);
336 return offsetof (Lisp_Coding_System, data) + p->methods->extra_data_size; 334 return offsetof (Lisp_Coding_System, data) + p->methods->extra_data_size;
337 } 335 }
338 336
339 static const struct memory_description coding_system_methods_description_1[] 337 static const struct memory_description coding_system_methods_description_1[]
340 = { 338 = {
378 const struct sized_memory_description coding_system_empty_extra_description = { 376 const struct sized_memory_description coding_system_empty_extra_description = {
379 0, coding_system_empty_extra_description_1 377 0, coding_system_empty_extra_description_1
380 }; 378 };
381 379
382 #ifdef NEW_GC 380 #ifdef NEW_GC
383 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("coding-system", coding_system, 381 DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT ("coding-system", coding_system,
384 1, /*dumpable-flag*/ 382 mark_coding_system,
385 mark_coding_system, 383 print_coding_system,
386 print_coding_system, 384 0, 0, 0, coding_system_description,
387 0, 0, 0, coding_system_description, 385 sizeof_coding_system,
388 sizeof_coding_system, 386 Lisp_Coding_System);
389 Lisp_Coding_System);
390 #else /* not NEW_GC */ 387 #else /* not NEW_GC */
391 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("coding-system", coding_system, 388 DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT ("coding-system", coding_system,
392 1, /*dumpable-flag*/ 389 mark_coding_system,
393 mark_coding_system, 390 print_coding_system,
394 print_coding_system, 391 finalize_coding_system,
395 finalize_coding_system, 392 0, 0, coding_system_description,
396 0, 0, coding_system_description, 393 sizeof_coding_system,
397 sizeof_coding_system, 394 Lisp_Coding_System);
398 Lisp_Coding_System);
399 #endif /* not NEW_GC */ 395 #endif /* not NEW_GC */
400 396
401 /************************************************************************/ 397 /************************************************************************/
402 /* Creating coding systems */ 398 /* Creating coding systems */
403 /************************************************************************/ 399 /************************************************************************/
1003 allocate_coding_system (struct coding_system_methods *codesys_meths, 999 allocate_coding_system (struct coding_system_methods *codesys_meths,
1004 Bytecount data_size, 1000 Bytecount data_size,
1005 Lisp_Object name) 1001 Lisp_Object name)
1006 { 1002 {
1007 Bytecount total_size = offsetof (Lisp_Coding_System, data) + data_size; 1003 Bytecount total_size = offsetof (Lisp_Coding_System, data) + data_size;
1008 Lisp_Coding_System *codesys = 1004 Lisp_Object obj = ALLOC_SIZED_LISP_OBJECT (total_size, coding_system);
1009 (Lisp_Coding_System *) BASIC_ALLOC_LCRECORD (total_size, 1005 Lisp_Coding_System *codesys = XCODING_SYSTEM (obj);
1010 &lrecord_coding_system);
1011 1006
1012 codesys->methods = codesys_meths; 1007 codesys->methods = codesys_meths;
1013 #define MARKED_SLOT(x) codesys->x = Qnil; 1008 #define MARKED_SLOT(x) codesys->x = Qnil;
1014 #include "coding-system-slots.h" 1009 #include "coding-system-slots.h"
1015 1010
1452 else if (XCODING_SYSTEM (old_coding_system)->methods != 1447 else if (XCODING_SYSTEM (old_coding_system)->methods !=
1453 XCODING_SYSTEM (new_coding_system)->methods) 1448 XCODING_SYSTEM (new_coding_system)->methods)
1454 invalid_operation_2 ("Coding systems not same type", 1449 invalid_operation_2 ("Coding systems not same type",
1455 old_coding_system, new_coding_system); 1450 old_coding_system, new_coding_system);
1456 1451
1457 { 1452 copy_lisp_object (new_coding_system, old_coding_system);
1458 Lisp_Coding_System *to = XCODING_SYSTEM (new_coding_system); 1453 XCODING_SYSTEM (new_coding_system)->name = new_name;
1459 Lisp_Coding_System *from = XCODING_SYSTEM (old_coding_system);
1460 COPY_SIZED_LCRECORD (to, from, sizeof_coding_system (from));
1461 to->name = new_name;
1462 }
1463 return new_coding_system; 1454 return new_coding_system;
1464 } 1455 }
1465 1456
1466 /* #### Shouldn't this really be a find/get pair? */ 1457 /* #### Shouldn't this really be a find/get pair? */
1467 1458
4508 /************************************************************************/ 4499 /************************************************************************/
4509 4500
4510 void 4501 void
4511 syms_of_file_coding (void) 4502 syms_of_file_coding (void)
4512 { 4503 {
4513 INIT_LRECORD_IMPLEMENTATION (coding_system); 4504 INIT_LISP_OBJECT (coding_system);
4514 4505
4515 DEFSUBR (Fvalid_coding_system_type_p); 4506 DEFSUBR (Fvalid_coding_system_type_p);
4516 DEFSUBR (Fcoding_system_type_list); 4507 DEFSUBR (Fcoding_system_type_list);
4517 DEFSUBR (Fcoding_system_p); 4508 DEFSUBR (Fcoding_system_p);
4518 DEFSUBR (Fautoload_coding_system); 4509 DEFSUBR (Fautoload_coding_system);