浏览代码

Add property getters for Is* style accessors (for example, Node::IsEnabled) (closed #1003)

Josh Engebretson 9 年之前
父节点
当前提交
05a254739a
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      Source/ToolCore/JSBind/JSBFunction.cpp

+ 7 - 3
Source/ToolCore/JSBind/JSBFunction.cpp

@@ -53,11 +53,15 @@ void JSBFunction::Process()
     // if not already marked as a getter
     // if not already marked as a getter
     if (!isGetter_)
     if (!isGetter_)
     {
     {
-        if (!parameters_.Size() && returnType_)
+        // Check for whether this is a property getter function
+        // IsObject is special as we don't want a property to it
+        if (!parameters_.Size() && returnType_ && name_ != "IsObject")
         {
         {
-            if (name_.Length() > 3 && name_.StartsWith("Get") && isupper(name_[3]))
+            if ((name_.Length() > 3 && name_.StartsWith("Get") && isupper(name_[3])) ||
+                (name_.Length() > 2 && name_.StartsWith("Is") && isupper(name_[2])) )
             {
             {
-                String pname = name_.Substring(3);
+                String pname = name_.Substring(name_.StartsWith("Get") ? 3 : 2);
+
                 class_->SetSkipFunction(pname);
                 class_->SetSkipFunction(pname);
                 isGetter_ = true;
                 isGetter_ = true;
                 propertyName_ = pname;
                 propertyName_ = pname;