Use a throwing default setter in v8 emitter.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13815 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a82e0a6e8f
commit
91fc0ff205
2 changed files with 22 additions and 2 deletions
|
|
@ -43,4 +43,20 @@ void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol, v8
|
|||
obj->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
|
||||
}
|
||||
|
||||
void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
|
||||
{
|
||||
char buffer[256];
|
||||
char msg[512];
|
||||
int res;
|
||||
|
||||
property->WriteUtf8(buffer, 256);
|
||||
res = sprintf(msg, "Tried to write read-only variable: %s.", buffer);
|
||||
|
||||
if(res<0) {
|
||||
SWIG_exception(SWIG_ERROR, "Tried to write read-only variable.");
|
||||
} else {
|
||||
SWIG_exception(SWIG_ERROR, msg);
|
||||
}
|
||||
}
|
||||
|
||||
%} // v8_helper_functions
|
||||
|
|
|
|||
|
|
@ -1591,12 +1591,15 @@ private:
|
|||
|
||||
String* GLOBAL;
|
||||
String* NULL_STR;
|
||||
String *VETO_SET;
|
||||
|
||||
};
|
||||
|
||||
V8Emitter::V8Emitter()
|
||||
: JSEmitter(),
|
||||
GLOBAL(NewString("global")),
|
||||
NULL_STR(NewString("0"))
|
||||
NULL_STR(NewString("0")),
|
||||
VETO_SET(NewString("JS_veto_set_variable"))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1604,6 +1607,7 @@ V8Emitter::~V8Emitter()
|
|||
{
|
||||
Delete(GLOBAL);
|
||||
Delete(NULL_STR);
|
||||
Delete(VETO_SET);
|
||||
}
|
||||
|
||||
int V8Emitter::initialize(Node *n)
|
||||
|
|
@ -1761,7 +1765,7 @@ int V8Emitter::enterVariable(Node* n)
|
|||
JSEmitter::enterVariable(n);
|
||||
|
||||
state.variable(GETTER, NULL_STR);
|
||||
state.variable(SETTER, NULL_STR);
|
||||
state.variable(SETTER, VETO_SET);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue