Author: petdance
Date: Wed Jun 13 18:45:10 2007
New Revision: 18993
Modified:
trunk/config/gen/makefiles/root.in
trunk/include/parrot/encoding.h
trunk/src/encoding.c
trunk/src/encodings/fixed_8.c
trunk/src/encodings/fixed_8.h
trunk/src/encodings/ucs2.c
trunk/src/encodings/ucs2.h
trunk/src/encodings/utf16.c
trunk/src/encodings/utf16.h
trunk/src/encodings/utf8.c
trunk/src/encodings/utf8.h
Log:
headerized the encodings directoriy
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Wed Jun 13 18:45:10 2007
@@ -1822,14 +1822,13 @@
HEADERIZER_O_FILES = \
$(INTERP_O_FILES) \
- $(CHARSET_O_FILES) \
$(IO_O_FILES) \
$(CLASS_O_FILES) \
- $(ENCODING_O_FILES)
# Slowing working my way up to having everything headerized in
$(HEADERIZER_O_FILES)
HEADERIZER_O_FILES = \
$(CHARSET_O_FILES) \
+ $(ENCODING_O_FILES) \
src/byteorder.o \
src/charset.o \
src/datatypes.o \
Modified: trunk/include/parrot/encoding.h
==============================================================================
--- trunk/include/parrot/encoding.h (original)
+++ trunk/include/parrot/encoding.h Wed Jun 13 18:45:10 2007
@@ -96,7 +96,8 @@
PARROT_API ENCODING * Parrot_find_encoding( Interp *interp,
const char *encodingname /*NN*/ )
- __attribute__nonnull__(2);
+ __attribute__nonnull__(2)
+ __attribute__warn_unused_result__;
PARROT_API encoding_converter_t Parrot_find_encoding_converter( Interp *interp,
ENCODING *lhs,
Modified: trunk/src/encoding.c
==============================================================================
--- trunk/src/encoding.c (original)
+++ trunk/src/encoding.c Wed Jun 13 18:45:10 2007
@@ -38,9 +38,9 @@
void
parrot_init_encodings_2(Interp *interp)
{
- int i, n;
+ const int n = all_encodings->n_encodings;
+ int i;
- n = all_encodings->n_encodings;
for (i = 0; i < n; ++i) {
all_encodings->enc[i].name->charset = Parrot_default_charset_ptr;
}
@@ -71,6 +71,7 @@
PARROT_API
ENCODING *
Parrot_find_encoding(Interp *interp, const char *encodingname /*NN*/)
+ /* WARN_UNUSED */
{
const int n = all_encodings->n_encodings;
int i;
@@ -174,8 +175,8 @@
}
static INTVAL
-register_encoding(Interp *interp, const char *encodingname,
- ENCODING *encoding)
+register_encoding(Interp *interp, const char *encodingname /*NN*/,
+ ENCODING *encoding /*NN*/)
{
const int n = all_encodings->n_encodings;
int i;
Modified: trunk/src/encodings/fixed_8.c
==============================================================================
--- trunk/src/encodings/fixed_8.c (original)
+++ trunk/src/encodings/fixed_8.c Wed Jun 13 18:45:10 2007
@@ -10,13 +10,26 @@
This file implements the encoding functions for fixed-width 8-bit codepoints
-=cut
-
*/
#include "parrot/parrot.h"
#include "fixed_8.h"
+/* HEADER: src/encodings/fixed_8.h */
+
+static UINTVAL get_codepoint(Interp *interp, const STRING *source_string,
UINTVAL offset);
+static void set_codepoint(Interp *interp, STRING *source_string, UINTVAL
offset, UINTVAL codepoint);
+static UINTVAL get_byte(Interp *interp, const STRING *source_string, UINTVAL
offset);
+static void set_byte(Interp *interp, const STRING *source_string, UINTVAL
offset, UINTVAL byte);
+static STRING *get_codepoints(Interp *interp, STRING *source_string, UINTVAL
offset, UINTVAL count);
+static STRING *get_bytes(Interp *interp, STRING *source_string, UINTVAL
offset, UINTVAL count);
+static STRING *get_bytes_inplace(Interp *interp, STRING *source_string,
UINTVAL offset, UINTVAL count, STRING *dest_string);
+static void set_codepoints(Interp *interp, STRING *source_string, UINTVAL
offset, UINTVAL count, STRING *new_codepoints);
+static void set_bytes(Interp *interp, STRING *source_string, UINTVAL offset,
UINTVAL count, STRING *new_bytes);
+static void become_encoding(Interp *interp, STRING *source_string);
+static UINTVAL codepoints(Interp *interp, STRING *source_string);
+static UINTVAL bytes(Interp *interp, STRING *source_string);
+
#define UNIMPL internal_exception(UNIMPLEMENTED, "unimpl fixed_8")
static STRING *
@@ -29,7 +42,7 @@
/* codepoints are bytes, so delegate */
static UINTVAL
-get_codepoint(Interp *interp, const STRING *source_string,
+get_codepoint(Interp *interp, const STRING *source_string /*NN*/,
UINTVAL offset)
{
return get_byte(interp, source_string, offset);
@@ -199,7 +212,7 @@
ENCODING *
Parrot_encoding_fixed_8_init(Interp *interp)
{
- ENCODING *return_encoding = Parrot_new_encoding(interp);
+ ENCODING * const return_encoding = Parrot_new_encoding(interp);
ENCODING base_encoding = {
"fixed_8",
@@ -227,10 +240,6 @@
}
-
-
-
-
/*
* Local variables:
* c-file-style: "parrot"
Modified: trunk/src/encodings/fixed_8.h
==============================================================================
--- trunk/src/encodings/fixed_8.h (original)
+++ trunk/src/encodings/fixed_8.h Wed Jun 13 18:45:10 2007
@@ -1,5 +1,5 @@
/* fixed_8.h
- * Copyright (C) 2004, The Perl Foundation.
+ * Copyright (C) 2004-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
@@ -13,19 +13,10 @@
#ifndef PARROT_ENCODING_FIXED_8_H_GUARD
#define PARROT_ENCODING_FIXED_8_H_GUARD
-static UINTVAL get_codepoint(Interp *interp, const STRING *source_string,
UINTVAL offset);
-static void set_codepoint(Interp *interp, STRING *source_string, UINTVAL
offset, UINTVAL codepoint);
-static UINTVAL get_byte(Interp *interp, const STRING *source_string, UINTVAL
offset);
-static void set_byte(Interp *interp, const STRING *source_string, UINTVAL
offset, UINTVAL byte);
-static STRING *get_codepoints(Interp *interp, STRING *source_string, UINTVAL
offset, UINTVAL count);
-static STRING *get_bytes(Interp *interp, STRING *source_string, UINTVAL
offset, UINTVAL count);
-static STRING *get_bytes_inplace(Interp *interp, STRING *source_string,
UINTVAL offset, UINTVAL count, STRING *dest_string);
-static void set_codepoints(Interp *interp, STRING *source_string, UINTVAL
offset, UINTVAL count, STRING *new_codepoints);
-static void set_bytes(Interp *interp, STRING *source_string, UINTVAL offset,
UINTVAL count, STRING *new_bytes);
-static void become_encoding(Interp *interp, STRING *source_string);
-static UINTVAL codepoints(Interp *interp, STRING *source_string);
-static UINTVAL bytes(Interp *interp, STRING *source_string);
-ENCODING *Parrot_encoding_fixed_8_init(Interp *interp);
+/* HEADERIZER BEGIN: src/encodings/fixed_8.c */
+
+ENCODING * Parrot_encoding_fixed_8_init( Interp *interp );
+/* HEADERIZER END: src/encodings/fixed_8.c */
#endif /* PARROT_ENCODING_FIXED_8_H_GUARD */
Modified: trunk/src/encodings/ucs2.c
==============================================================================
--- trunk/src/encodings/ucs2.c (original)
+++ trunk/src/encodings/ucs2.c Wed Jun 13 18:45:10 2007
@@ -12,15 +12,13 @@
=head2 Functions
-=over 4
-
-=cut
-
*/
#include "parrot/parrot.h"
#include "../unicode.h"
+/* HEADER: src/encodings/ucs2.h */
+
#include "ucs2.h"
#if PARROT_HAS_ICU
@@ -36,8 +34,8 @@
static STRING *
to_encoding(Interp *interp, STRING *src, STRING *dest)
{
- STRING *result = Parrot_utf16_encoding_ptr->to_encoding(interp,
- src, dest);
+ STRING * const result =
+ Parrot_utf16_encoding_ptr->to_encoding(interp, src, dest);
/*
* conversion to utf16 downgrads to ucs-2 if possible - check result
*/
@@ -262,8 +260,6 @@
/*
-=back
-
=head1 SEE ALSO
F<src/encodings/fixed_8.c>,
@@ -272,8 +268,6 @@
F<include/parrot/string.h>,
F<docs/string.pod>.
-=cut
-
*/
Modified: trunk/src/encodings/ucs2.h
==============================================================================
--- trunk/src/encodings/ucs2.h (original)
+++ trunk/src/encodings/ucs2.h Wed Jun 13 18:45:10 2007
@@ -13,7 +13,10 @@
#ifndef PARROT_ENCODING_UCS2_H_GUARD
#define PARROT_ENCODING_UCS2_H_GUARD
-ENCODING *Parrot_encoding_ucs2_init(Interp *);
+/* HEADERIZER BEGIN: src/encodings/ucs2.c */
+
+ENCODING * Parrot_encoding_ucs2_init( Interp *interp );
+/* HEADERIZER END: src/encodings/ucs2.c */
#endif /* PARROT_ENCODING_UCS2_H_GUARD */
Modified: trunk/src/encodings/utf16.c
==============================================================================
--- trunk/src/encodings/utf16.c (original)
+++ trunk/src/encodings/utf16.c Wed Jun 13 18:45:10 2007
@@ -12,15 +12,13 @@
=head2 Functions
-=over 4
-
-=cut
-
*/
#include "parrot/parrot.h"
#include "../unicode.h"
+/* HEADER: src/encodings/utf16.h */
+
#include "utf16.h"
#if PARROT_HAS_ICU
@@ -35,17 +33,16 @@
/*
-=item C<static STRING *to_encoding(Interp *, STRING *src, STRING *dest)>
+FUNCDOC: to_encoding
Convert string C<src> to this encoding. If C<dest> is set
fill it with the converted result, else operate inplace.
-=cut
-
*/
static STRING *
-to_encoding(Interp *interp, STRING *src, STRING *dest)
+to_encoding(Interp *interp, STRING *src /*NN*/, STRING *dest)
+ /* WARN_UNUSED */
{
#if PARROT_HAS_ICU
UErrorCode err;
@@ -165,7 +162,7 @@
}
static UINTVAL
-get_byte(Interp *interp, const STRING *src, UINTVAL offset)
+get_byte(Interp *interp, const STRING *src /*NN*/, UINTVAL offset)
{
unsigned char *contents = (unsigned char *)src->strstart;
if (offset >= src->bufused) {
@@ -195,8 +192,8 @@
{
String_iter iter;
UINTVAL start;
- STRING *return_string = Parrot_make_COW_reference(interp,
- src);
+ STRING * const return_string = Parrot_make_COW_reference(interp, src);
+
iter_init(interp, src, &iter);
iter.set_position(interp, &iter, offset);
start = iter.bytepos;
@@ -228,8 +225,7 @@
}
static STRING *
-get_bytes(Interp *interp, STRING *src,
- UINTVAL offset, UINTVAL count)
+get_bytes(Interp *interp, STRING *src, UINTVAL offset, UINTVAL count)
{
UNIMPL;
return NULL;
@@ -371,8 +367,6 @@
/*
-=back
-
=head1 SEE ALSO
F<src/encodings/fixed_8.c>,
@@ -381,8 +375,6 @@
F<include/parrot/string.h>,
F<docs/string.pod>.
-=cut
-
*/
Modified: trunk/src/encodings/utf16.h
==============================================================================
--- trunk/src/encodings/utf16.h (original)
+++ trunk/src/encodings/utf16.h Wed Jun 13 18:45:10 2007
@@ -1,5 +1,5 @@
/* utf16.h
- * Copyright (C) 2004, The Perl Foundation.
+ * Copyright (C) 2004-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
@@ -13,7 +13,10 @@
#ifndef PARROT_ENCODING_UTF16_H_GUARD
#define PARROT_ENCODING_UTF16_H_GUARD
-ENCODING *Parrot_encoding_utf16_init(Interp *);
+/* HEADERIZER BEGIN: src/encodings/utf16.c */
+
+ENCODING * Parrot_encoding_utf16_init( Interp *interp );
+/* HEADERIZER END: src/encodings/utf16.c */
#endif /* PARROT_ENCODING_UTF16_H_GUARD */
Modified: trunk/src/encodings/utf8.c
==============================================================================
--- trunk/src/encodings/utf8.c (original)
+++ trunk/src/encodings/utf8.c Wed Jun 13 18:45:10 2007
@@ -12,16 +12,14 @@
=head2 Functions
-=over 4
-
-=cut
-
*/
#include "parrot/parrot.h"
#include "../unicode.h"
#include "utf8.h"
+/* HEADER: src/encodings/utf8.h */
+
#define UNIMPL internal_exception(UNIMPLEMENTED, "unimpl utf8")
const char Parrot_utf8skip[256] = {
@@ -48,15 +46,13 @@
#endif
static void iter_init(Interp *, const String *src, String_iter *iter);
+
/*
-=item C<static UINTVAL
-utf8_characters(const void *ptr, UINTVAL bytes)>
+FUNCDOC: utf8_characters
Returns the number of characters in the C<byte_len> bytes from C<*ptr>.
-=cut
-
*/
static UINTVAL
@@ -80,13 +76,10 @@
/*
-=item C<static UINTVAL
-utf8_decode(const void *ptr)>
+FUNCDOC: utf8_decode
Returns the integer for the UTF-8 character found at C<*ptr>.
-=cut
-
*/
static UINTVAL
@@ -121,13 +114,10 @@
/*
-=item C<static void *
-utf8_encode(void *ptr, UINTVAL c)>
+FUNCDOC: utf8_encode
Returns the UTF-8 encoding of integer C<c>.
-=cut
-
*/
static void *
@@ -154,13 +144,10 @@
/*
-=item C<static const void *
-utf8_skip_forward(const void *ptr, UINTVAL n)>
+FUNCDOC: utf8_skip_forward
Moves C<ptr> C<n> characters forward.
-=cut
-
*/
static const void *
@@ -177,13 +164,10 @@
/*
-=item C<static const void *
-utf8_skip_backward(const void *ptr, UINTVAL n)>
+FUNCDOC: utf8_skip_backward
Moves C<ptr> C<n> characters back.
-=cut
-
*/
static const void *
@@ -202,26 +186,18 @@
/*
-=back
-
=head2 Iterator Functions
-=over 4
-
-=item C<static UINTVAL
-utf8_decode_and_advance(Interp *, String_iter *i)>
+FUNCDOC: utf8_decode_and_advance
The UTF-8 implementation of the string iterator's C<get_and_advance>
function.
-=item C<static void
-utf8_encode_and_advance(Interp *, String_iter *i, UINTVAL c)>
+FUNCDOC: utf8_encode_and_advance
The UTF-8 implementation of the string iterator's C<set_and_advance>
function.
-=cut
-
*/
static UINTVAL
@@ -274,13 +250,11 @@
/*
-=item C<func>
+FUNCDOC: utf8_set_position
The UTF-8 implementation of the string iterator's C<set_position>
function.
-=cut
-
*/
/* XXX Should use quickest direction */
@@ -565,8 +539,6 @@
/*
-=back
-
=head1 SEE ALSO
F<src/encodings/fixed_8.c>,
@@ -574,8 +546,6 @@
F<include/parrot/string.h>,
F<docs/string.pod>.
-=cut
-
*/
Modified: trunk/src/encodings/utf8.h
==============================================================================
--- trunk/src/encodings/utf8.h (original)
+++ trunk/src/encodings/utf8.h Wed Jun 13 18:45:10 2007
@@ -1,5 +1,5 @@
/* utf8.h
- * Copyright (C) 2004, The Perl Foundation.
+ * Copyright (C) 2004-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
@@ -13,7 +13,10 @@
#ifndef PARROT_ENCODING_UTF8_H_GUARD
#define PARROT_ENCODING_UTF8_H_GUARD
-ENCODING *Parrot_encoding_utf8_init(Interp *);
+/* HEADERIZER BEGIN: src/encodings/utf8.c */
+
+ENCODING * Parrot_encoding_utf8_init( Interp *interp );
+/* HEADERIZER END: src/encodings/utf8.c */
#endif /* PARROT_ENCODING_UTF8_H_GUARD */