std::cout << "OpenAL Vendor: " << alGetString(AL_VENDOR) << "\n"
<< "OpenAL Version: " << alGetString(AL_VERSION) << "\n"
<< "OpenAL Renderer: " << alGetString(AL_RENDERER) << "\n"
- << "OpenAl Extensions: " << alGetString(AL_RENDERER) << "\n";
+ << "OpenAl Extensions: " << alGetString(AL_EXTENSIONS) << "\n";
}
void
#ifndef __FUNCTIONS_H__
#define __FUNCTIONS_H__
+#ifndef SCRIPTING_API
+#define __suspend
+#endif
+
namespace Scripting
{
/** displays a text file and scrolls it over the screen */
void display_text_file(const std::string& filename);
-/** @SUSPEND@
+/**
* Suspends the script execution for the specified number of seconds
- * */
-void wait(float seconds);
+ */
+void wait(float seconds) __suspend;
/** translates a give text into the users language (by looking it up in the .po
* files)
*/
std::string translate(const std::string& text);
/** load a script file and executes it
* This is typically used to import functions from external files.
- * */
+ */
void import(HSQUIRRELVM v, const std::string& filename);
}
}
out << ind << "\n";
// push return value back on stack and return
- if(function->return_type.is_void()) {
- if(function->docu_comment.find("@SUSPEND@") != std::string::npos) {
- out << ind << "return sq_suspendvm(v);\n";
- } else {
- out << ind << "return 0;\n";
+ if(function->suspend) {
+ if(!function->return_type.is_void()) {
+ std::stringstream msg;
+ msg << "Function '" << function->name << "' declared as suspend"
+ << " but has a return value.";
+ throw std::runtime_error(msg.str());
}
+ out << ind << "return sq_suspendvm(v);\n";
+ } else if(function->return_type.is_void()) {
+ out << ind << "return 0;\n";
} else {
push_to_stack(function->return_type, "return_value");
out << ind << "return 1;\n";
protected { return T_PROTECTED; }
private { return T_PRIVATE; }
namespace { return T_NAMESPACE; }
+__suspend { return T_SUSPEND; }
[a-zA-Z_][a-zA-Z_0-9]* {
Namespace* ns = search_namespace;
if(ns == 0)
%token T_CLASS
%token T_STRUCT
%token T_STATIC
+%token T_SUSPEND
%token T_CONST
%token T_UNSIGNED
%token T_SIGNED
current_function->docu_comment = last_docucomment;
last_docucomment = "";
}
- parameter_list ')' maybe_const abstract_declaration ';'
+ parameter_list ')' function_attributes abstract_declaration ';'
{
$$ = current_function;
}
;
-maybe_const:
+function_attributes:
/* empty */
- | T_CONST
+ | T_CONST function_attributes
+ | T_SUSPEND function_attributes
+ {
+ current_function->suspend = true;
+ }
;
abstract_declaration:
class Function : public ClassMember {
public:
+ Function() {
+ type = FUNCTION;
+ suspend = false;
+ }
+
enum FuncType {
FUNCTION,
CONSTRUCTOR,
DESTRUCTOR
};
FuncType type;
+ bool suspend;
std::string docu_comment;
std::string name;
Type return_type;