Browse Source

More work on JSBind supporting SharedPtr return values

Josh Engebretson 10 years ago
parent
commit
19d845dcd9

+ 6 - 1
Source/AtomicJS/JSBind/JSBFunction.cpp

@@ -370,7 +370,12 @@ void JSBFunction::WriteFunction(String& source)
         {
         {
             JSBClassType* klassType = returnType_->type_->asClassType();
             JSBClassType* klassType = returnType_->type_->asClassType();
 
 
-            if (klassType->class_->isObject())
+            if (returnType_->isTemplate_)
+            {
+                returnDeclared = true;
+                source.AppendWithFormat("SharedPtr<%s> object = ", klassType->class_->GetClassName().CString());
+            }
+            else if (klassType->class_->isObject())
             {
             {
                 returnDeclared = true;
                 returnDeclared = true;
                 source.Append("const Object* object = ");
                 source.Append("const Object* object = ");

+ 2 - 0
Source/AtomicJS/JSBind/JSBFunction.h

@@ -18,11 +18,13 @@ public:
         isSharedPtr_ = false;
         isSharedPtr_ = false;
         isPointer_ = false;
         isPointer_ = false;
         isReference_ = false;
         isReference_ = false;
+        isTemplate_ = false;
     }
     }
 
 
     bool isSharedPtr_;
     bool isSharedPtr_;
     bool isPointer_;
     bool isPointer_;
     bool isReference_;
     bool isReference_;
+    bool isTemplate_;
 
 
     String name_;
     String name_;
     String initializer_;
     String initializer_;

+ 3 - 0
Source/AtomicJS/JSBind/JSBHeaderVisitor.h

@@ -111,6 +111,7 @@ public:
         bool isPointer = false;
         bool isPointer = false;
         bool isSharedPtr = false;
         bool isSharedPtr = false;
         bool isReference = false;
         bool isReference = false;
+        bool isTemplate = false;
 
 
         if (type->isPointerType())
         if (type->isPointerType())
         {
         {
@@ -137,6 +138,7 @@ public:
                     {
                     {
                         FullySpecifiedType pfst = tnid->templateArgumentAt(0);
                         FullySpecifiedType pfst = tnid->templateArgumentAt(0);
                         type = pfst.type();
                         type = pfst.type();
+                        isTemplate = true;
                     }
                     }
                 }
                 }
             }
             }
@@ -166,6 +168,7 @@ public:
         ftype->isPointer_ = isPointer;
         ftype->isPointer_ = isPointer;
         ftype->isSharedPtr_ = isSharedPtr;
         ftype->isSharedPtr_ = isSharedPtr;
         ftype->isReference_ = isReference;
         ftype->isReference_ = isReference;
+        ftype->isTemplate_ = isTemplate;
 
 
         return ftype;
         return ftype;