(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too. noai
authorrubidium
Sun, 25 Mar 2007 15:22:56 +0000
branchnoai
changeset 9528 b2cc6f31363c
parent 9527 f709c97a5d9f
child 9529 5f26f4bc574b
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
src/ai/ai_squirrel.cpp
src/ai/api/squirrel_export.sh
--- a/src/ai/ai_squirrel.cpp	Sun Mar 25 15:03:49 2007 +0000
+++ b/src/ai/ai_squirrel.cpp	Sun Mar 25 15:22:56 2007 +0000
@@ -21,10 +21,11 @@
 
 /* Convert all AI related classes to Squirrel data */
 #define DEFINE_SQUIRREL_CLASS
+#include "api/ai_accounting.hpp"
 #include "api/ai_base.hpp"
 #include "api/ai_cargo.hpp"
+#include "api/ai_company.hpp"
 #include "api/ai_controller.hpp"
-#include "api/ai_company.hpp"
 #include "api/ai_execmode.hpp"
 #include "api/ai_industry.hpp"
 #include "api/ai_map.hpp"
@@ -189,6 +190,7 @@
 
 	/* Register all classes */
 	squirrel_register_std(this->engine);
+	SQAIAccountingRegister(this->engine);
 	SQAIBaseRegister(this->engine);
 	SQAICargoRegister(this->engine);
 	SQAICompanyRegister(this->engine);
@@ -198,8 +200,8 @@
 	SQAIMapRegister(this->engine);
 	SQAIOrderRegister(this->engine);
 	SQAIRoadRegister(this->engine);
+	SQAISettingsRegister(this->engine);
 	SQAISignRegister(this->engine);
-	SQAISettingsRegister(this->engine);
 	SQAITestModeRegister(this->engine);
 	SQAITownRegister(this->engine);
 	SQAITransactionModeRegister(this->engine);
--- a/src/ai/api/squirrel_export.sh	Sun Mar 25 15:03:49 2007 +0000
+++ b/src/ai/api/squirrel_export.sh	Sun Mar 25 15:22:56 2007 +0000
@@ -14,3 +14,53 @@
 		rm -f ${f}.tmp
 	fi
 done
+
+
+# Add stuff to ../ai_squirrel.cpp
+f='../ai_squirrel.cpp'
+
+functions=``
+
+echo "
+{ }
+/#define DEFINE_SQUIRREL_CLASS/ {
+	squirrel_stuff = \"true\";
+	print \"#define DEFINE_SQUIRREL_CLASS\"
+	split(\"`grep '^void SQAI.*Register(Squirrel \*engine) {$' *.hpp | sed 's/:.*$//' | sort | uniq | tr -d '\r' | tr '\n' ' '`\", files, \" \")
+
+	for (i = 1; files[i] != \"\"; i++) {
+		print \"#include \\\"api/\" files[i] \"\\\"\"
+	}
+
+	print \"#undef DEFINE_SQUIRREL_CLASS\"
+
+	next;
+}
+/^#undef DEFINE_SQUIRREL_CLASS/ { if (squirrel_stuff == \"true\") { squirrel_stuff = \"false\"; next; } }
+/^$/ { if (squirrel_stuff == \"true\") { squirrel_stuff = \"false\"; } }
+{ if (squirrel_stuff == \"true\") next; }
+
+/\/\* Register all classes \*\// {
+	squirrel_stuff = \"true\";
+	print \"	/* Register all classes */\"
+	print \"	squirrel_register_std(this->engine);\"
+	split(\"`grep '^void SQAI.*Register(Squirrel \*engine) {$' *.hpp | sed 's/^.*void //;s/Squirrel \*/this->/;s/ {/;/' | sort  | tr -d '\r' | tr '\n' ' '`\", regs, \" \")
+
+	for (i = 1; regs[i] != \"\"; i++) {
+		print \"	\" regs[i]
+	}
+
+	next
+}
+
+{ print \$0; }
+" > ${f}.awk
+
+awk -f ${f}.awk ${f} > ${f}.tmp
+
+if [ -n "`diff ${f} ${f}.tmp`" ]; then
+	mv ${f}.tmp ${f}
+else
+	rm -f ${f}.tmp
+fi
+rm -f ${f}.awk