object.cpp

来自「Shorthand是一个强大的脚本语言」· C++ 代码 · 共 35 行

CPP
35
字号
///////////////////////////////////////////////////////////////////////////////
// $Header: /shorthand/src/object.cpp 5     2/08/03 6:40a Arm $
//-----------------------------------------------------------------------------
// Project: ShortHand interpreter
// Author: Andrei Remenchuk <andrei@remenchuk.com>
//-----------------------------------------------------------------------------
// object.cpp: abstract ShortHand object 
///////////////////////////////////////////////////////////////////////////////
#include "module.h"
#include "object.h"
#include "value.h"

ShhObject::ShhObject(ShhModule& module, const char* type, const YYLTYPE& location)
: m_module(module), m_type(type), m_ctor_location(location)
{
}

void ShhObject::setProperty(const char* name, ShhValue value)
{
    m_properties.put(name, value);
}

ShhValue& ShhObject::getProperty(const char* key)
{
    ShhValue* value = m_properties.get(key);
    if (value == NULL) {
        throw new ShhObjectException(1070, "Object of type '%s' doesn't have property or method named '%s'",  m_type.cstr(), key );
    }
    return *value;
}

ShhObject::~ShhObject()
{
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?