From 6a4ba76836a8a0579a6164351e3fa2d14e29aa79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 1 Sep 2016 22:22:41 +0200 Subject: Merge tools/docdump in tools/doc Reduces clutter in the tools folder. --- tools/SCsub | 3 - tools/doc/doc_dump.cpp | 312 +++++++++++++++++++++++++++++++++++++++++++++ tools/doc/doc_dump.h | 41 ++++++ tools/docdump/SCsub | 5 - tools/docdump/doc_dump.cpp | 312 --------------------------------------------- tools/docdump/doc_dump.h | 41 ------ 6 files changed, 353 insertions(+), 361 deletions(-) create mode 100644 tools/doc/doc_dump.cpp create mode 100644 tools/doc/doc_dump.h delete mode 100644 tools/docdump/SCsub delete mode 100644 tools/docdump/doc_dump.cpp delete mode 100644 tools/docdump/doc_dump.h diff --git a/tools/SCsub b/tools/SCsub index f6c14a13fb..aaebab724a 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -115,10 +115,7 @@ if (env["tools"]!="no"): env.Command('#tools/editor/builtin_fonts.h',flist,make_fonts_header) SConscript('editor/SCsub'); - #SConscript('scintilla/SCsub'); SConscript('collada/SCsub'); - SConscript('docdump/SCsub'); - #SConscript('freetype/SCsub'); SConscript('doc/SCsub') SConscript('pck/SCsub') diff --git a/tools/doc/doc_dump.cpp b/tools/doc/doc_dump.cpp new file mode 100644 index 0000000000..fbf13f9e8f --- /dev/null +++ b/tools/doc/doc_dump.cpp @@ -0,0 +1,312 @@ +/*************************************************************************/ +/* doc_dump.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "version.h" +#include "doc_dump.h" +#include "os/file_access.h" +#include "scene/main/node.h" + + +static void _write_string(FileAccess *f,int p_tablevel,const String& p_string) { + + String tab; + for(int i=0;istore_string(tab+p_string+"\n"); +} + +struct _ConstantSort { + + String name; + int value; + bool operator<(const _ConstantSort& p_c) const { + + String left_a=name.find("_")==-1?name:name.substr(0,name.find("_")); + String left_b=p_c.name.find("_")==-1?p_c.name:p_c.name.substr(0,p_c.name.find("_")); + if(left_a==left_b) + return value","<"); + ret=ret.replace("'","'"); + ret=ret.replace("\"","""); + for (char i=1;i<32;i++) { + + char chr[2]={i,0}; + ret=ret.replace(chr,"&#"+String::num(i)+";"); + } + ret=ret.utf8(); + return ret; +} +void DocDump::dump(const String& p_file) { + + + List class_list; + ObjectTypeDB::get_type_list(&class_list); + + class_list.sort_custom(); + + + FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE); + + _write_string(f,0,""); + + _write_string(f,0,""); + while(class_list.size()) { + + String name=class_list.front()->get(); + + String header=""); + _write_string(f,1,""); + _write_string(f,1,""); + _write_string(f,1,""); + _write_string(f,1,""); + + List method_list; + ObjectTypeDB::get_method_list(name,&method_list,true); + method_list.sort(); + + + for(List::Element *E=method_list.front();E;E=E->next()) { + if (E->get().name=="" || E->get().name[0]=='_') + continue; //hiden + + MethodBind *m = ObjectTypeDB::get_method(name,E->get().name); + + String qualifiers; + if (E->get().flags&METHOD_FLAG_CONST) + qualifiers+="qualifiers=\"const\""; + + _write_string(f,2,"get().name)+"\" "+qualifiers+" >"); + + for(int i=-1;iget().arguments.size();i++) { + + PropertyInfo arginfo; + + if (i==-1) { + + arginfo=E->get().return_val; + String type_name=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type); + + if (arginfo.type==Variant::NIL) + continue; + _write_string(f,3,""); + } else { + + + arginfo=E->get().arguments[i]; + + String type_name; + + if (arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE) + type_name=arginfo.hint_string; + else if (arginfo.type==Variant::NIL) + type_name="var"; + else + type_name=Variant::get_type_name(arginfo.type); + + if (m && m->has_default_argument(i)) { + Variant default_arg=m->get_default_argument(i); + String default_arg_text=String(_escape_string(m->get_default_argument(i))); + + switch(default_arg.get_type()) { + + case Variant::NIL: + default_arg_text="NULL"; + break; + // atomic types + case Variant::BOOL: + if (bool(default_arg)) + default_arg_text="true"; + else + default_arg_text="false"; + break; + case Variant::INT: + case Variant::REAL: + //keep it + break; + case Variant::STRING: // 15 + case Variant::NODE_PATH: // 15 + default_arg_text="\""+default_arg_text+"\""; + break; + case Variant::TRANSFORM: + if (default_arg.operator Transform()==Transform()) { + default_arg_text=""; + } + + default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")"; + break; + + case Variant::VECTOR2: // 5 + case Variant::RECT2: + case Variant::VECTOR3: + case Variant::PLANE: + case Variant::QUAT: + case Variant::_AABB: //sorry naming convention fail :( not like it's used often // 10 + case Variant::MATRIX3: + case Variant::COLOR: + case Variant::RAW_ARRAY: + case Variant::INT_ARRAY: + case Variant::REAL_ARRAY: + case Variant::STRING_ARRAY: //25 + case Variant::VECTOR3_ARRAY: + case Variant::COLOR_ARRAY: + default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")"; + break; + case Variant::OBJECT: + case Variant::INPUT_EVENT: + case Variant::DICTIONARY: // 20 + case Variant::ARRAY: + case Variant::_RID: + case Variant::IMAGE: + //case Variant::RESOURCE: + + default_arg_text=Variant::get_type_name(default_arg.get_type())+"()"; + break; + default: {} + + } + + + + + _write_string(f,3,""); + } else + _write_string(f,3,""); + } + + + String hint; + switch(arginfo.hint) { + case PROPERTY_HINT_DIR: hint="A directory."; break; + case PROPERTY_HINT_RANGE: hint="Range - min: "+arginfo.hint_string.get_slice(",",0)+" max: "+arginfo.hint_string.get_slice(",",1)+" step: "+arginfo.hint_string.get_slice(",",2); break; + case PROPERTY_HINT_ENUM: hint="Values: "; for(int j=0;j0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(j); } break; + case PROPERTY_HINT_LENGTH: hint="Length: "+arginfo.hint_string; break; + case PROPERTY_HINT_FLAGS: hint="Values: "; for(int j=0;j0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(1<":""); + + + } + + _write_string(f,3,""); + _write_string(f,3,""); + + _write_string(f,2,""); + + } + + + _write_string(f,1,""); + + List signal_list; + ObjectTypeDB::get_signal_list(name,&signal_list,true); + + if (signal_list.size()) { + + _write_string(f,1,""); + for(List::Element *EV=signal_list.front();EV;EV=EV->next()) { + + _write_string(f,2,"get().name+"\">"); + for(int i=0;iget().arguments.size();i++) { + PropertyInfo arginfo=EV->get().arguments[i]; + _write_string(f,3,""); + _write_string(f,3,""); + } + _write_string(f,3,""); + _write_string(f,3,""); + + _write_string(f,2,""); + } + + _write_string(f,1,""); + } + + + _write_string(f,1,""); + + + List constant_list; + ObjectTypeDB::get_integer_constant_list(name, &constant_list, true); + + /* constants are sorted in a special way */ + + List<_ConstantSort> constant_sort; + + for(List::Element *E=constant_list.front();E;E=E->next()) { + _ConstantSort cs; + cs.name=E->get(); + cs.value=ObjectTypeDB::get_integer_constant(name, E->get()); + constant_sort.push_back(cs); + } + + constant_sort.sort(); + + for(List<_ConstantSort>::Element *E=constant_sort.front();E;E=E->next()) { + + _write_string(f,2,"get().name+"\" value=\""+itos(E->get().value)+"\">"); + _write_string(f,2,""); + } + + _write_string(f,1,""); + _write_string(f,0,""); + + class_list.erase(name); + } + + _write_string(f,0,""); + f->close(); + memdelete(f); + +} diff --git a/tools/doc/doc_dump.h b/tools/doc/doc_dump.h new file mode 100644 index 0000000000..372f5e0969 --- /dev/null +++ b/tools/doc/doc_dump.h @@ -0,0 +1,41 @@ +/*************************************************************************/ +/* doc_dump.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef DOC_DUMP_H +#define DOC_DUMP_H + +#include "object_type_db.h" + +class DocDump { +public: + + static void dump(const String& p_file); + +}; + +#endif // DOC_DUMP_H diff --git a/tools/docdump/SCsub b/tools/docdump/SCsub deleted file mode 100644 index 34524f10ef..0000000000 --- a/tools/docdump/SCsub +++ /dev/null @@ -1,5 +0,0 @@ -Import('env') - -env.add_source_files(env.tool_sources,"*.cpp") - -Export('env') diff --git a/tools/docdump/doc_dump.cpp b/tools/docdump/doc_dump.cpp deleted file mode 100644 index fbf13f9e8f..0000000000 --- a/tools/docdump/doc_dump.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/*************************************************************************/ -/* doc_dump.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "version.h" -#include "doc_dump.h" -#include "os/file_access.h" -#include "scene/main/node.h" - - -static void _write_string(FileAccess *f,int p_tablevel,const String& p_string) { - - String tab; - for(int i=0;istore_string(tab+p_string+"\n"); -} - -struct _ConstantSort { - - String name; - int value; - bool operator<(const _ConstantSort& p_c) const { - - String left_a=name.find("_")==-1?name:name.substr(0,name.find("_")); - String left_b=p_c.name.find("_")==-1?p_c.name:p_c.name.substr(0,p_c.name.find("_")); - if(left_a==left_b) - return value","<"); - ret=ret.replace("'","'"); - ret=ret.replace("\"","""); - for (char i=1;i<32;i++) { - - char chr[2]={i,0}; - ret=ret.replace(chr,"&#"+String::num(i)+";"); - } - ret=ret.utf8(); - return ret; -} -void DocDump::dump(const String& p_file) { - - - List class_list; - ObjectTypeDB::get_type_list(&class_list); - - class_list.sort_custom(); - - - FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE); - - _write_string(f,0,""); - - _write_string(f,0,""); - while(class_list.size()) { - - String name=class_list.front()->get(); - - String header=""); - _write_string(f,1,""); - _write_string(f,1,""); - _write_string(f,1,""); - _write_string(f,1,""); - - List method_list; - ObjectTypeDB::get_method_list(name,&method_list,true); - method_list.sort(); - - - for(List::Element *E=method_list.front();E;E=E->next()) { - if (E->get().name=="" || E->get().name[0]=='_') - continue; //hiden - - MethodBind *m = ObjectTypeDB::get_method(name,E->get().name); - - String qualifiers; - if (E->get().flags&METHOD_FLAG_CONST) - qualifiers+="qualifiers=\"const\""; - - _write_string(f,2,"get().name)+"\" "+qualifiers+" >"); - - for(int i=-1;iget().arguments.size();i++) { - - PropertyInfo arginfo; - - if (i==-1) { - - arginfo=E->get().return_val; - String type_name=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type); - - if (arginfo.type==Variant::NIL) - continue; - _write_string(f,3,""); - } else { - - - arginfo=E->get().arguments[i]; - - String type_name; - - if (arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE) - type_name=arginfo.hint_string; - else if (arginfo.type==Variant::NIL) - type_name="var"; - else - type_name=Variant::get_type_name(arginfo.type); - - if (m && m->has_default_argument(i)) { - Variant default_arg=m->get_default_argument(i); - String default_arg_text=String(_escape_string(m->get_default_argument(i))); - - switch(default_arg.get_type()) { - - case Variant::NIL: - default_arg_text="NULL"; - break; - // atomic types - case Variant::BOOL: - if (bool(default_arg)) - default_arg_text="true"; - else - default_arg_text="false"; - break; - case Variant::INT: - case Variant::REAL: - //keep it - break; - case Variant::STRING: // 15 - case Variant::NODE_PATH: // 15 - default_arg_text="\""+default_arg_text+"\""; - break; - case Variant::TRANSFORM: - if (default_arg.operator Transform()==Transform()) { - default_arg_text=""; - } - - default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")"; - break; - - case Variant::VECTOR2: // 5 - case Variant::RECT2: - case Variant::VECTOR3: - case Variant::PLANE: - case Variant::QUAT: - case Variant::_AABB: //sorry naming convention fail :( not like it's used often // 10 - case Variant::MATRIX3: - case Variant::COLOR: - case Variant::RAW_ARRAY: - case Variant::INT_ARRAY: - case Variant::REAL_ARRAY: - case Variant::STRING_ARRAY: //25 - case Variant::VECTOR3_ARRAY: - case Variant::COLOR_ARRAY: - default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")"; - break; - case Variant::OBJECT: - case Variant::INPUT_EVENT: - case Variant::DICTIONARY: // 20 - case Variant::ARRAY: - case Variant::_RID: - case Variant::IMAGE: - //case Variant::RESOURCE: - - default_arg_text=Variant::get_type_name(default_arg.get_type())+"()"; - break; - default: {} - - } - - - - - _write_string(f,3,""); - } else - _write_string(f,3,""); - } - - - String hint; - switch(arginfo.hint) { - case PROPERTY_HINT_DIR: hint="A directory."; break; - case PROPERTY_HINT_RANGE: hint="Range - min: "+arginfo.hint_string.get_slice(",",0)+" max: "+arginfo.hint_string.get_slice(",",1)+" step: "+arginfo.hint_string.get_slice(",",2); break; - case PROPERTY_HINT_ENUM: hint="Values: "; for(int j=0;j0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(j); } break; - case PROPERTY_HINT_LENGTH: hint="Length: "+arginfo.hint_string; break; - case PROPERTY_HINT_FLAGS: hint="Values: "; for(int j=0;j0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(1<":""); - - - } - - _write_string(f,3,""); - _write_string(f,3,""); - - _write_string(f,2,""); - - } - - - _write_string(f,1,""); - - List signal_list; - ObjectTypeDB::get_signal_list(name,&signal_list,true); - - if (signal_list.size()) { - - _write_string(f,1,""); - for(List::Element *EV=signal_list.front();EV;EV=EV->next()) { - - _write_string(f,2,"get().name+"\">"); - for(int i=0;iget().arguments.size();i++) { - PropertyInfo arginfo=EV->get().arguments[i]; - _write_string(f,3,""); - _write_string(f,3,""); - } - _write_string(f,3,""); - _write_string(f,3,""); - - _write_string(f,2,""); - } - - _write_string(f,1,""); - } - - - _write_string(f,1,""); - - - List constant_list; - ObjectTypeDB::get_integer_constant_list(name, &constant_list, true); - - /* constants are sorted in a special way */ - - List<_ConstantSort> constant_sort; - - for(List::Element *E=constant_list.front();E;E=E->next()) { - _ConstantSort cs; - cs.name=E->get(); - cs.value=ObjectTypeDB::get_integer_constant(name, E->get()); - constant_sort.push_back(cs); - } - - constant_sort.sort(); - - for(List<_ConstantSort>::Element *E=constant_sort.front();E;E=E->next()) { - - _write_string(f,2,"get().name+"\" value=\""+itos(E->get().value)+"\">"); - _write_string(f,2,""); - } - - _write_string(f,1,""); - _write_string(f,0,""); - - class_list.erase(name); - } - - _write_string(f,0,""); - f->close(); - memdelete(f); - -} diff --git a/tools/docdump/doc_dump.h b/tools/docdump/doc_dump.h deleted file mode 100644 index 372f5e0969..0000000000 --- a/tools/docdump/doc_dump.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************/ -/* doc_dump.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef DOC_DUMP_H -#define DOC_DUMP_H - -#include "object_type_db.h" - -class DocDump { -public: - - static void dump(const String& p_file); - -}; - -#endif // DOC_DUMP_H -- cgit v1.2.3