--- parser3/src/classes/table.C 2001/04/27 17:17:58 1.65.2.2 +++ parser3/src/classes/table.C 2001/05/02 11:49:17 1.69 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: table.C,v 1.65.2.2 2001/04/27 17:17:58 paf Exp $ + $Id: table.C,v 1.69 2001/05/02 11:49:17 paf Exp $ */ #include "pa_config_includes.h" @@ -39,7 +39,7 @@ public: // methods -void _set(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _set(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); // data is last parameter Value& vdata=params->get_junction(params->size()-1, "body must be code"); @@ -81,7 +81,7 @@ void _set(Methoded& m, Request& r, const static_cast(r.self)->set_table(table); } -void _load(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _load(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); // filename is last parameter Value& vfilename=params->get_no_junction(params->size()-1, @@ -130,7 +130,7 @@ void _load(Methoded& m, Request& r, cons static_cast(r.self)->set_table(table); } -void _save(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _save(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); Value& vtable_name=params->get_no_junction(params->size()-1, "file name must not be code"); @@ -177,19 +177,19 @@ void _save(Methoded& m, Request& r, cons sdata.cstr(), sdata.size(), true); } -void _count(Methoded& m, Request& r, const String&, MethodParams *) { +static void _count(Request& r, const String&, MethodParams *) { Pool& pool=r.pool(); Value& value=*new(pool) VInt(pool, static_cast(r.self)->table().size()); r.write_no_lang(value); } -void _line(Methoded& m, Request& r, const String& method_name, MethodParams *) { +static void _line(Request& r, const String& method_name, MethodParams *) { Pool& pool=r.pool(); Value& value=*new(pool) VInt(pool, 1+static_cast(r.self)->table().current()); r.write_no_lang(value); } -void _offset(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _offset(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); Table& table=static_cast(r.self)->table(); if(params->size()) @@ -200,7 +200,7 @@ void _offset(Methoded& m, Request& r, co } } -void _menu(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _menu(Request& r, const String& method_name, MethodParams *params) { Value& body_code=params->get_junction(0, "body must be code"); Value *delim_code=params->size()==2?¶ms->get(1):0; @@ -224,7 +224,7 @@ void _menu(Methoded& m, Request& r, cons table.set_current(saved_current); vtable.unlock(); } -void _empty(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _empty(Request& r, const String& method_name, MethodParams *params) { Table& table=static_cast(r.self)->table(); if(table.size()==0) r.write_pass_lang(r.process(params->get(0))); @@ -249,7 +249,7 @@ static void store_column_item_to_hash(Ar value=new(*ri.pool) VUnknown(*ri.pool); ri.hash->put(column_name, value); } -void _record(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _record(Request& r, const String& method_name, MethodParams *params) { Table& table=static_cast(r.self)->table(); if(const Array *columns=table.columns()) { Pool& pool=r.pool(); @@ -284,7 +284,7 @@ static int sort_cmp_double(const void *a else return 0; } -void _sort(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _sort(Request& r, const String& method_name, MethodParams *params) { Value& key_maker=params->get_junction(0, "key-maker must be code"); bool reverse=params->size()==2/*..[asc|desc]*/? @@ -327,7 +327,7 @@ void _sort(Methoded& m, Request& r, cons table.set_current(0); } -void _locate(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _locate(Request& r, const String& method_name, MethodParams *params) { VTable& vtable=*static_cast(r.self); Table& table=vtable.table(); vtable.last_locate_was_successful=table.locate( @@ -335,14 +335,14 @@ void _locate(Methoded& m, Request& r, co params->get(1).as_string()); } -void _found(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _found(Request& r, const String& method_name, MethodParams *params) { if(static_cast(r.self)->last_locate_was_successful) r.write_pass_lang(r.process(params->get_junction(0, "found-parameter must be code"))); else if(params->size()==2) r.write_pass_lang(r.process(params->get_junction(0, "else-parameter must be code"))); } -void _flip(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _flip(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); VTable& vtable=*static_cast(r.self); @@ -362,7 +362,7 @@ void _flip(Methoded& m, Request& r, cons vtable.set_table(new_table); } -void _append(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _append(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); // data is last parameter const String& string= @@ -372,10 +372,14 @@ void _append(Methoded& m, Request& r, co Array& row=*new(pool) Array(pool); string.split(row, 0, "\t", 1, String::UL_CLEAN); - static_cast(r.self)->table()+=&row; + VTable& vtable=*static_cast(r.self); + // disable ^a.menu{^a.append[]} + vtable.lock(); + vtable.table()+=&row; + vtable.unlock(); } -void _join(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _join(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); Table *maybe_src=params->get_no_junction(0, "table ref must not be code").get_table(); @@ -408,7 +412,7 @@ void _join(Methoded& m, Request& r, cons } /// ^table:sql{query}[(count[;offset])] -void _sql(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _sql(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); if(!r.connection) @@ -485,7 +489,7 @@ void _sql(Methoded& m, Request& r, const /// ^table:dir[path] /// ^table:dir[path][regexp] -void _dir(Methoded& m, Request& r, const String& method_name, MethodParams *params) { +static void _dir(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); Value& relative_path=params->get_no_junction(0, "path must not be code"); @@ -544,7 +548,7 @@ void _dir(Methoded& m, Request& r, const char *file_name_cstr=(char *)r.malloc(file_name_size); memcpy(file_name_cstr, ffblk.ff_name, file_name_size); String &file_name=*new(pool) String(pool); - file_name.APPEND_TAINTED(file_name_cstr, file_name_size, + file_name.APPEND(file_name_cstr, file_name_size, String::UL_FILE_NAME, method_name.origin().file, method_name.origin().line); Array& row=*new(pool) Array(pool); @@ -562,8 +566,8 @@ void _dir(Methoded& m, Request& r, const // constructor -MTable::MTable(Pool& pool) : Methoded(pool) { - set_name(NEW String(pool, TABLE_CLASS_NAME)); +MTable::MTable(Pool& apool) : Methoded(apool) { + set_name(*NEW String(pool(), TABLE_CLASS_NAME)); // ^table:set{data} // ^table:set[nameless]{data}