summaryrefslogtreecommitdiff
path: root/fluid/io/Code_Writer.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'fluid/io/Code_Writer.cxx')
-rw-r--r--fluid/io/Code_Writer.cxx66
1 files changed, 32 insertions, 34 deletions
diff --git a/fluid/io/Code_Writer.cxx b/fluid/io/Code_Writer.cxx
index f451d187e..ffa63514a 100644
--- a/fluid/io/Code_Writer.cxx
+++ b/fluid/io/Code_Writer.cxx
@@ -31,9 +31,6 @@
#include <stdlib.h>
#include <string.h>
-using namespace fld;
-using namespace fld::io;
-
// ---- Fd_Id_Map implementation ----
void Fd_Id_Map::clear() {
@@ -144,7 +141,7 @@ int is_id(char c) {
\param[in] label else if label is set, it is appended, skipping non-keyword characters
\return buffer to a unique identifier, managed by Code_Writer, so caller must NOT free() it
*/
-const char* Code_Writer::unique_id(void* o, const char* type, const char* name, const char* label) {
+const char* fld::io::Code_Writer::unique_id(void* o, const char* type, const char* name, const char* label) {
char buffer[128];
char* q = buffer;
char* q_end = q + 128 - 8 - 1; // room for hex number and NUL
@@ -189,7 +186,7 @@ const char* Code_Writer::unique_id(void* o, const char* type, const char* name,
\param[in] set generate this indent depth
\return pointer to a static string
*/
-const char *Code_Writer::indent(int set) {
+const char *fld::io::Code_Writer::indent(int set) {
static const char* spaces = " ";
int i = set * 2;
if (i>64) i = 64;
@@ -201,7 +198,7 @@ const char *Code_Writer::indent(int set) {
Return a C string that indents code to the current source file depth.
\return pointer to a static string
*/
-const char *Code_Writer::indent() {
+const char *fld::io::Code_Writer::indent() {
return indent(indentation);
}
@@ -211,7 +208,7 @@ const char *Code_Writer::indent() {
change the `indentation` variable; offset can be negative
\return pointer to a static string
*/
-const char *Code_Writer::indent_plus(int offset) {
+const char *fld::io::Code_Writer::indent_plus(int offset) {
return indent(indentation+offset);
}
@@ -222,7 +219,7 @@ const char *Code_Writer::indent_plus(int offset) {
\param[in] format printf-style formatting text, followed by a vararg list
\return 1 if the text was written to the file, 0 if it was previously written.
*/
-int Code_Writer::write_h_once(const char *format, ...) {
+int fld::io::Code_Writer::write_h_once(const char *format, ...) {
va_list args;
char buf[1024];
va_start(args, format);
@@ -242,7 +239,7 @@ int Code_Writer::write_h_once(const char *format, ...) {
\param[in] format printf-style formatting text, followed by a vararg list
\return 1 if the text was written to the file, 0 if it was previously written.
*/
-int Code_Writer::write_c_once(const char *format, ...) {
+int fld::io::Code_Writer::write_c_once(const char *format, ...) {
va_list args;
char buf[1024];
va_start(args, format);
@@ -267,7 +264,7 @@ int Code_Writer::write_c_once(const char *format, ...) {
\param[in] pp ay pointer
\return true if found in the tree, false if added to the tree
*/
-bool Code_Writer::c_contains(void *pp) {
+bool fld::io::Code_Writer::c_contains(void *pp) {
if (ptr_in_code.contains(pp)) {
return true;
}
@@ -292,7 +289,7 @@ bool Code_Writer::c_contains(void *pp) {
\see f.write_cstring(const char*)
*/
-void Code_Writer::write_cstring(const char *s, int length) {
+void fld::io::Code_Writer::write_cstring(const char *s, int length) {
const char *next_line = "\"\n\"";
if (varused_test) {
varused = 1;
@@ -373,7 +370,7 @@ void Code_Writer::write_cstring(const char *s, int length) {
\param[in] s write this string
\see f.write_cstring(const char*, int)
*/
-void Code_Writer::write_cstring(const char *s) {
+void fld::io::Code_Writer::write_cstring(const char *s) {
write_cstring(s, (int)strlen(s));
}
@@ -385,7 +382,7 @@ void Code_Writer::write_cstring(const char *s) {
\param[in] s a block of binary data, interpreted as unsigned bytes
\param[in] length size of the block in bytes
*/
-void Code_Writer::write_cdata(const char *s, int length) {
+void fld::io::Code_Writer::write_cdata(const char *s, int length) {
if (varused_test) {
varused = 1;
return;
@@ -423,7 +420,7 @@ void Code_Writer::write_cdata(const char *s, int length) {
\param[in] format printf-style formatting text
\param[in] args list of arguments
*/
-void Code_Writer::vwrite_c(const char* format, va_list args) {
+void fld::io::Code_Writer::vwrite_c(const char* format, va_list args) {
if (varused_test) {
varused = 1;
return;
@@ -435,7 +432,7 @@ void Code_Writer::vwrite_c(const char* format, va_list args) {
Print a formatted line to the source file.
\param[in] format printf-style formatting text, followed by a vararg list
*/
-void Code_Writer::write_c(const char* format,...) {
+void fld::io::Code_Writer::write_c(const char* format,...) {
va_list args;
va_start(args, format);
vwrite_c(format, args);
@@ -450,7 +447,7 @@ void Code_Writer::write_c(const char* format,...) {
\param[in] c line of code
\param[in] com optional commentary
*/
-void Code_Writer::write_cc(const char *indent, int n, const char *c, const char *com) {
+void fld::io::Code_Writer::write_cc(const char *indent, int n, const char *c, const char *com) {
write_c("%s%.*s", indent, n, c);
char cc = c[n-1];
if (cc!='}' && cc!=';')
@@ -464,7 +461,7 @@ void Code_Writer::write_cc(const char *indent, int n, const char *c, const char
Print a formatted line to the header file.
\param[in] format printf-style formatting text, followed by a vararg list
*/
-void Code_Writer::write_h(const char* format,...) {
+void fld::io::Code_Writer::write_h(const char* format,...) {
if (varused_test) return;
va_list args;
va_start(args, format);
@@ -480,7 +477,7 @@ void Code_Writer::write_h(const char* format,...) {
\param[in] c line of code
\param[in] com optional commentary
*/
-void Code_Writer::write_hc(const char *indent, int n, const char* c, const char *com) {
+void fld::io::Code_Writer::write_hc(const char *indent, int n, const char* c, const char *com) {
write_h("%s%.*s", indent, n, c);
char cc = c[n-1];
if (cc!='}' && cc!=';')
@@ -497,7 +494,7 @@ void Code_Writer::write_hc(const char *indent, int n, const char* c, const char
\param[in] inTrailWith append this character if the last line did not end with
a newline, usually 0 or newline.
*/
-void Code_Writer::write_c_indented(const char *textlines, int inIndent, char inTrailWith) {
+void fld::io::Code_Writer::write_c_indented(const char *textlines, int inIndent, char inTrailWith) {
if (textlines) {
indentation += inIndent;
for (;;) {
@@ -570,7 +567,7 @@ bool is_comment_before_class_member(Node *q) {
\param[in] p write this type and all its children
\return pointer to the next sibling
*/
-Node* Code_Writer::write_static(Node* p) {
+Node* fld::io::Code_Writer::write_static(Node* p) {
if (write_codeview) p->header_static_start = (int)ftell(header_file);
if (write_codeview) p->code_static_start = (int)ftell(code_file);
p->write_static(*this);
@@ -592,7 +589,7 @@ Node* Code_Writer::write_static(Node* p) {
\param[in] p write this node and all its children
\return pointer to the next sibling
*/
-Node* Code_Writer::write_code(Node* p) {
+Node* fld::io::Code_Writer::write_code(Node* p) {
// write all code that comes before the children code
// (but don't write the last comment until the very end)
if (!(p==Fluid.proj.tree.last && p->is_a(FLD_NODE_TYPE_Comment))) {
@@ -661,7 +658,7 @@ Node* Code_Writer::write_code(Node* p) {
\param[in] t filename of the header file
\return 0 if the operation failed, 1 if it was successful
*/
-int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) {
+int fld::io::Code_Writer::write_code(const char *s, const char *t, bool to_codeview) {
write_codeview = to_codeview;
unique_id_list.clear();
indentation = 0;
@@ -835,7 +832,8 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) {
write_c("#endif\n");
}
}
- for (Node* p = first_node; p;) {
+ Node *p;
+ for (p = first_node; p;) {
// write all static data for this & all children first
write_static(p);
// then write the nested code:
@@ -875,7 +873,7 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) {
This avoids repeating these words if the mode is already set.
\param[in] state 0 for private, 1 for public, 2 for protected
*/
-void Code_Writer::write_public(int state) {
+void fld::io::Code_Writer::write_public(int state) {
if (!current_class && !current_widget_class) return;
if (current_class && current_class->write_public_state == state) return;
if (current_widget_class && current_widget_class->write_public_state == state) return;
@@ -891,7 +889,7 @@ void Code_Writer::write_public(int state) {
/**
Create and initialize a new C++ source code writer.
*/
-Code_Writer::Code_Writer(Project &proj)
+fld::io::Code_Writer::Code_Writer(Project &proj)
: proj_ { proj }
{
block_crc_ = crc32(0, 0, 0);
@@ -900,7 +898,7 @@ Code_Writer::Code_Writer(Project &proj)
/**
Release all resources.
*/
-Code_Writer::~Code_Writer()
+fld::io::Code_Writer::~Code_Writer()
{
if (block_buffer_) ::free(block_buffer_);
}
@@ -913,7 +911,7 @@ Code_Writer::~Code_Writer()
\param[in] type FD_TAG_GENERIC, FD_TAG_CODE, FD_TAG_MENU_CALLBACK, or FD_TAG_WIDGET_CALLBACK
\param[in] uid the unique id of the current type
*/
-void Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsigned short uid) {
+void fld::io::Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsigned short uid) {
if (proj_.write_mergeback_data) {
::Mergeback::print_tag(code_file, prev_type, next_type, uid, (uint32_t)block_crc_);
}
@@ -931,7 +929,7 @@ void Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsign
if we are the start of a line, used to find leading whitespace
\return the new CRC
*/
-unsigned long Code_Writer::block_crc(const void *data, int n, unsigned long in_crc, bool *inout_line_start) {
+unsigned long fld::io::Code_Writer::block_crc(const void *data, int n, unsigned long in_crc, bool *inout_line_start) {
if (!data) return 0;
if (n==-1) n = (int)strlen((const char*)data);
bool line_start = true;
@@ -958,7 +956,7 @@ unsigned long Code_Writer::block_crc(const void *data, int n, unsigned long in_c
\param[in] data a pointer to the data block
\param[in] n the size of the data in bytes, or -1 to use strlen()
*/
-void Code_Writer::crc_add(const void *data, int n) {
+void fld::io::Code_Writer::crc_add(const void *data, int n) {
block_crc_ = block_crc(data, n, block_crc_, &block_line_start_);
}
@@ -967,7 +965,7 @@ void Code_Writer::crc_add(const void *data, int n) {
\param[in] format printf style formatting string
\return see fprintf(FILE *, *const char*, ...)
*/
-int Code_Writer::crc_printf(const char *format, ...) {
+int fld::io::Code_Writer::crc_printf(const char *format, ...) {
va_list args;
va_start(args, format);
int ret = crc_vprintf(format, args);
@@ -981,7 +979,7 @@ int Code_Writer::crc_printf(const char *format, ...) {
\param[in] args list of arguments
\return see fprintf(FILE *, *const char*, ...)
*/
-int Code_Writer::crc_vprintf(const char *format, va_list args) {
+int fld::io::Code_Writer::crc_vprintf(const char *format, va_list args) {
if (proj_.write_mergeback_data) {
int n = vsnprintf(block_buffer_, block_buffer_size_, format, args);
if (n > block_buffer_size_) {
@@ -1002,7 +1000,7 @@ int Code_Writer::crc_vprintf(const char *format, va_list args) {
\param[in] text any text, no requirements to end in a newline or such
\return see fputs(const char*, FILE*)
*/
-int Code_Writer::crc_puts(const char *text) {
+int fld::io::Code_Writer::crc_puts(const char *text) {
if (proj_.write_mergeback_data) {
crc_add(text);
}
@@ -1011,11 +1009,11 @@ int Code_Writer::crc_puts(const char *text) {
/** Write a single ASCII character to the code file.
If MergeBack is enabled, the CRC calculation is continued.
- \note to write UTF-8 characters, use Code_Writer::crc_puts(const char *text)
+ \note to write UTF-8 characters, use fld::io::Code_Writer::crc_puts(const char *text)
\param[in] c any character between 0 and 127 inclusive
\return see fputc(int, FILE*)
*/
-int Code_Writer::crc_putc(int c) {
+int fld::io::Code_Writer::crc_putc(int c) {
if (proj_.write_mergeback_data) {
uchar uc = (uchar)c;
crc_add(&uc, 1);