Browse Source

Reverted to AngelScript 2.21.1 because of crash with VariantMap.
Find the zone at far clip plane and use it for the background color.
Added zone mask for drawables, allowing to select which zones they can belong to.
When zone moves or changes its bounding box, clear the cached zone from all drawables that were inside.

Lasse Öörni 14 years ago
parent
commit
bdc29caebd
51 changed files with 1097 additions and 2230 deletions
  1. 3 3
      Docs/Reference.dox
  2. 7 0
      Docs/ScriptAPI.dox
  3. 1 1
      Docs/Urho3D.dox
  4. 2 0
      Engine/Engine/APITemplates.h
  5. 1 1
      Engine/Graphics/BillboardSet.h
  6. 9 0
      Engine/Graphics/Drawable.cpp
  7. 8 1
      Engine/Graphics/Drawable.h
  8. 136 107
      Engine/Graphics/View.cpp
  9. 2 0
      Engine/Graphics/View.h
  10. 21 0
      Engine/Graphics/Zone.cpp
  11. 4 0
      Engine/Graphics/Zone.h
  12. 2 2
      Engine/Script/Addons.cpp
  13. 3 3
      Engine/Script/Script.cpp
  14. 6 4
      Engine/Script/ScriptFile.cpp
  15. 1 1
      Readme.txt
  16. 21 69
      ThirdParty/AngelScript/include/angelscript.h
  17. 36 245
      ThirdParty/AngelScript/source/as_builder.cpp
  18. 1 4
      ThirdParty/AngelScript/source/as_builder.h
  19. 7 60
      ThirdParty/AngelScript/source/as_callfunc.cpp
  20. 235 235
      ThirdParty/AngelScript/source/as_callfunc_arm_gcc.S
  21. 242 242
      ThirdParty/AngelScript/source/as_callfunc_arm_msvc.asm
  22. 50 26
      ThirdParty/AngelScript/source/as_callfunc_x64_gcc.cpp
  23. 67 277
      ThirdParty/AngelScript/source/as_compiler.cpp
  24. 2 2
      ThirdParty/AngelScript/source/as_compiler.h
  25. 0 6
      ThirdParty/AngelScript/source/as_configgroup.cpp
  26. 1 10
      ThirdParty/AngelScript/source/as_configgroup.h
  27. 27 150
      ThirdParty/AngelScript/source/as_context.cpp
  28. 3 3
      ThirdParty/AngelScript/source/as_context.h
  29. 0 1
      ThirdParty/AngelScript/source/as_criticalsection.h
  30. 2 36
      ThirdParty/AngelScript/source/as_gc.cpp
  31. 0 2
      ThirdParty/AngelScript/source/as_gc.h
  32. 1 34
      ThirdParty/AngelScript/source/as_generic.cpp
  33. 1 5
      ThirdParty/AngelScript/source/as_generic.h
  34. 1 2
      ThirdParty/AngelScript/source/as_globalproperty.cpp
  35. 3 3
      ThirdParty/AngelScript/source/as_map.h
  36. 4 66
      ThirdParty/AngelScript/source/as_module.cpp
  37. 7 17
      ThirdParty/AngelScript/source/as_module.h
  38. 26 103
      ThirdParty/AngelScript/source/as_objecttype.cpp
  39. 6 19
      ThirdParty/AngelScript/source/as_objecttype.h
  40. 3 38
      ThirdParty/AngelScript/source/as_parser.cpp
  41. 1 5
      ThirdParty/AngelScript/source/as_property.h
  42. 47 163
      ThirdParty/AngelScript/source/as_restore.cpp
  43. 0 2
      ThirdParty/AngelScript/source/as_restore.h
  44. 44 198
      ThirdParty/AngelScript/source/as_scriptengine.cpp
  45. 23 37
      ThirdParty/AngelScript/source/as_scriptengine.h
  46. 18 12
      ThirdParty/AngelScript/source/as_scriptfunction.cpp
  47. 1 10
      ThirdParty/AngelScript/source/as_scriptfunction.h
  48. 4 3
      ThirdParty/AngelScript/source/as_scriptobject.cpp
  49. 2 2
      ThirdParty/AngelScript/source/as_scriptobject.h
  50. 1 15
      ThirdParty/AngelScript/source/as_texts.h
  51. 4 5
      ThirdParty/AngelScript/source/as_tokendef.h

+ 3 - 3
Docs/Reference.dox

@@ -411,7 +411,7 @@ The rendering-related components defined by the %Graphics library are:
 - BillboardSet: a group of camera-facing billboards, which can have varying sizes, rotations and texture coordinates.
 - BillboardSet: a group of camera-facing billboards, which can have varying sizes, rotations and texture coordinates.
 - ParticleEmitter: a subclass of BillboardSet that emits particle billboards.
 - ParticleEmitter: a subclass of BillboardSet that emits particle billboards.
 - Light: illuminates the scene. Can optionally cast shadows.
 - Light: illuminates the scene. Can optionally cast shadows.
-- Zone: defines global properties like fogging and background color. The active zone is the one the Camera is currently in.
+- Zone: defines ambient light and fog settings for objects inside the zone volume.
 
 
 \section Rendering_Optimizations Optimizations
 \section Rendering_Optimizations Optimizations
 
 
@@ -543,9 +543,9 @@ When occlusion is used, a light will automatically be culled if its bounding box
 
 
 It is possible to limit which objects are affected by each light, by calling \ref Drawable::SetLightMask "SetLightMask()" on both the light and the objects. The lightmasks of the light and objects are ANDed to check whether the light should have effect: the light will only illuminate an object if the result is nonzero. By default objects and lights have all bits set in their lightmask, thus passing this test always.
 It is possible to limit which objects are affected by each light, by calling \ref Drawable::SetLightMask "SetLightMask()" on both the light and the objects. The lightmasks of the light and objects are ANDed to check whether the light should have effect: the light will only illuminate an object if the result is nonzero. By default objects and lights have all bits set in their lightmask, thus passing this test always.
 
 
-\ref Zone "Zones" can also be used for light culling in a similar manner. The lightmask of the zone the camera is in will be ANDed with each light's lightmask to see whether the light should be included in rendering. By default a zone has all bits set in its lightmask.
+\ref Zone "Zones" can also be used for light culling. When an object is inside a zone, its lightmask will be ANDed with the zone's lightmask before testing it against the lights' lightmasks. Using this mechanism, objects can change their accepted light set dynamically as they move through the scene.
 
 
-Care must be utilized when doing light culling with lightmasks, because they easily create situations where a light's influence is cut off unnaturally. However, they can be a great performance boost: imagine a multi-store building, where the lights of each floor would normally need to have shadows enabled to not "bleed" into the lower floors, costing performance. Instead of enabling shadows, the bleeding could also be prevented by using unique lightmask bits on the objects and lights of each floor.
+Care must be utilized when doing light culling with lightmasks, because they easily create situations where a light's influence is cut off unnaturally. However, they can be helpful in preventing light spill into undesired areas, for example lights inside one room bleeding into another, without having to resort into shadow-casting lights.
 
 
 \section Lights_ShadowedLights Shadowed lights
 \section Lights_ShadowedLights Shadowed lights
 
 

+ 7 - 0
Docs/ScriptAPI.dox

@@ -1586,6 +1586,7 @@ Properties:<br>
 - float lodBias
 - float lodBias
 - uint viewMask
 - uint viewMask
 - uint lightMask
 - uint lightMask
+- uint zoneMask
 - uint maxLights
 - uint maxLights
 - BoundingBox& worldBoundingBox (readonly)
 - BoundingBox& worldBoundingBox (readonly)
 
 
@@ -1647,6 +1648,7 @@ Properties:<br>
 - float lodBias
 - float lodBias
 - uint viewMask
 - uint viewMask
 - uint lightMask
 - uint lightMask
+- uint zoneMask
 - uint maxLights
 - uint maxLights
 - BoundingBox& worldBoundingBox (readonly)
 - BoundingBox& worldBoundingBox (readonly)
 - LightType lightType
 - LightType lightType
@@ -1698,6 +1700,7 @@ Properties:<br>
 - float lodBias
 - float lodBias
 - uint viewMask
 - uint viewMask
 - uint lightMask
 - uint lightMask
+- uint zoneMask
 - uint maxLights
 - uint maxLights
 - BoundingBox& worldBoundingBox (readonly)
 - BoundingBox& worldBoundingBox (readonly)
 - BoundingBox& boundingBox
 - BoundingBox& boundingBox
@@ -1738,6 +1741,7 @@ Properties:<br>
 - float lodBias
 - float lodBias
 - uint viewMask
 - uint viewMask
 - uint lightMask
 - uint lightMask
+- uint zoneMask
 - uint maxLights
 - uint maxLights
 - BoundingBox& worldBoundingBox (readonly)
 - BoundingBox& worldBoundingBox (readonly)
 - Model@ model
 - Model@ model
@@ -1778,6 +1782,7 @@ Properties:<br>
 - float lodBias
 - float lodBias
 - uint viewMask
 - uint viewMask
 - uint lightMask
 - uint lightMask
+- uint zoneMask
 - uint maxLights
 - uint maxLights
 - BoundingBox& worldBoundingBox (readonly)
 - BoundingBox& worldBoundingBox (readonly)
 - Model@ model
 - Model@ model
@@ -1846,6 +1851,7 @@ Properties:<br>
 - float lodBias
 - float lodBias
 - uint viewMask
 - uint viewMask
 - uint lightMask
 - uint lightMask
+- uint zoneMask
 - uint maxLights
 - uint maxLights
 - BoundingBox& worldBoundingBox (readonly)
 - BoundingBox& worldBoundingBox (readonly)
 - Model@ model
 - Model@ model
@@ -1953,6 +1959,7 @@ Properties:<br>
 - float lodBias
 - float lodBias
 - uint viewMask
 - uint viewMask
 - uint lightMask
 - uint lightMask
+- uint zoneMask
 - uint maxLights
 - uint maxLights
 - BoundingBox& worldBoundingBox (readonly)
 - BoundingBox& worldBoundingBox (readonly)
 - Material@ material
 - Material@ material

+ 1 - 1
Docs/Urho3D.dox

@@ -58,7 +58,7 @@ Urho3D is greatly inspired by OGRE (http://www.ogre3d.org/) and Horde3D (http://
 
 
 Urho3D uses the following third-party libraries:
 Urho3D uses the following third-party libraries:
 
 
-- AngelScript 2.22.0 WIP (http://www.angelcode.com/angelscript/)
+- AngelScript 2.21.1 (http://www.angelcode.com/angelscript/)
 - FreeType 2.3.12 (http://www.freetype.org/)
 - FreeType 2.3.12 (http://www.freetype.org/)
 - GLee 5.4 (http://elf-stone.com/)
 - GLee 5.4 (http://elf-stone.com/)
 - GLFW 3.0 WIP (http://www.glfw.org/)
 - GLFW 3.0 WIP (http://www.glfw.org/)

+ 2 - 0
Engine/Engine/APITemplates.h

@@ -627,6 +627,8 @@ template <class T> void RegisterDrawable(asIScriptEngine* engine, const char* cl
     engine->RegisterObjectMethod(className, "uint get_viewMask() const", asMETHOD(T, GetViewMask), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_viewMask() const", asMETHOD(T, GetViewMask), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_lightMask(uint)", asMETHOD(T, SetLightMask), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_lightMask(uint)", asMETHOD(T, SetLightMask), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_lightMask() const", asMETHOD(T, GetLightMask), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_lightMask() const", asMETHOD(T, GetLightMask), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void set_zoneMask(uint)", asMETHOD(T, SetZoneMask), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "uint get_zoneMask() const", asMETHOD(T, GetZoneMask), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_maxLights(uint)", asMETHOD(T, SetMaxLights), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_maxLights(uint)", asMETHOD(T, SetMaxLights), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_maxLights() const", asMETHOD(T, GetMaxLights), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_maxLights() const", asMETHOD(T, GetMaxLights), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "const BoundingBox& get_worldBoundingBox()", asMETHOD(T, GetWorldBoundingBox), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "const BoundingBox& get_worldBoundingBox()", asMETHOD(T, GetWorldBoundingBox), asCALL_THISCALL);

+ 1 - 1
Engine/Graphics/BillboardSet.h

@@ -118,7 +118,7 @@ public:
     const PODVector<unsigned char>& GetNetBillboardsAttr() const;
     const PODVector<unsigned char>& GetNetBillboardsAttr() const;
     
     
 protected:
 protected:
-    /// Transform has changed. Mark billboards dirty if necessary.
+    /// Handle node transform being dirtied. Mark billboards dirty if necessary.
     virtual void OnMarkedDirty(Node* node);
     virtual void OnMarkedDirty(Node* node);
     /// Recalculate the world-space bounding box.
     /// Recalculate the world-space bounding box.
     virtual void OnWorldBoundingBoxUpdate();
     virtual void OnWorldBoundingBoxUpdate();

+ 9 - 0
Engine/Graphics/Drawable.cpp

@@ -47,6 +47,7 @@ Drawable::Drawable(Context* context) :
     lodBias_(1.0f),
     lodBias_(1.0f),
     viewMask_(DEFAULT_VIEWMASK),
     viewMask_(DEFAULT_VIEWMASK),
     lightMask_(DEFAULT_LIGHTMASK),
     lightMask_(DEFAULT_LIGHTMASK),
+    zoneMask_(DEFAULT_ZONEMASK),
     maxLights_(0),
     maxLights_(0),
     drawableFlags_(0),
     drawableFlags_(0),
     visible_(true),
     visible_(true),
@@ -73,6 +74,7 @@ void Drawable::RegisterObject(Context* context)
     ATTRIBUTE(Drawable, VAR_INT, "Max Lights", maxLights_, 0, AM_DEFAULT);
     ATTRIBUTE(Drawable, VAR_INT, "Max Lights", maxLights_, 0, AM_DEFAULT);
     ATTRIBUTE(Drawable, VAR_INT, "View Mask", viewMask_, DEFAULT_VIEWMASK, AM_DEFAULT);
     ATTRIBUTE(Drawable, VAR_INT, "View Mask", viewMask_, DEFAULT_VIEWMASK, AM_DEFAULT);
     ATTRIBUTE(Drawable, VAR_INT, "Light Mask", lightMask_, DEFAULT_LIGHTMASK, AM_DEFAULT);
     ATTRIBUTE(Drawable, VAR_INT, "Light Mask", lightMask_, DEFAULT_LIGHTMASK, AM_DEFAULT);
+    ACCESSOR_ATTRIBUTE(Drawable, VAR_INT, "Zone Mask", GetZoneMask, SetZoneMask, unsigned, DEFAULT_ZONEMASK, AM_DEFAULT);
 }
 }
 
 
 void Drawable::ProcessRayQuery(RayOctreeQuery& query, float initialDistance)
 void Drawable::ProcessRayQuery(RayOctreeQuery& query, float initialDistance)
@@ -129,6 +131,13 @@ void Drawable::SetLightMask(unsigned mask)
     lightMask_ = mask;
     lightMask_ = mask;
 }
 }
 
 
+void Drawable::SetZoneMask(unsigned mask)
+{
+    zoneMask_ = mask;
+    // Mark dirty to reset cached zone
+    OnMarkedDirty(node_);
+}
+
 void Drawable::SetMaxLights(unsigned num)
 void Drawable::SetMaxLights(unsigned num)
 {
 {
     maxLights_ = num;
     maxLights_ = num;

+ 8 - 1
Engine/Graphics/Drawable.h

@@ -34,6 +34,7 @@ static const unsigned DRAWABLE_ZONE = 0x4;
 static const unsigned DRAWABLE_ANY = 0xff;
 static const unsigned DRAWABLE_ANY = 0xff;
 static const unsigned DEFAULT_VIEWMASK = M_MAX_UNSIGNED;
 static const unsigned DEFAULT_VIEWMASK = M_MAX_UNSIGNED;
 static const unsigned DEFAULT_LIGHTMASK = M_MAX_UNSIGNED;
 static const unsigned DEFAULT_LIGHTMASK = M_MAX_UNSIGNED;
+static const unsigned DEFAULT_ZONEMASK = M_MAX_UNSIGNED;
 
 
 struct Batch;
 struct Batch;
 class Camera;
 class Camera;
@@ -99,8 +100,10 @@ public:
     void SetLodBias(float bias);
     void SetLodBias(float bias);
     /// %Set view mask. Will be and'ed with camera's view mask to see if the object should be rendered.
     /// %Set view mask. Will be and'ed with camera's view mask to see if the object should be rendered.
     void SetViewMask(unsigned mask);
     void SetViewMask(unsigned mask);
-    /// %Set light mask. Will be and'ed with light's light mask to see if the object should be lit.
+    /// %Set light mask. Will be and'ed with light's and zone's light mask to see if the object should be lit.
     void SetLightMask(unsigned mask);
     void SetLightMask(unsigned mask);
+    /// %Set zone mask. Will be and'ed with zone's zone mask to see if the object should belong to the zone.
+    void SetZoneMask(unsigned mask);
     /// %Set maximum number of lights. Default 0 is unlimited.
     /// %Set maximum number of lights. Default 0 is unlimited.
     void SetMaxLights(unsigned num);
     void SetMaxLights(unsigned num);
     /// %Set visible flag.
     /// %Set visible flag.
@@ -126,6 +129,8 @@ public:
     unsigned GetViewMask() const { return viewMask_; }
     unsigned GetViewMask() const { return viewMask_; }
     /// Return light mask.
     /// Return light mask.
     unsigned GetLightMask() const { return lightMask_; }
     unsigned GetLightMask() const { return lightMask_; }
+    /// Return zone mask.
+    unsigned GetZoneMask() const { return zoneMask_; }
     /// Return maximum number of lights.
     /// Return maximum number of lights.
     unsigned GetMaxLights() const { return maxLights_; }
     unsigned GetMaxLights() const { return maxLights_; }
     /// Return visible flag.
     /// Return visible flag.
@@ -206,6 +211,8 @@ protected:
     unsigned viewMask_;
     unsigned viewMask_;
     /// Light mask.
     /// Light mask.
     unsigned lightMask_;
     unsigned lightMask_;
+    /// Zone mask.
+    unsigned zoneMask_;
     /// Maximum lights.
     /// Maximum lights.
     unsigned maxLights_;
     unsigned maxLights_;
     /// Drawable flags.
     /// Drawable flags.

+ 136 - 107
Engine/Graphics/View.cpp

@@ -65,6 +65,7 @@ View::View(Context* context) :
     octree_(0),
     octree_(0),
     camera_(0),
     camera_(0),
     cameraZone_(0),
     cameraZone_(0),
+    farClipZone_(0),
     renderTarget_(0),
     renderTarget_(0),
     depthStencil_(0)
     depthStencil_(0)
 {
 {
@@ -226,135 +227,162 @@ void View::Render()
     camera_ = 0;
     camera_ = 0;
     octree_ = 0;
     octree_ = 0;
     cameraZone_ = 0;
     cameraZone_ = 0;
+    farClipZone_ = 0;
     frame_.camera_ = 0;
     frame_.camera_ = 0;
 }
 }
 
 
 void View::GetDrawables()
 void View::GetDrawables()
 {
 {
-    PROFILE(GetDrawables);
-    
-    Vector3 cameraPos = camera_->GetWorldPosition();
-    
-    // Get default zone first in case we do not have anything else
-    Zone* defaultZone = renderer_->GetDefaultZone();
-    cameraZone_ = defaultZone;
-    
-    FrustumOctreeQuery query(reinterpret_cast<PODVector<Drawable*>&>(zones_), frustum_, DRAWABLE_ZONE);
-    octree_->GetDrawables(query);
-    
-    // Find the visible zones, and the zone the camera is in. Determine also the highest zone priority to aid in seeing whether
-    // a zone query result is conclusive
     int highestZonePriority = M_MIN_INT;
     int highestZonePriority = M_MIN_INT;
-    int bestPriority = M_MIN_INT;
-    for (PODVector<Zone*>::Iterator i = zones_.Begin(); i != zones_.End(); ++i)
-    {
-        int priority = (*i)->GetPriority();
-        if (priority > highestZonePriority)
-            highestZonePriority = priority;
-        if ((*i)->IsInside(cameraPos) && priority > bestPriority)
-        {
-            cameraZone_ = *i;
-            bestPriority = priority;
-        }
-    }
     
     
-    // If occlusion in use, get & render the occluders, then build the depth buffer hierarchy
-    OcclusionBuffer* buffer = 0;
-    
-    if (maxOccluderTriangles_ > 0)
     {
     {
-        FrustumOctreeQuery query(occluders_, frustum_, DRAWABLE_GEOMETRY, camera_->GetViewMask(), true, false);
+        PROFILE(GetZones);
+        
+        // Get default zone first in case we do not have zones defined
+        Zone* defaultZone = renderer_->GetDefaultZone();
+        cameraZone_ = farClipZone_ = defaultZone;
+        
+        FrustumOctreeQuery query(reinterpret_cast<PODVector<Drawable*>&>(zones_), frustum_, DRAWABLE_ZONE);
         octree_->GetDrawables(query);
         octree_->GetDrawables(query);
-        UpdateOccluders(occluders_, camera_);
         
         
-        if (occluders_.Size())
+        // Find the visible zones, and the zone the camera is in. Determine also the highest zone priority to aid in seeing
+        // whether a zone query result for a drawable is conclusive
+        int bestPriority = M_MIN_INT;
+        Vector3 cameraPos = camera_->GetWorldPosition();
+        
+        for (PODVector<Zone*>::Iterator i = zones_.Begin(); i != zones_.End(); ++i)
         {
         {
-            buffer = renderer_->GetOrCreateOcclusionBuffer(camera_, maxOccluderTriangles_);
-            DrawOccluders(buffer, occluders_);
-            buffer->BuildDepthHierarchy();
+            int priority = (*i)->GetPriority();
+            if (priority > highestZonePriority)
+                highestZonePriority = priority;
+            if ((*i)->IsInside(cameraPos) && priority > bestPriority)
+            {
+                cameraZone_ = *i;
+                bestPriority = priority;
+            }
         }
         }
+        
+        // Determine the zone at far clip distance. If not found, or camera zone has override mode, use camera zone
+        cameraZoneOverride_ = cameraZone_->GetOverride();
+        if (!cameraZoneOverride_)
+        {
+            Vector3 farClipPos = cameraPos + camera_->GetNode()->GetWorldDirection() * Vector3(0, 0, camera_->GetFarClip());
+            bestPriority = M_MIN_INT;
+            
+            for (PODVector<Zone*>::Iterator i = zones_.Begin(); i != zones_.End(); ++i)
+            {
+                int priority = (*i)->GetPriority();
+                if ((*i)->IsInside(farClipPos) && priority > bestPriority)
+                {
+                    farClipZone_ = *i;
+                    bestPriority = priority;
+                }
+            }
+        }
+        if (farClipZone_ == defaultZone)
+            farClipZone_ = cameraZone_;
     }
     }
     
     
-    if (!buffer)
-    {
-        // Get geometries & lights without occlusion
-        FrustumOctreeQuery query(tempDrawables_, frustum_, DRAWABLE_GEOMETRY | DRAWABLE_LIGHT);
-        octree_->GetDrawables(query);
-    }
-    else
-    {
-        // Get geometries & lights using occlusion
-        OccludedFrustumOctreeQuery query(tempDrawables_, frustum_, buffer, DRAWABLE_GEOMETRY | DRAWABLE_LIGHT,
-            camera_->GetViewMask());
-        octree_->GetDrawables(query);
-    }
-    
-    // Add unculled geometries & lights
-    octree_->GetUnculledDrawables(tempDrawables_, DRAWABLE_GEOMETRY | DRAWABLE_LIGHT);
-    
-    // Sort into geometries & lights, and build visible scene bounding boxes in world and view space
-    sceneBox_.min_ = sceneBox_.max_ = Vector3::ZERO;
-    sceneBox_.defined_ = false;
-    sceneViewBox_.min_ = sceneViewBox_.max_ = Vector3::ZERO;
-    sceneViewBox_.defined_ = false;
-    Matrix3x4 view(camera_->GetInverseWorldTransform());
-    
-    for (unsigned i = 0; i < tempDrawables_.Size(); ++i)
     {
     {
-        Drawable* drawable = tempDrawables_[i];
-        drawable->UpdateDistance(frame_);
+        PROFILE(GetDrawables);
         
         
-        // If draw distance non-zero, check it
-        float maxDistance = drawable->GetDrawDistance();
-        if (maxDistance > 0.0f && drawable->GetDistance() > maxDistance)
-            continue;
+        // If occlusion in use, get & render the occluders, then build the depth buffer hierarchy
+        OcclusionBuffer* buffer = 0;
         
         
-        unsigned flags = drawable->GetDrawableFlags();
-        if (flags & DRAWABLE_GEOMETRY)
+        if (maxOccluderTriangles_ > 0)
         {
         {
-            // Find new zone for the drawable if necessary
-            /// \todo Add a zone mask to drawables to be able to exclude zones per-object
-            if (!drawable->GetZone() && !cameraZoneOverride_)
-                FindZone(drawable, highestZonePriority);
-            
-            drawable->ClearLights();
-            drawable->MarkInView(frame_);
-            drawable->UpdateGeometry(frame_);
+            FrustumOctreeQuery query(occluders_, frustum_, DRAWABLE_GEOMETRY, camera_->GetViewMask(), true, false);
+            octree_->GetDrawables(query);
+            UpdateOccluders(occluders_, camera_);
             
             
-            // Expand the scene bounding boxes. However, do not take "infinite" objects such as the skybox into account,
-            // as the bounding boxes are also used for shadow focusing
-            const BoundingBox& geomBox = drawable->GetWorldBoundingBox();
-            BoundingBox geomViewBox = geomBox.Transformed(view);
-            if (geomBox.Size().LengthFast() < M_LARGE_VALUE)
+            if (occluders_.Size())
             {
             {
-                sceneBox_.Merge(geomBox);
-                sceneViewBox_.Merge(geomViewBox);
+                buffer = renderer_->GetOrCreateOcclusionBuffer(camera_, maxOccluderTriangles_);
+                DrawOccluders(buffer, occluders_);
+                buffer->BuildDepthHierarchy();
             }
             }
+        }
+        
+        if (!buffer)
+        {
+            // Get geometries & lights without occlusion
+            FrustumOctreeQuery query(tempDrawables_, frustum_, DRAWABLE_GEOMETRY | DRAWABLE_LIGHT);
+            octree_->GetDrawables(query);
+        }
+        else
+        {
+            // Get geometries & lights using occlusion
+            OccludedFrustumOctreeQuery query(tempDrawables_, frustum_, buffer, DRAWABLE_GEOMETRY | DRAWABLE_LIGHT,
+                camera_->GetViewMask());
+            octree_->GetDrawables(query);
+        }
+        
+        // Add unculled geometries & lights
+        octree_->GetUnculledDrawables(tempDrawables_, DRAWABLE_GEOMETRY | DRAWABLE_LIGHT);
+        
+        // Sort into geometries & lights, and build visible scene bounding boxes in world and view space
+        sceneBox_.min_ = sceneBox_.max_ = Vector3::ZERO;
+        sceneBox_.defined_ = false;
+        sceneViewBox_.min_ = sceneViewBox_.max_ = Vector3::ZERO;
+        sceneViewBox_.defined_ = false;
+        Matrix3x4 view(camera_->GetInverseWorldTransform());
+        
+        for (unsigned i = 0; i < tempDrawables_.Size(); ++i)
+        {
+            Drawable* drawable = tempDrawables_[i];
+            drawable->UpdateDistance(frame_);
             
             
-            // Store depth info for split directional light queries
-            GeometryDepthBounds bounds;
-            bounds.min_ = geomViewBox.min_.z_;
-            bounds.max_ = geomViewBox.max_.z_;
+            // If draw distance non-zero, check it
+            float maxDistance = drawable->GetDrawDistance();
+            if (maxDistance > 0.0f && drawable->GetDistance() > maxDistance)
+                continue;
             
             
-            geometryDepthBounds_.Push(bounds);
-            geometries_.Push(drawable);
+            unsigned flags = drawable->GetDrawableFlags();
+            if (flags & DRAWABLE_GEOMETRY)
+            {
+                // Find new zone for the drawable if necessary
+                if (!drawable->GetZone() && !cameraZoneOverride_)
+                    FindZone(drawable, highestZonePriority);
+                
+                drawable->ClearLights();
+                drawable->MarkInView(frame_);
+                drawable->UpdateGeometry(frame_);
+                
+                // Expand the scene bounding boxes. However, do not take "infinite" objects such as the skybox into account,
+                // as the bounding boxes are also used for shadow focusing
+                const BoundingBox& geomBox = drawable->GetWorldBoundingBox();
+                BoundingBox geomViewBox = geomBox.Transformed(view);
+                if (geomBox.Size().LengthFast() < M_LARGE_VALUE)
+                {
+                    sceneBox_.Merge(geomBox);
+                    sceneViewBox_.Merge(geomViewBox);
+                }
+                
+                // Store depth info for split directional light queries
+                GeometryDepthBounds bounds;
+                bounds.min_ = geomViewBox.min_.z_;
+                bounds.max_ = geomViewBox.max_.z_;
+                
+                geometryDepthBounds_.Push(bounds);
+                geometries_.Push(drawable);
+            }
+            else if (flags & DRAWABLE_LIGHT)
+            {
+                Light* light = static_cast<Light*>(drawable);
+                light->MarkInView(frame_);
+                lights_.Push(light);
+            }
         }
         }
-        else if (flags & DRAWABLE_LIGHT)
+        
+        // Sort the lights to brightest/closest first
+        for (unsigned i = 0; i < lights_.Size(); ++i)
         {
         {
-            Light* light = static_cast<Light*>(drawable);
-            light->MarkInView(frame_);
-            lights_.Push(light);
+            Light* light = lights_[i];
+            light->SetIntensitySortValue(camera_->GetDistance(light->GetWorldPosition()));
         }
         }
+        
+        Sort(lights_.Begin(), lights_.End(), CompareDrawables);
     }
     }
-    
-    // Sort the lights to brightest/closest first
-    for (unsigned i = 0; i < lights_.Size(); ++i)
-    {
-        Light* light = lights_[i];
-        light->SetIntensitySortValue(camera_->GetDistance(light->GetWorldPosition()));
-    }
-    
-    Sort(lights_.Begin(), lights_.End(), CompareDrawables);
 }
 }
 
 
 void View::GetBatches()
 void View::GetBatches()
@@ -632,7 +660,7 @@ void View::RenderBatches()
         graphics_->SetRenderTarget(0, renderTarget_);
         graphics_->SetRenderTarget(0, renderTarget_);
         graphics_->SetDepthStencil(depthStencil_);
         graphics_->SetDepthStencil(depthStencil_);
         graphics_->SetViewport(screenRect_);
         graphics_->SetViewport(screenRect_);
-        graphics_->Clear(CLEAR_COLOR | CLEAR_DEPTH | CLEAR_STENCIL, cameraZone_->GetFogColor());
+        graphics_->Clear(CLEAR_COLOR | CLEAR_DEPTH | CLEAR_STENCIL, farClipZone_->GetFogColor());
         
         
         RenderBatchQueue(baseQueue_);
         RenderBatchQueue(baseQueue_);
     }
     }
@@ -1401,7 +1429,8 @@ void View::FindZone(Drawable* drawable, int highestZonePriority)
     
     
     // First check if the last zone remains a conclusive result
     // First check if the last zone remains a conclusive result
     Zone* lastZone = drawable->GetLastZone();
     Zone* lastZone = drawable->GetLastZone();
-    if (lastZone && lastZone->IsInside(center) && lastZone->GetPriority() >= highestZonePriority)
+    if (lastZone && lastZone->IsInside(center) && (drawable->GetZoneMask() & lastZone->GetZoneMask()) && lastZone->GetPriority()
+        >= highestZonePriority)
         drawable->SetZone(lastZone);
         drawable->SetZone(lastZone);
     // Then check if the visible zones contain the node center
     // Then check if the visible zones contain the node center
     else
     else
@@ -1411,14 +1440,14 @@ void View::FindZone(Drawable* drawable, int highestZonePriority)
         for (PODVector<Zone*>::Iterator i = zones_.Begin(); i != zones_.End(); ++i)
         for (PODVector<Zone*>::Iterator i = zones_.Begin(); i != zones_.End(); ++i)
         {
         {
             int priority = (*i)->GetPriority();
             int priority = (*i)->GetPriority();
-            if ((*i)->IsInside(center) && priority > bestPriority)
+            if ((*i)->IsInside(center) && (drawable->GetZoneMask() & (*i)->GetZoneMask()) && priority > bestPriority)
             {
             {
                 newZone = *i;
                 newZone = *i;
                 bestPriority = priority;
                 bestPriority = priority;
             }
             }
         }
         }
         
         
-        // If all else fails, query the octree for zones at node center
+        // Finally, if no zone found yet, query the octree for zones at node center
         if (!newZone)
         if (!newZone)
         {
         {
             PointOctreeQuery query(reinterpret_cast<PODVector<Drawable*>&>(tempZones_), center, DRAWABLE_ZONE);
             PointOctreeQuery query(reinterpret_cast<PODVector<Drawable*>&>(tempZones_), center, DRAWABLE_ZONE);
@@ -1428,7 +1457,7 @@ void View::FindZone(Drawable* drawable, int highestZonePriority)
             for (PODVector<Zone*>::Iterator i = tempZones_.Begin(); i != tempZones_.End(); ++i)
             for (PODVector<Zone*>::Iterator i = tempZones_.Begin(); i != tempZones_.End(); ++i)
             {
             {
                 int priority = (*i)->GetPriority();
                 int priority = (*i)->GetPriority();
-                if ((*i)->IsInside(center) && priority > bestPriority)
+                if ((*i)->IsInside(center) && (drawable->GetZoneMask() & (*i)->GetZoneMask()) && priority > bestPriority)
                 {
                 {
                     newZone = *i;
                     newZone = *i;
                     bestPriority = priority;
                     bestPriority = priority;

+ 2 - 0
Engine/Graphics/View.h

@@ -154,6 +154,8 @@ private:
     Camera* camera_;
     Camera* camera_;
     /// Zone the camera is inside, or default zone if not assigned.
     /// Zone the camera is inside, or default zone if not assigned.
     Zone* cameraZone_;
     Zone* cameraZone_;
+    /// Zone at far clip plane.
+    Zone* farClipZone_;
     /// Color buffer to use.
     /// Color buffer to use.
     RenderSurface* renderTarget_;
     RenderSurface* renderTarget_;
     /// Depth buffer to use.
     /// Depth buffer to use.

+ 21 - 0
Engine/Graphics/Zone.cpp

@@ -23,6 +23,8 @@
 
 
 #include "Precompiled.h"
 #include "Precompiled.h"
 #include "Context.h"
 #include "Context.h"
+#include "Octree.h"
+#include "OctreeQuery.h"
 #include "XMLElement.h"
 #include "XMLElement.h"
 #include "Zone.h"
 #include "Zone.h"
 
 
@@ -63,6 +65,7 @@ void Zone::RegisterObject(Context* context)
     ATTRIBUTE(Zone, VAR_BOOL, "Override Mode", override_, 0, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_BOOL, "Override Mode", override_, 0, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_INT, "Priority", priority_, 0, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_INT, "Priority", priority_, 0, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_INT, "Light Mask", lightMask_, DEFAULT_LIGHTMASK, AM_DEFAULT);
     ATTRIBUTE(Zone, VAR_INT, "Light Mask", lightMask_, DEFAULT_LIGHTMASK, AM_DEFAULT);
+    ACCESSOR_ATTRIBUTE(Zone, VAR_INT, "Zone Mask", GetZoneMask, SetZoneMask, unsigned, DEFAULT_ZONEMASK, AM_DEFAULT);
 }
 }
 
 
 void Zone::OnSetAttribute(const AttributeInfo& attr, const Variant& src)
 void Zone::OnSetAttribute(const AttributeInfo& attr, const Variant& src)
@@ -124,6 +127,24 @@ bool Zone::IsInside(const Vector3& point)
     return boundingBox_.IsInside(localPoint) != OUTSIDE;
     return boundingBox_.IsInside(localPoint) != OUTSIDE;
 }
 }
 
 
+void Zone::OnMarkedDirty(Node* node)
+{
+    Drawable::OnMarkedDirty(node);
+    
+    // When marked dirty, clear the cached zone from all drawables inside the zone bounding box
+    if (octant_ && lastBoundingBox_.defined_)
+    {
+        PODVector<Drawable*> result;
+        BoxOctreeQuery query(result, lastBoundingBox_, DRAWABLE_GEOMETRY);
+        octant_->GetRoot()->GetDrawables(query);
+        
+        for (PODVector<Drawable*>::Iterator i = result.Begin(); i != result.End(); ++i)
+            (*i)->SetZone(0);
+    }
+    
+    lastBoundingBox_ = GetWorldBoundingBox();
+}
+
 void Zone::OnWorldBoundingBoxUpdate()
 void Zone::OnWorldBoundingBoxUpdate()
 {
 {
     worldBoundingBox_ = boundingBox_.Transformed(GetWorldTransform());
     worldBoundingBox_ = boundingBox_.Transformed(GetWorldTransform());

+ 4 - 0
Engine/Graphics/Zone.h

@@ -76,11 +76,15 @@ public:
     virtual bool IsInside(const Vector3& point);
     virtual bool IsInside(const Vector3& point);
     
     
 protected:
 protected:
+    /// Transform has changed. Clear cached zone of any contained drawables.
+    virtual void OnMarkedDirty(Node* node);
     /// Recalculate the world-space bounding box.
     /// Recalculate the world-space bounding box.
     virtual void OnWorldBoundingBoxUpdate();
     virtual void OnWorldBoundingBoxUpdate();
     
     
     /// Bounding box.
     /// Bounding box.
     BoundingBox boundingBox_;
     BoundingBox boundingBox_;
+    /// Last bounding box.
+    BoundingBox lastBoundingBox_;
     /// Ambient color.
     /// Ambient color.
     Color ambientColor_;
     Color ambientColor_;
     /// Fog color.
     /// Fog color.

+ 2 - 2
Engine/Script/Addons.cpp

@@ -96,7 +96,7 @@ static bool ScriptArrayTemplateCallback(asIObjectType* ot)
                 if (beh != asBEHAVE_CONSTRUCT)
                 if (beh != asBEHAVE_CONSTRUCT)
                     continue;
                     continue;
                 
                 
-                asIScriptFunction* func = ot->GetEngine()->GetFunctionById(funcId);
+                asIScriptFunction* func = ot->GetEngine()->GetFunctionDescriptorById(funcId);
                 if (func->GetParamCount() == 0)
                 if (func->GetParamCount() == 0)
                 {
                 {
                     // Found the default constructor
                     // Found the default constructor
@@ -113,7 +113,7 @@ static bool ScriptArrayTemplateCallback(asIObjectType* ot)
             for (unsigned n = 0; n < subtype->GetFactoryCount(); ++n)
             for (unsigned n = 0; n < subtype->GetFactoryCount(); ++n)
             {
             {
                 int funcId = subtype->GetFactoryIdByIndex(n);
                 int funcId = subtype->GetFactoryIdByIndex(n);
-                asIScriptFunction* func = ot->GetEngine()->GetFunctionById(funcId);
+                asIScriptFunction* func = ot->GetEngine()->GetFunctionDescriptorById(funcId);
                 if (func->GetParamCount() == 0)
                 if (func->GetParamCount() == 0)
                 {
                 {
                     // Found the default factory
                     // Found the default factory

+ 3 - 3
Engine/Script/Script.cpp

@@ -221,7 +221,7 @@ void Script::DumpAPI()
     for (unsigned i = 0; i < functions; ++i)
     for (unsigned i = 0; i < functions; ++i)
     {
     {
         unsigned id = scriptEngine_->GetGlobalFunctionIdByIndex(i);
         unsigned id = scriptEngine_->GetGlobalFunctionIdByIndex(i);
-        asIScriptFunction* function = scriptEngine_->GetFunctionById(id);
+        asIScriptFunction* function = scriptEngine_->GetFunctionDescriptorById(id);
         String functionName(function->GetName());
         String functionName(function->GetName());
         String declaration(function->GetDeclaration());
         String declaration(function->GetDeclaration());
         
         
@@ -279,7 +279,7 @@ void Script::DumpAPI()
             unsigned methods = type->GetMethodCount();
             unsigned methods = type->GetMethodCount();
             for (unsigned j = 0; j < methods; ++j)
             for (unsigned j = 0; j < methods; ++j)
             {
             {
-                asIScriptFunction* method = type->GetMethodByIndex(j);
+                asIScriptFunction* method = type->GetMethodDescriptorByIndex(j);
                 String methodName(method->GetName());
                 String methodName(method->GetName());
                 String declaration(method->GetDeclaration());
                 String declaration(method->GetDeclaration());
                 if (methodName.Find("get_") == String::NPOS && methodName.Find("set_") == String::NPOS)
                 if (methodName.Find("get_") == String::NPOS && methodName.Find("set_") == String::NPOS)
@@ -378,7 +378,7 @@ void Script::MessageCallback(const asSMessageInfo* msg)
 void Script::ExceptionCallback(asIScriptContext* context)
 void Script::ExceptionCallback(asIScriptContext* context)
 {
 {
     int funcId = context->GetExceptionFunction();
     int funcId = context->GetExceptionFunction();
-    const asIScriptFunction *function = scriptEngine_->GetFunctionById(funcId);
+    const asIScriptFunction *function = scriptEngine_->GetFunctionDescriptorById(funcId);
     String message = "Exception '" + String(context->GetExceptionString()) + "' in '" +
     String message = "Exception '" + String(context->GetExceptionString()) + "' in '" +
         String(function->GetDeclaration()) + "'";
         String(function->GetDeclaration()) + "'";
     
     

+ 6 - 4
Engine/Script/ScriptFile.cpp

@@ -177,7 +177,7 @@ bool ScriptFile::Execute(asIScriptFunction* function, const VariantVector& param
         return false;
         return false;
     }
     }
     
     
-    if (context->Prepare(function) < 0)
+    if (context->Prepare(function->GetId()) < 0)
         return false;
         return false;
     
     
     SetParameters(context, function, parameters);
     SetParameters(context, function, parameters);
@@ -221,7 +221,7 @@ bool ScriptFile::Execute(asIScriptObject* object, asIScriptFunction* method, con
         return false;
         return false;
     }
     }
     
     
-    if (context->Prepare(method) < 0)
+    if (context->Prepare(method->GetId()) < 0)
         return false;
         return false;
     
     
     context->SetObject(object);
     context->SetObject(object);
@@ -302,7 +302,8 @@ asIScriptFunction* ScriptFile::GetFunction(const String& declaration)
     if (i != functions_.End())
     if (i != functions_.End())
         return i->second_;
         return i->second_;
     
     
-    asIScriptFunction* function = scriptModule_->GetFunctionByDecl(declaration.CString());
+    int id = scriptModule_->GetFunctionIdByDecl(declaration.CString());
+    asIScriptFunction* function = scriptModule_->GetFunctionDescriptorById(id);
     functions_[declaration] = function;
     functions_[declaration] = function;
     return function;
     return function;
 }
 }
@@ -323,7 +324,8 @@ asIScriptFunction* ScriptFile::GetMethod(asIScriptObject* object, const String&
             return j->second_;
             return j->second_;
     }
     }
     
     
-    asIScriptFunction* function = type->GetMethodByDecl(declaration.CString());
+    int id = type->GetMethodIdByDecl(declaration.CString());
+    asIScriptFunction* function = scriptModule_->GetFunctionDescriptorById(id);
     methods_[type][declaration] = function;
     methods_[type][declaration] = function;
     return function;
     return function;
 }
 }

+ 1 - 1
Readme.txt

@@ -34,7 +34,7 @@ Urho3D is greatly inspired by OGRE (http://www.ogre3d.org) and Horde3D
   http://warp.povusers.org/SortComparison/
   http://warp.povusers.org/SortComparison/
 
 
 Urho3D uses the following third-party libraries:
 Urho3D uses the following third-party libraries:
-- AngelScript 2.22.0 WIP (http://www.angelcode.com/angelscript/)
+- AngelScript 2.21.1 (http://www.angelcode.com/angelscript/)
 - FreeType 2.3.12 (http://www.freetype.org/)
 - FreeType 2.3.12 (http://www.freetype.org/)
 - GLee 5.4 (http://elf-stone.com/)
 - GLee 5.4 (http://elf-stone.com/)
 - GLFW 3.0 WIP (http://www.glfw.org/)
 - GLFW 3.0 WIP (http://www.glfw.org/)

+ 21 - 69
ThirdParty/AngelScript/include/angelscript.h

@@ -56,8 +56,8 @@ BEGIN_AS_NAMESPACE
 
 
 // AngelScript version
 // AngelScript version
 
 
-#define ANGELSCRIPT_VERSION        22200
-#define ANGELSCRIPT_VERSION_STRING "2.22.0 WIP"
+#define ANGELSCRIPT_VERSION        22101
+#define ANGELSCRIPT_VERSION_STRING "2.21.1"
 
 
 // Data types
 // Data types
 
 
@@ -91,8 +91,7 @@ enum asEEngineProp
 	asEP_STRING_ENCODING              = 13,
 	asEP_STRING_ENCODING              = 13,
 	asEP_PROPERTY_ACCESSOR_MODE       = 14,
 	asEP_PROPERTY_ACCESSOR_MODE       = 14,
 	asEP_EXPAND_DEF_ARRAY_TO_TMPL     = 15,
 	asEP_EXPAND_DEF_ARRAY_TO_TMPL     = 15,
-	asEP_AUTO_GARBAGE_COLLECT         = 16,
-	asEP_DISALLOW_GLOBAL_VARS         = 17
+	asEP_AUTO_GARBAGE_COLLECT         = 16
 };
 };
 
 
 // Calling conventions
 // Calling conventions
@@ -139,11 +138,8 @@ enum asEObjTypeFlags
 	asOBJ_APP_CLASS_K                = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
 	asOBJ_APP_CLASS_K                = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
 	asOBJ_APP_PRIMITIVE              = 0x2000,
 	asOBJ_APP_PRIMITIVE              = 0x2000,
 	asOBJ_APP_FLOAT                  = 0x4000,
 	asOBJ_APP_FLOAT                  = 0x4000,
-	asOBJ_APP_CLASS_ALLINTS          = 0x8000,
-	asOBJ_APP_CLASS_ALLFLOATS        = 0x10000,
-	asOBJ_MASK_VALID_FLAGS           = 0x1FFFF,
-	asOBJ_SCRIPT_OBJECT              = 0x80000,
-	asOBJ_SHARED                     = 0x100000
+	asOBJ_MASK_VALID_FLAGS           = 0x7FFF,
+	asOBJ_SCRIPT_OBJECT              = 0x10000
 };
 };
 
 
 // Behaviours
 // Behaviours
@@ -347,10 +343,8 @@ typedef void (*asGENFUNC_t)(asIScriptGeneric *);
 typedef void *(*asALLOCFUNC_t)(size_t);
 typedef void *(*asALLOCFUNC_t)(size_t);
 typedef void (*asFREEFUNC_t)(void *);
 typedef void (*asFREEFUNC_t)(void *);
 typedef void (*asCLEANENGINEFUNC_t)(asIScriptEngine *);
 typedef void (*asCLEANENGINEFUNC_t)(asIScriptEngine *);
-typedef void (*asCLEANMODULEFUNC_t)(asIScriptModule *);
 typedef void (*asCLEANCONTEXTFUNC_t)(asIScriptContext *);
 typedef void (*asCLEANCONTEXTFUNC_t)(asIScriptContext *);
 typedef void (*asCLEANFUNCTIONFUNC_t)(asIScriptFunction *);
 typedef void (*asCLEANFUNCTIONFUNC_t)(asIScriptFunction *);
-typedef void (*asCLEANOBJECTTYPEFUNC_t)(asIObjectType *);
 
 
 #define asFUNCTION(f) asFunctionPtr(f)
 #define asFUNCTION(f) asFunctionPtr(f)
 #if (defined(_MSC_VER) && _MSC_VER <= 1200) || (defined(__BORLANDC__) && __BORLANDC__ < 0x590)
 #if (defined(_MSC_VER) && _MSC_VER <= 1200) || (defined(__BORLANDC__) && __BORLANDC__ < 0x590)
@@ -498,16 +492,14 @@ public:
 	virtual asIJITCompiler *GetJITCompiler() const = 0;
 	virtual asIJITCompiler *GetJITCompiler() const = 0;
 
 
 	// Global functions
 	// Global functions
-	virtual int                RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0;
-	virtual asUINT             GetGlobalFunctionCount() const = 0;
-	virtual int                GetGlobalFunctionIdByIndex(asUINT index) const = 0;
-	virtual asIScriptFunction *GetGlobalFunctionByIndex(asUINT index) const = 0;
-	virtual asIScriptFunction *GetGlobalFunctionByDecl(const char *declaration) const = 0;
+	virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0;
+	virtual int GetGlobalFunctionCount() const = 0;
+	virtual int GetGlobalFunctionIdByIndex(asUINT index) const = 0;
 
 
 	// Global properties
 	// Global properties
-	virtual int    RegisterGlobalProperty(const char *declaration, void *pointer) = 0;
-	virtual asUINT GetGlobalPropertyCount() const = 0;
-	virtual int    GetGlobalPropertyByIndex(asUINT index, const char **name, int *typeId = 0, bool *isConst = 0, const char **configGroup = 0, void **pointer = 0) const = 0;
+	virtual int RegisterGlobalProperty(const char *declaration, void *pointer) = 0;
+	virtual int GetGlobalPropertyCount() const = 0;
+	virtual int GetGlobalPropertyByIndex(asUINT index, const char **name, int *typeId = 0, bool *isConst = 0, const char **configGroup = 0, void **pointer = 0) const = 0;
 
 
 	// Object types
 	// Object types
 	virtual int            RegisterObjectType(const char *obj, int byteSize, asDWORD flags) = 0;
 	virtual int            RegisterObjectType(const char *obj, int byteSize, asDWORD flags) = 0;
@@ -516,7 +508,7 @@ public:
 	virtual int            RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0;
 	virtual int            RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0;
 	virtual int            RegisterInterface(const char *name) = 0;
 	virtual int            RegisterInterface(const char *name) = 0;
 	virtual int            RegisterInterfaceMethod(const char *intf, const char *declaration) = 0;
 	virtual int            RegisterInterfaceMethod(const char *intf, const char *declaration) = 0;
-	virtual asUINT         GetObjectTypeCount() const = 0;
+	virtual int            GetObjectTypeCount() const = 0;
 	virtual asIObjectType *GetObjectTypeByIndex(asUINT index) const = 0;
 	virtual asIObjectType *GetObjectTypeByIndex(asUINT index) const = 0;
 
 
 	// String factory
 	// String factory
@@ -530,41 +522,33 @@ public:
 	// Enums
 	// Enums
 	virtual int         RegisterEnum(const char *type) = 0;
 	virtual int         RegisterEnum(const char *type) = 0;
 	virtual int         RegisterEnumValue(const char *type, const char *name, int value) = 0;
 	virtual int         RegisterEnumValue(const char *type, const char *name, int value) = 0;
-	virtual asUINT      GetEnumCount() const = 0;
+	virtual int         GetEnumCount() const = 0;
 	virtual const char *GetEnumByIndex(asUINT index, int *enumTypeId, const char **configGroup = 0) const = 0;
 	virtual const char *GetEnumByIndex(asUINT index, int *enumTypeId, const char **configGroup = 0) const = 0;
 	virtual int         GetEnumValueCount(int enumTypeId) const = 0;
 	virtual int         GetEnumValueCount(int enumTypeId) const = 0;
 	virtual const char *GetEnumValueByIndex(int enumTypeId, asUINT index, int *outValue) const = 0;
 	virtual const char *GetEnumValueByIndex(int enumTypeId, asUINT index, int *outValue) const = 0;
 
 
 	// Funcdefs
 	// Funcdefs
 	virtual int                RegisterFuncdef(const char *decl) = 0;
 	virtual int                RegisterFuncdef(const char *decl) = 0;
-	virtual asUINT             GetFuncdefCount() const = 0;
+	virtual int                GetFuncdefCount() const = 0;
 	virtual asIScriptFunction *GetFuncdefByIndex(asUINT index, const char **configGroup = 0) const = 0;
 	virtual asIScriptFunction *GetFuncdefByIndex(asUINT index, const char **configGroup = 0) const = 0;
 
 
 	// Typedefs
 	// Typedefs
 	virtual int         RegisterTypedef(const char *type, const char *decl) = 0;
 	virtual int         RegisterTypedef(const char *type, const char *decl) = 0;
-	virtual asUINT      GetTypedefCount() const = 0;
+	virtual int         GetTypedefCount() const = 0;
 	virtual const char *GetTypedefByIndex(asUINT index, int *typeId, const char **configGroup = 0) const = 0;
 	virtual const char *GetTypedefByIndex(asUINT index, int *typeId, const char **configGroup = 0) const = 0;
 
 
 	// Configuration groups
 	// Configuration groups
 	virtual int BeginConfigGroup(const char *groupName) = 0;
 	virtual int BeginConfigGroup(const char *groupName) = 0;
 	virtual int EndConfigGroup() = 0;
 	virtual int EndConfigGroup() = 0;
 	virtual int RemoveConfigGroup(const char *groupName) = 0;
 	virtual int RemoveConfigGroup(const char *groupName) = 0;
-	virtual asDWORD SetDefaultAccessMask(asDWORD defaultMask) = 0;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-04
 	virtual int SetConfigGroupModuleAccess(const char *groupName, const char *module, bool hasAccess) = 0;
 	virtual int SetConfigGroupModuleAccess(const char *groupName, const char *module, bool hasAccess) = 0;
-#endif
 
 
 	// Script modules
 	// Script modules
 	virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag = asGM_ONLY_IF_EXISTS) = 0;
 	virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag = asGM_ONLY_IF_EXISTS) = 0;
 	virtual int              DiscardModule(const char *module) = 0;
 	virtual int              DiscardModule(const char *module) = 0;
 
 
 	// Script functions
 	// Script functions
-	virtual asIScriptFunction *GetFunctionById(int funcId) const = 0;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-03
 	virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) const = 0;
 	virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) const = 0;
-#endif
 
 
 	// Type identification
 	// Type identification
 	virtual asIObjectType *GetObjectTypeById(int typeId) const = 0;
 	virtual asIObjectType *GetObjectTypeById(int typeId) const = 0;
@@ -594,10 +578,8 @@ public:
 	virtual void *SetUserData(void *data) = 0;
 	virtual void *SetUserData(void *data) = 0;
 	virtual void *GetUserData() const = 0;
 	virtual void *GetUserData() const = 0;
 	virtual void  SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback) = 0;
 	virtual void  SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback) = 0;
-	virtual void  SetModuleUserDataCleanupCallback(asCLEANMODULEFUNC_t callback) = 0;
 	virtual void  SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback) = 0;
 	virtual void  SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback) = 0;
 	virtual void  SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback) = 0;
 	virtual void  SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback) = 0;
-	virtual void  SetObjectTypeUserDataCleanupCallback(asCLEANOBJECTTYPEFUNC_t callback) = 0;
 
 
 protected:
 protected:
 	virtual ~asIScriptEngine() {}
 	virtual ~asIScriptEngine() {}
@@ -611,25 +593,18 @@ public:
 	virtual const char      *GetName() const = 0;
 	virtual const char      *GetName() const = 0;
 
 
 	// Compilation
 	// Compilation
-	virtual int     AddScriptSection(const char *name, const char *code, size_t codeLength = 0, int lineOffset = 0) = 0;
-	virtual int     Build() = 0;
-	virtual int     CompileFunction(const char *sectionName, const char *code, int lineOffset, asDWORD compileFlags, asIScriptFunction **outFunc) = 0;
-	virtual int     CompileGlobalVar(const char *sectionName, const char *code, int lineOffset) = 0;
-	virtual asDWORD SetAccessMask(asDWORD accessMask) = 0;
+	virtual int  AddScriptSection(const char *name, const char *code, size_t codeLength = 0, int lineOffset = 0) = 0;
+	virtual int  Build() = 0;
+	virtual int  CompileFunction(const char *sectionName, const char *code, int lineOffset, asDWORD compileFlags, asIScriptFunction **outFunc) = 0;
+	virtual int  CompileGlobalVar(const char *sectionName, const char *code, int lineOffset) = 0;
 
 
 	// Functions
 	// Functions
 	virtual asUINT             GetFunctionCount() const = 0;
 	virtual asUINT             GetFunctionCount() const = 0;
 	virtual int                GetFunctionIdByIndex(asUINT index) const = 0;
 	virtual int                GetFunctionIdByIndex(asUINT index) const = 0;
 	virtual int                GetFunctionIdByName(const char *name) const = 0;
 	virtual int                GetFunctionIdByName(const char *name) const = 0;
 	virtual int                GetFunctionIdByDecl(const char *decl) const = 0;
 	virtual int                GetFunctionIdByDecl(const char *decl) const = 0;
-	virtual asIScriptFunction *GetFunctionByIndex(asUINT index) const = 0;
-	virtual asIScriptFunction *GetFunctionByDecl(const char *decl) const = 0;
-	virtual asIScriptFunction *GetFunctionByName(const char *name) const = 0;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-03
 	virtual asIScriptFunction *GetFunctionDescriptorByIndex(asUINT index) const = 0;
 	virtual asIScriptFunction *GetFunctionDescriptorByIndex(asUINT index) const = 0;
 	virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) const = 0;
 	virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) const = 0;
-#endif
 	virtual int                RemoveFunction(int funcId) = 0;
 	virtual int                RemoveFunction(int funcId) = 0;
 
 
 	// Global variables
 	// Global variables
@@ -671,10 +646,6 @@ public:
 	virtual int SaveByteCode(asIBinaryStream *out) const = 0;
 	virtual int SaveByteCode(asIBinaryStream *out) const = 0;
 	virtual int LoadByteCode(asIBinaryStream *in) = 0;
 	virtual int LoadByteCode(asIBinaryStream *in) = 0;
 
 
-	// User data
-	virtual void *SetUserData(void *data) = 0;
-	virtual void *GetUserData() const = 0;
-
 protected:
 protected:
 	virtual ~asIScriptModule() {}
 	virtual ~asIScriptModule() {}
 };
 };
@@ -690,7 +661,6 @@ public:
 	virtual asIScriptEngine *GetEngine() const = 0;
 	virtual asIScriptEngine *GetEngine() const = 0;
 
 
 	// Execution
 	// Execution
-	virtual int             Prepare(asIScriptFunction *func) = 0;
 	virtual int             Prepare(int funcId) = 0;
 	virtual int             Prepare(int funcId) = 0;
 	virtual int             Unprepare() = 0;
 	virtual int             Unprepare() = 0;
 	virtual int             SetObject(void *obj) = 0;
 	virtual int             SetObject(void *obj) = 0;
@@ -758,11 +728,7 @@ public:
 	// Miscellaneous
 	// Miscellaneous
 	virtual asIScriptEngine   *GetEngine() const = 0;
 	virtual asIScriptEngine   *GetEngine() const = 0;
 	virtual int                GetFunctionId() const = 0;
 	virtual int                GetFunctionId() const = 0;
-	virtual asIScriptFunction *GetFunction() const = 0;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-03
 	virtual asIScriptFunction *GetFunctionDescriptor() const = 0;
 	virtual asIScriptFunction *GetFunctionDescriptor() const = 0;
-#endif
 	virtual void              *GetFunctionUserData() const = 0;
 	virtual void              *GetFunctionUserData() const = 0;
 
 
 	// Object
 	// Object
@@ -810,7 +776,7 @@ public:
 	virtual asIObjectType *GetObjectType() const = 0;
 	virtual asIObjectType *GetObjectType() const = 0;
 
 
 	// Class properties
 	// Class properties
-	virtual asUINT      GetPropertyCount() const = 0;
+	virtual int         GetPropertyCount() const = 0;
 	virtual int         GetPropertyTypeId(asUINT prop) const = 0;
 	virtual int         GetPropertyTypeId(asUINT prop) const = 0;
 	virtual const char *GetPropertyName(asUINT prop) const = 0;
 	virtual const char *GetPropertyName(asUINT prop) const = 0;
 	virtual void       *GetAddressOfProperty(asUINT prop) = 0;
 	virtual void       *GetAddressOfProperty(asUINT prop) = 0;
@@ -848,21 +814,13 @@ public:
 	virtual asUINT             GetFactoryCount() const = 0;
 	virtual asUINT             GetFactoryCount() const = 0;
 	virtual int                GetFactoryIdByIndex(asUINT index) const = 0;
 	virtual int                GetFactoryIdByIndex(asUINT index) const = 0;
 	virtual int                GetFactoryIdByDecl(const char *decl) const = 0;
 	virtual int                GetFactoryIdByDecl(const char *decl) const = 0;
-	virtual asIScriptFunction *GetFactoryByIndex(asUINT index) const = 0;
-	virtual asIScriptFunction *GetFactoryByDecl(const char *decl) const = 0;
 
 
 	// Methods
 	// Methods
 	virtual asUINT             GetMethodCount() const = 0;
 	virtual asUINT             GetMethodCount() const = 0;
 	virtual int                GetMethodIdByIndex(asUINT index, bool getVirtual = true) const = 0;
 	virtual int                GetMethodIdByIndex(asUINT index, bool getVirtual = true) const = 0;
 	virtual int                GetMethodIdByName(const char *name, bool getVirtual = true) const = 0;
 	virtual int                GetMethodIdByName(const char *name, bool getVirtual = true) const = 0;
 	virtual int                GetMethodIdByDecl(const char *decl, bool getVirtual = true) const = 0;
 	virtual int                GetMethodIdByDecl(const char *decl, bool getVirtual = true) const = 0;
-	virtual asIScriptFunction *GetMethodByIndex(asUINT index, bool getVirtual = true) const = 0;
-	virtual asIScriptFunction *GetMethodByName(const char *name, bool getVirtual = true) const = 0;
-	virtual asIScriptFunction *GetMethodByDecl(const char *decl, bool getVirtual = true) const = 0;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-03
 	virtual asIScriptFunction *GetMethodDescriptorByIndex(asUINT index, bool getVirtual = true) const = 0;
 	virtual asIScriptFunction *GetMethodDescriptorByIndex(asUINT index, bool getVirtual = true) const = 0;
-#endif
 
 
 	// Properties
 	// Properties
 	virtual asUINT      GetPropertyCount() const = 0;
 	virtual asUINT      GetPropertyCount() const = 0;
@@ -873,10 +831,6 @@ public:
 	virtual asUINT GetBehaviourCount() const = 0;
 	virtual asUINT GetBehaviourCount() const = 0;
 	virtual int    GetBehaviourByIndex(asUINT index, asEBehaviours *outBehaviour) const = 0;
 	virtual int    GetBehaviourByIndex(asUINT index, asEBehaviours *outBehaviour) const = 0;
 
 
-	// User data
-	virtual void *SetUserData(void *data) = 0;
-	virtual void *GetUserData() const = 0;
-
 protected:
 protected:
 	virtual ~asIObjectType() {}
 	virtual ~asIObjectType() {}
 };
 };
@@ -995,9 +949,7 @@ struct asSMethodPtr
 		// as it would mean that the size of the method pointer cannot be determined.
 		// as it would mean that the size of the method pointer cannot be determined.
 
 
 		int ERROR_UnsupportedMethodPtr[N-100];
 		int ERROR_UnsupportedMethodPtr[N-100];
-
-		asSFuncPtr p;
-		return p;
+		return 0;
 	}
 	}
 };
 };
 
 

+ 36 - 245
ThirdParty/AngelScript/source/as_builder.cpp

@@ -427,7 +427,6 @@ void asCBuilder::ParseScripts()
 		for( n = 0; n < interfaceDeclarations.GetLength(); n++ )
 		for( n = 0; n < interfaceDeclarations.GetLength(); n++ )
 		{
 		{
 			sClassDeclaration *decl = interfaceDeclarations[n];
 			sClassDeclaration *decl = interfaceDeclarations[n];
-			if( decl->isExistingShared ) continue; // TODO: shared: Should really verify that the methods match the original
 
 
 			asCScriptNode *node = decl->node->firstChild->next;
 			asCScriptNode *node = decl->node->firstChild->next;
 			while( node )
 			while( node )
@@ -451,7 +450,6 @@ void asCBuilder::ParseScripts()
 		for( n = 0; n < classDeclarations.GetLength(); n++ )
 		for( n = 0; n < classDeclarations.GetLength(); n++ )
 		{
 		{
 			sClassDeclaration *decl = classDeclarations[n];
 			sClassDeclaration *decl = classDeclarations[n];
-			if( decl->isExistingShared ) continue; // TODO: shared: Should really verify that the methods match the original
 
 
 			asCScriptNode *node = decl->node->firstChild->next;
 			asCScriptNode *node = decl->node->firstChild->next;
 
 
@@ -671,29 +669,22 @@ asCObjectProperty *asCBuilder::GetObjectProperty(asCDataType &obj, const char *p
 {
 {
 	asASSERT(obj.GetObjectType() != 0);
 	asASSERT(obj.GetObjectType() != 0);
 
 
+	// TODO: Only search in config groups to which the module has access
 	// TODO: optimize: Improve linear search
 	// TODO: optimize: Improve linear search
 	asCArray<asCObjectProperty *> &props = obj.GetObjectType()->properties;
 	asCArray<asCObjectProperty *> &props = obj.GetObjectType()->properties;
 	for( asUINT n = 0; n < props.GetLength(); n++ )
 	for( asUINT n = 0; n < props.GetLength(); n++ )
-	{
 		if( props[n]->name == prop )
 		if( props[n]->name == prop )
-		{
-			if( module->accessMask & props[n]->accessMask )
-				return props[n];
-			else
-				return 0;
-		}
-	}
+			return props[n];
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-asCGlobalProperty *asCBuilder::GetGlobalProperty(const char *prop, bool *isCompiled, bool *isPureConstant, asQWORD *constantValue, bool *isAppProp)
+asCGlobalProperty *asCBuilder::GetGlobalProperty(const char *prop, bool *isCompiled, bool *isPureConstant, asQWORD *constantValue)
 {
 {
 	asUINT n;
 	asUINT n;
 
 
 	if( isCompiled ) *isCompiled = true;
 	if( isCompiled ) *isCompiled = true;
 	if( isPureConstant ) *isPureConstant = false;
 	if( isPureConstant ) *isPureConstant = false;
-	if( isAppProp ) *isAppProp = false;
 
 
 	// TODO: optimize: Improve linear search
 	// TODO: optimize: Improve linear search
 	// Check application registered properties
 	// Check application registered properties
@@ -703,24 +694,14 @@ asCGlobalProperty *asCBuilder::GetGlobalProperty(const char *prop, bool *isCompi
 		{
 		{
 			if( module )
 			if( module )
 			{
 			{
-				// Determine if the module has access to the property
-				if( module->accessMask & (*props)[n]->accessMask )
-				{
-#ifdef AS_DEPRECATED
-					// deprecated since 2011-10-04
-					// Find the config group for the global property
-					asCConfigGroup *group = engine->FindConfigGroupForGlobalVar((*props)[n]->id);
-					if( !group || group->HasModuleAccess(module->name.AddressOf()) )
-						continue;
-#endif
-					if( isAppProp ) *isAppProp = true;
+				// Find the config group for the global property
+				asCConfigGroup *group = engine->FindConfigGroupForGlobalVar((*props)[n]->id);
+				if( !group || group->HasModuleAccess(module->name.AddressOf()) )
 					return (*props)[n];
 					return (*props)[n];
-				}
 			}
 			}
 			else
 			else
 			{
 			{
 				// We're not compiling a module right now, so it must be a registered global property
 				// We're not compiling a module right now, so it must be a registered global property
-				if( isAppProp ) *isAppProp = true;
 				return (*props)[n];
 				return (*props)[n];
 			}
 			}
 		}
 		}
@@ -985,7 +966,7 @@ int asCBuilder::CheckNameConflict(const char *name, asCScriptNode *node, asCScri
 
 
 	// TODO: Must verify global properties in all config groups, whether the module has access or not
 	// TODO: Must verify global properties in all config groups, whether the module has access or not
 	// Check against global properties
 	// Check against global properties
-	asCGlobalProperty *prop = GetGlobalProperty(name, 0, 0, 0, 0);
+	asCGlobalProperty *prop = GetGlobalProperty(name, 0, 0, 0);
 	if( prop )
 	if( prop )
 	{
 	{
 		if( code )
 		if( code )
@@ -1134,14 +1115,6 @@ void asCBuilder::CompleteFuncDef(sFuncDef *funcDef)
 
 
 int asCBuilder::RegisterGlobalVar(asCScriptNode *node, asCScriptCode *file)
 int asCBuilder::RegisterGlobalVar(asCScriptNode *node, asCScriptCode *file)
 {
 {
-	// Has the application disabled global vars?
-	if( engine->ep.disallowGlobalVars )
-	{
-		int r, c;
-		file->ConvertPosToRowCol(node->tokenPos, &r, &c);
-		WriteError(file->name.AddressOf(), TXT_GLOBAL_VARS_NOT_ALLOWED, r, c);
-	}
-
 	// What data type is it?
 	// What data type is it?
 	asCDataType type = CreateDataTypeFromNode(node->firstChild, file);
 	asCDataType type = CreateDataTypeFromNode(node->firstChild, file);
 
 
@@ -1205,15 +1178,6 @@ int asCBuilder::RegisterClass(asCScriptNode *node, asCScriptCode *file)
 	asCScriptNode *n = node->firstChild;
 	asCScriptNode *n = node->firstChild;
 	asCString name(&file->code[n->tokenPos], n->tokenLength);
 	asCString name(&file->code[n->tokenPos], n->tokenLength);
 
 
-	bool isShared = false;
-	if( name == SHARED_TOKEN )
-	{
-		isShared = true;
-
-		n = n->next;
-		name.Assign(&file->code[n->tokenPos], n->tokenLength);
-	}
-
 	int r, c;
 	int r, c;
 	file->ConvertPosToRowCol(n->tokenPos, &r, &c);
 	file->ConvertPosToRowCol(n->tokenPos, &r, &c);
 
 
@@ -1221,40 +1185,14 @@ int asCBuilder::RegisterClass(asCScriptNode *node, asCScriptCode *file)
 
 
 	sClassDeclaration *decl = asNEW(sClassDeclaration);
 	sClassDeclaration *decl = asNEW(sClassDeclaration);
 	classDeclarations.PushLast(decl);
 	classDeclarations.PushLast(decl);
-	decl->name             = name;
-	decl->script           = file;
-	decl->node             = node;
+	decl->name       = name;
+	decl->script     = file;
+	decl->validState = 0;
+	decl->node       = node;
 
 
-	// If this type is shared and there already exist another shared 
-	// type of the same name, then that one should be used instead of
-	// creating a new one.
-	if( isShared )
-	{
-		for( asUINT n = 0; n < engine->classTypes.GetLength(); n++ )
-		{
-			asCObjectType *st = engine->classTypes[n];
-			if( st &&
-				st->IsShared() &&
-				st->name == name &&
-				!st->IsInterface() )
-			{
-				// We'll use the existing type
-				decl->isExistingShared = true;
-				decl->objType          = st;
-				module->classTypes.PushLast(st);
-				st->AddRef();
-				return 0;
-			}
-		}
-	}
-
-	// Create a new object type for this class
 	asCObjectType *st = asNEW(asCObjectType)(engine);
 	asCObjectType *st = asNEW(asCObjectType)(engine);
 	st->flags = asOBJ_REF | asOBJ_SCRIPT_OBJECT;
 	st->flags = asOBJ_REF | asOBJ_SCRIPT_OBJECT;
 
 
-	if( isShared )
-		st->flags |= asOBJ_SHARED;
-
 	if( node->tokenType == ttHandle )
 	if( node->tokenType == ttHandle )
 		st->flags |= asOBJ_IMPLICIT_HANDLE;
 		st->flags |= asOBJ_IMPLICIT_HANDLE;
 
 
@@ -1266,7 +1204,6 @@ int asCBuilder::RegisterClass(asCScriptNode *node, asCScriptCode *file)
 	decl->objType = st;
 	decl->objType = st;
 
 
 	// Add script classes to the GC
 	// Add script classes to the GC
-	// TODO: optimize: Only add the class to the GC when the module won't use the type anymore
 	engine->gc.AddScriptObjectToGC(st, &engine->objectTypeBehaviours);
 	engine->gc.AddScriptObjectToGC(st, &engine->objectTypeBehaviours);
 
 
 	// Use the default script class behaviours
 	// Use the default script class behaviours
@@ -1294,15 +1231,6 @@ int asCBuilder::RegisterInterface(asCScriptNode *node, asCScriptCode *file)
 	asCScriptNode *n = node->firstChild;
 	asCScriptNode *n = node->firstChild;
 	asCString name(&file->code[n->tokenPos], n->tokenLength);
 	asCString name(&file->code[n->tokenPos], n->tokenLength);
 
 
-	bool isShared = false;
-	if( name == SHARED_TOKEN )
-	{
-		isShared = true;
-
-		n = n->next;
-		name.Assign(&file->code[n->tokenPos], n->tokenLength);
-	}
-
 	int r, c;
 	int r, c;
 	file->ConvertPosToRowCol(n->tokenPos, &r, &c);
 	file->ConvertPosToRowCol(n->tokenPos, &r, &c);
 
 
@@ -1310,40 +1238,14 @@ int asCBuilder::RegisterInterface(asCScriptNode *node, asCScriptCode *file)
 
 
 	sClassDeclaration *decl = asNEW(sClassDeclaration);
 	sClassDeclaration *decl = asNEW(sClassDeclaration);
 	interfaceDeclarations.PushLast(decl);
 	interfaceDeclarations.PushLast(decl);
-	decl->name             = name;
-	decl->script           = file;
-	decl->node             = node;
-
-	// If this type is shared and there already exist another shared 
-	// type of the same name, then that one should be used instead of
-	// creating a new one.
-	if( isShared )
-	{
-		for( asUINT n = 0; n < engine->classTypes.GetLength(); n++ )
-		{
-			asCObjectType *st = engine->classTypes[n];
-			if( st &&
-				st->IsShared() &&
-				st->name == name &&
-				st->IsInterface() )
-			{
-				// We'll use the existing type
-				decl->isExistingShared = true;
-				decl->objType          = st;
-				module->classTypes.PushLast(st);
-				st->AddRef();
-				return 0;
-			}
-		}
-	}
+	decl->name       = name;
+	decl->script     = file;
+	decl->validState = 0;
+	decl->node       = node;
 
 
 	// Register the object type for the interface
 	// Register the object type for the interface
 	asCObjectType *st = asNEW(asCObjectType)(engine);
 	asCObjectType *st = asNEW(asCObjectType)(engine);
 	st->flags = asOBJ_REF | asOBJ_SCRIPT_OBJECT;
 	st->flags = asOBJ_REF | asOBJ_SCRIPT_OBJECT;
-
-	if( isShared )
-		st->flags |= asOBJ_SHARED;
-
 	st->size = 0; // Cannot be instanciated
 	st->size = 0; // Cannot be instanciated
 	st->name = name;
 	st->name = name;
 	module->classTypes.PushLast(st);
 	module->classTypes.PushLast(st);
@@ -1648,13 +1550,6 @@ void asCBuilder::CompileClasses()
 		// Find the base class that this class inherits from
 		// Find the base class that this class inherits from
 		bool multipleInheritance = false;
 		bool multipleInheritance = false;
 		asCScriptNode *node = decl->node->firstChild->next;
 		asCScriptNode *node = decl->node->firstChild->next;
-
-		if( decl->objType->IsShared() )
-		{
-			// Skip the keyword 'shared'
-			node = node->next;
-		}
-
 		while( node && node->nodeType == snIdentifier )
 		while( node && node->nodeType == snIdentifier )
 		{
 		{
 			// Get the interface name from the node
 			// Get the interface name from the node
@@ -1682,7 +1577,7 @@ void asCBuilder::CompileClasses()
 			else if( objType->size != 0 )
 			else if( objType->size != 0 )
 			{
 			{
 				// The class inherits from another script class
 				// The class inherits from another script class
-				if( !decl->isExistingShared && decl->objType->derivedFrom != 0 )
+				if( decl->objType->derivedFrom != 0 )
 				{
 				{
 					if( !multipleInheritance )
 					if( !multipleInheritance )
 					{
 					{
@@ -1713,43 +1608,15 @@ void asCBuilder::CompileClasses()
 
 
 					if( !error )
 					if( !error )
 					{
 					{
-						// A shared type may only inherit from other shared types
-						if( (decl->objType->IsShared()) && !(objType->IsShared()) )
-						{
-							int r, c;
-							file->ConvertPosToRowCol(node->tokenPos, &r, &c);
-							asCString msg;
-							msg.Format(TXT_SHARED_CANNOT_INHERIT_FROM_NON_SHARED_s, objType->name.AddressOf());
-							WriteError(file->name.AddressOf(), msg.AddressOf(), r, c);
-							error = true;
-						}
-					}
-
-					if( !error )
-					{
-						if( decl->isExistingShared )
-						{
-							// Verify that the base class is the same as the original shared type
-							if( decl->objType->derivedFrom != objType )
-							{
-								int r, c;
-								file->ConvertPosToRowCol(node->tokenPos, &r, &c);
-								WriteError(file->name.AddressOf(), TXT_SHARED_DOESNT_MATCH_ORIGINAL, r, c);
-							}
-						}
-						else
-						{
-							// Set the base class
-							decl->objType->derivedFrom = objType;
-							objType->AddRef();
-						}
+						decl->objType->derivedFrom = objType;
+						objType->AddRef();
 					}
 					}
 				}
 				}
 			}
 			}
 			else
 			else
 			{
 			{
 				// The class implements an interface
 				// The class implements an interface
-				if( !decl->isExistingShared && decl->objType->Implements(objType) )
+				if( decl->objType->Implements(objType) )
 				{
 				{
 					int r, c;
 					int r, c;
 					file->ConvertPosToRowCol(node->tokenPos, &r, &c);
 					file->ConvertPosToRowCol(node->tokenPos, &r, &c);
@@ -1759,32 +1626,7 @@ void asCBuilder::CompileClasses()
 				}
 				}
 				else
 				else
 				{
 				{
-					// A shared type may only implement from shared interfaces
-					if( (decl->objType->IsShared()) && !(objType->IsShared()) )
-					{
-						int r, c;
-						file->ConvertPosToRowCol(node->tokenPos, &r, &c);
-						asCString msg;
-						msg.Format(TXT_SHARED_CANNOT_IMPLEMENT_NON_SHARED_s, objType->name.AddressOf());
-						WriteError(file->name.AddressOf(), msg.AddressOf(), r, c);
-					}
-					else
-					{
-						if( decl->isExistingShared )
-						{
-							// Verify that the original implements the same interface
-							if( !decl->objType->Implements(objType) )
-							{
-								int r, c;
-								file->ConvertPosToRowCol(node->tokenPos, &r, &c);
-								WriteError(file->name.AddressOf(), TXT_SHARED_DOESNT_MATCH_ORIGINAL, r, c);
-							}
-						}
-						else
-						{
-							decl->objType->interfaces.PushLast(objType);
-						}
-					}
+					decl->objType->interfaces.PushLast(objType);
 				}
 				}
 			}
 			}
 
 
@@ -1822,11 +1664,6 @@ void asCBuilder::CompileClasses()
 	for( n = 0; n < classDeclarations.GetLength(); n++ )
 	for( n = 0; n < classDeclarations.GetLength(); n++ )
 	{
 	{
 		sClassDeclaration *decl = classDeclarations[n];
 		sClassDeclaration *decl = classDeclarations[n];
-		if( decl->isExistingShared )
-		{
-			// TODO: shared: Should really validate against original
-			continue;
-		}
 
 
 		// Add all properties and methods from the base class
 		// Add all properties and methods from the base class
 		if( decl->objType->derivedFrom )
 		if( decl->objType->derivedFrom )
@@ -1930,15 +1767,6 @@ void asCBuilder::CompileClasses()
 				asCDataType dt = CreateDataTypeFromNode(isPrivate ? node->firstChild->next : node->firstChild, file);
 				asCDataType dt = CreateDataTypeFromNode(isPrivate ? node->firstChild->next : node->firstChild, file);
 				asCString name(&file->code[node->lastChild->tokenPos], node->lastChild->tokenLength);
 				asCString name(&file->code[node->lastChild->tokenPos], node->lastChild->tokenLength);
 
 
-				if( decl->objType->IsShared() && dt.GetObjectType() && !dt.GetObjectType()->IsShared() )
-				{
-					int r, c;
-					file->ConvertPosToRowCol(node->tokenPos, &r, &c);
-					asCString msg;
-					msg.Format(TXT_SHARED_CANNOT_USE_NON_SHARED_TYPE_s, dt.GetObjectType()->name.AddressOf());
-					WriteError(file->name.AddressOf(), msg.AddressOf(), r, c);
-				}
-
 				if( dt.IsReadOnly() )
 				if( dt.IsReadOnly() )
 				{
 				{
 					int r, c;
 					int r, c;
@@ -1965,7 +1793,6 @@ void asCBuilder::CompileClasses()
 	for( n = 0; n < classDeclarations.GetLength(); n++ )
 	for( n = 0; n < classDeclarations.GetLength(); n++ )
 	{
 	{
 		sClassDeclaration *decl = classDeclarations[n];
 		sClassDeclaration *decl = classDeclarations[n];
-		if( decl->isExistingShared ) continue;
 		for( asUINT m = 0; m < decl->objType->interfaces.GetLength(); m++ )
 		for( asUINT m = 0; m < decl->objType->interfaces.GetLength(); m++ )
 		{
 		{
 			asCObjectType *objType = decl->objType->interfaces[m];
 			asCObjectType *objType = decl->objType->interfaces[m];
@@ -2079,7 +1906,6 @@ void asCBuilder::CompileClasses()
 	for( n = 0; n < classDeclarations.GetLength(); n++ )
 	for( n = 0; n < classDeclarations.GetLength(); n++ )
 	{
 	{
 		sClassDeclaration *decl = classDeclarations[n];
 		sClassDeclaration *decl = classDeclarations[n];
-		if( decl->isExistingShared ) continue;
 		asCObjectType *ot = decl->objType;
 		asCObjectType *ot = decl->objType;
 
 
 		// Is there some path in which this structure is involved in circular references?
 		// Is there some path in which this structure is involved in circular references?
@@ -2255,9 +2081,11 @@ int asCBuilder::RegisterEnum(asCScriptNode *node, asCScriptCode *file)
 
 
 		// Store the location of this declaration for reference in name collisions
 		// Store the location of this declaration for reference in name collisions
 		sClassDeclaration *decl = asNEW(sClassDeclaration);
 		sClassDeclaration *decl = asNEW(sClassDeclaration);
-		decl->name             = name;
-		decl->script           = file;
-		decl->objType          = st;
+		decl->name       = name;
+		decl->script     = file;
+		decl->validState = 0;
+		decl->node       = NULL;
+		decl->objType    = st;
 		namedTypeDeclarations.PushLast(decl);
 		namedTypeDeclarations.PushLast(decl);
 
 
 		asCDataType type = CreateDataTypeFromNode(tmp, file);
 		asCDataType type = CreateDataTypeFromNode(tmp, file);
@@ -2373,9 +2201,11 @@ int asCBuilder::RegisterTypedef(asCScriptNode *node, asCScriptCode *file)
 
 
 		// Store the location of this declaration for reference in name collisions
 		// Store the location of this declaration for reference in name collisions
 		sClassDeclaration *decl = asNEW(sClassDeclaration);
 		sClassDeclaration *decl = asNEW(sClassDeclaration);
-		decl->name             = name;
-		decl->script           = file;
-		decl->objType          = st;
+		decl->name       = name;
+		decl->script     = file;
+		decl->validState = 0;
+		decl->node       = NULL;
+		decl->objType    = st;
 		namedTypeDeclarations.PushLast(decl);
 		namedTypeDeclarations.PushLast(decl);
 	}
 	}
 
 
@@ -2575,33 +2405,6 @@ int asCBuilder::RegisterScriptFunction(int funcId, asCScriptNode *node, asCScrip
 		WriteError(file->name.AddressOf(), TXT_DESTRUCTOR_MAY_NOT_HAVE_PARM, r, c);
 		WriteError(file->name.AddressOf(), TXT_DESTRUCTOR_MAY_NOT_HAVE_PARM, r, c);
 	}
 	}
 
 
-	// If class or interface is shared, then only shared types may be used in the method signature
-	if( objType && objType->IsShared() )
-	{
-		asCObjectType *ot = returnType.GetObjectType();
-		if( ot && !ot->IsShared() )
-		{
-			int r, c;
-			file->ConvertPosToRowCol(node->tokenPos, &r, &c);
-			asCString msg;
-			msg.Format(TXT_SHARED_CANNOT_USE_NON_SHARED_TYPE_s, ot->name.AddressOf());
-			WriteError(file->name.AddressOf(), msg.AddressOf(), r, c);
-		}
-		
-		for( asUINT p = 0; p < parameterTypes.GetLength(); ++p )
-		{
-			asCObjectType *ot = parameterTypes[p].GetObjectType();
-			if( ot && !ot->IsShared() )
-			{
-				int r, c;
-				file->ConvertPosToRowCol(node->tokenPos, &r, &c);
-				asCString msg;
-				msg.Format(TXT_SHARED_CANNOT_USE_NON_SHARED_TYPE_s, ot->name.AddressOf());
-				WriteError(file->name.AddressOf(), msg.AddressOf(), r, c);
-			}
-		}
-	}
-
 	// TODO: Much of this can probably be reduced by using the IsSignatureEqual method
 	// TODO: Much of this can probably be reduced by using the IsSignatureEqual method
 	// Check that the same function hasn't been registered already
 	// Check that the same function hasn't been registered already
 	asCArray<int> funcs;
 	asCArray<int> funcs;
@@ -2844,17 +2647,10 @@ void asCBuilder::GetFunctionDescriptions(const char *name, asCArray<int> &funcs)
 			engine->scriptFunctions[n]->objectType == 0 &&
 			engine->scriptFunctions[n]->objectType == 0 &&
 			engine->scriptFunctions[n]->name == name )
 			engine->scriptFunctions[n]->name == name )
 		{
 		{
-			// Verify if the module has access to the function
-			if( module->accessMask & engine->scriptFunctions[n]->accessMask )
-			{
-#ifdef AS_DEPRECATED
-				// deprecated since 2011-10-04
-				// Find the config group for the global function
-				asCConfigGroup *group = engine->FindConfigGroupForFunction(engine->scriptFunctions[n]->id);
-				if( !group || group->HasModuleAccess(module->name.AddressOf()) )
-#endif
+			// Find the config group for the global function
+			asCConfigGroup *group = engine->FindConfigGroupForFunction(engine->scriptFunctions[n]->id);
+			if( !group || group->HasModuleAccess(module->name.AddressOf()) )
 				funcs.PushLast(engine->scriptFunctions[n]->id);
 				funcs.PushLast(engine->scriptFunctions[n]->id);
-			}
 		}
 		}
 	}
 	}
 }
 }
@@ -2991,15 +2787,9 @@ asCDataType asCBuilder::CreateDataTypeFromNode(asCScriptNode *node, asCScriptCod
 			if( ot->flags & asOBJ_IMPLICIT_HANDLE )
 			if( ot->flags & asOBJ_IMPLICIT_HANDLE )
 				isImplicitHandle = true;
 				isImplicitHandle = true;
 
 
-			// Make sure the module has access to the object type
-#ifdef AS_DEPRECATED
-			// deprecated since 2011-10-04
 			// Find the config group for the object type
 			// Find the config group for the object type
 			asCConfigGroup *group = engine->FindConfigGroupForObjectType(ot);
 			asCConfigGroup *group = engine->FindConfigGroupForObjectType(ot);
-			if( !module || ((module->accessMask & ot->accessMask) && (!group || group->HasModuleAccess(module->name.AddressOf()))) )
-#else
-			if( !module || (module->accessMask & ot->accessMask) )
-#endif
+			if( !module || !group || group->HasModuleAccess(module->name.AddressOf()) )
 			{
 			{
 				if(asOBJ_TYPEDEF == (ot->flags & asOBJ_TYPEDEF))
 				if(asOBJ_TYPEDEF == (ot->flags & asOBJ_TYPEDEF))
 				{
 				{
@@ -3205,6 +2995,7 @@ asCDataType asCBuilder::ModifyDataTypeFromNode(const asCDataType &type, asCScrip
 
 
 asCObjectType *asCBuilder::GetObjectType(const char *type)
 asCObjectType *asCBuilder::GetObjectType(const char *type)
 {
 {
+	// TODO: Only search in config groups to which the module has access
 	asCObjectType *ot = engine->GetObjectType(type);
 	asCObjectType *ot = engine->GetObjectType(type);
 	if( !ot && module )
 	if( !ot && module )
 		ot = module->GetObjectType(type);
 		ot = module->GetObjectType(type);
@@ -3216,7 +3007,7 @@ asCScriptFunction *asCBuilder::GetFuncDef(const char *type)
 {
 {
 	for( asUINT n = 0; n < engine->registeredFuncDefs.GetLength(); n++ )
 	for( asUINT n = 0; n < engine->registeredFuncDefs.GetLength(); n++ )
 	{
 	{
-		// TODO: access: Only return the definitions for the config groups that the module has access to
+		// TODO: Only return the definitions for the config groups that the module has access to
 		if( engine->registeredFuncDefs[n]->name == type )
 		if( engine->registeredFuncDefs[n]->name == type )
 		{
 		{
 			return engine->registeredFuncDefs[n];
 			return engine->registeredFuncDefs[n];

+ 1 - 4
ThirdParty/AngelScript/source/as_builder.h

@@ -76,14 +76,11 @@ struct sGlobalVariableDescription
 
 
 struct sClassDeclaration
 struct sClassDeclaration
 {
 {
-	sClassDeclaration() {script = 0; node = 0; validState = 0; objType = 0; isExistingShared = false;}
-
 	asCScriptCode *script;
 	asCScriptCode *script;
 	asCScriptNode *node;
 	asCScriptNode *node;
 	asCString name;
 	asCString name;
 	int validState;
 	int validState;
 	asCObjectType *objType;
 	asCObjectType *objType;
-	bool isExistingShared;
 };
 };
 
 
 struct sFuncDef
 struct sFuncDef
@@ -129,7 +126,7 @@ protected:
 	friend class asCParser;
 	friend class asCParser;
 
 
 	asCObjectProperty *GetObjectProperty(asCDataType &obj, const char *prop);
 	asCObjectProperty *GetObjectProperty(asCDataType &obj, const char *prop);
-	asCGlobalProperty *GetGlobalProperty(const char *prop, bool *isCompiled, bool *isPureConstant, asQWORD *constantValue, bool *isAppProp);
+	asCGlobalProperty *GetGlobalProperty(const char *prop, bool *isCompiled, bool *isPureConstant, asQWORD *constantValue);
 
 
 	asCScriptFunction *GetFunctionDescription(int funcID);
 	asCScriptFunction *GetFunctionDescription(int funcID);
 	void GetFunctionDescriptions(const char *name, asCArray<int> &funcs);
 	void GetFunctionDescriptions(const char *name, asCArray<int> &funcs);

+ 7 - 60
ThirdParty/AngelScript/source/as_callfunc.cpp

@@ -181,10 +181,6 @@ int PrepareSystemFunction(asCScriptFunction *func, asSSystemFunctionInterface *i
 				{
 				{
 					internal->hostReturnInMemory = false;
 					internal->hostReturnInMemory = false;
 					internal->hostReturnSize     = func->returnType.GetSizeInMemoryDWords();
 					internal->hostReturnSize     = func->returnType.GetSizeInMemoryDWords();
-#ifdef SPLIT_OBJS_BY_MEMBER_TYPES
-					if( func->returnType.GetObjectType()->flags & asOBJ_APP_CLASS_ALLFLOATS )
-						internal->hostReturnFloat = true;
-#endif
 				}
 				}
 
 
 #ifdef THISCALL_RETURN_SIMPLE_IN_MEMORY
 #ifdef THISCALL_RETURN_SIMPLE_IN_MEMORY
@@ -215,24 +211,6 @@ int PrepareSystemFunction(asCScriptFunction *func, asSSystemFunctionInterface *i
 				}
 				}
 #endif
 #endif
 			}
 			}
-
-#ifdef SPLIT_OBJS_BY_MEMBER_TYPES
-			// It's not safe to return objects by value because different registers
-			// will be used depending on the memory layout of the object.
-			// Ref: http://www.x86-64.org/documentation/abi.pdf
-			// Ref: http://www.agner.org/optimize/calling_conventions.pdf
-			// If the application informs that the class should be treated as all integers, then we allow it
-			if( !internal->hostReturnInMemory &&
-				!(func->returnType.GetObjectType()->flags & (asOBJ_APP_CLASS_ALLINTS | asOBJ_APP_CLASS_ALLFLOATS)) )	
-			{
-				engine->WriteMessage("", 0, 0, asMSGTYPE_INFORMATION, func->GetDeclarationStr().AddressOf());
-
-				asCString str;
-				str.Format(TXT_DONT_SUPPORT_RET_TYPE_s_BY_VAL, func->returnType.Format().AddressOf());
-				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
-				engine->ConfigError(asINVALID_CONFIGURATION);
-			}
-#endif
 		}
 		}
 		else if( objType & asOBJ_APP_PRIMITIVE )
 		else if( objType & asOBJ_APP_PRIMITIVE )
 		{
 		{
@@ -313,8 +291,6 @@ int PrepareSystemFunction(asCScriptFunction *func, asSSystemFunctionInterface *i
 #ifdef SPLIT_OBJS_BY_MEMBER_TYPES
 #ifdef SPLIT_OBJS_BY_MEMBER_TYPES
 			// It's not safe to pass objects by value because different registers
 			// It's not safe to pass objects by value because different registers
 			// will be used depending on the memory layout of the object
 			// will be used depending on the memory layout of the object
-			// Ref: http://www.x86-64.org/documentation/abi.pdf
-			// Ref: http://www.agner.org/optimize/calling_conventions.pdf
 #ifdef COMPLEX_OBJS_PASSED_BY_REF
 #ifdef COMPLEX_OBJS_PASSED_BY_REF
 			if( !(func->parameterTypes[n].GetObjectType()->flags & COMPLEX_MASK) )	
 			if( !(func->parameterTypes[n].GetObjectType()->flags & COMPLEX_MASK) )	
 #endif
 #endif
@@ -402,6 +378,13 @@ int CallSystemFunction(int id, asCContext *context, void *objectPointer)
 	void    *obj               = 0;
 	void    *obj               = 0;
 	int      popSize           = sysFunc->paramSize;
 	int      popSize           = sysFunc->paramSize;
 
 
+	context->regs.objectType = descr->returnType.GetObjectType();
+	if( descr->returnType.IsObject() && !descr->returnType.IsReference() && !descr->returnType.IsObjectHandle() )
+	{
+		// Allocate the memory for the object
+		retPointer = engine->CallAlloc(descr->returnType.GetObjectType());
+	}
+
 	if( callConv >= ICC_THISCALL )
 	if( callConv >= ICC_THISCALL )
 	{
 	{
 		if( objectPointer )
 		if( objectPointer )
@@ -438,24 +421,6 @@ int CallSystemFunction(int id, asCContext *context, void *objectPointer)
 		}
 		}
 	}
 	}
 
 
-	context->regs.objectType = descr->returnType.GetObjectType();
-	if( descr->returnType.IsObject() && !descr->returnType.IsReference() && !descr->returnType.IsObjectHandle() )
-	{
-#ifndef AS_OLD
-		// Get the address of the location for the return value from the stack
-		retPointer = (void*)*(size_t*)(args);
-		popSize += AS_PTR_SIZE;
-		args += AS_PTR_SIZE;
-
-		// When returning the value on the location allocated by the called we shouldn't set the object type in the register
-		context->regs.objectType = 0;
-#else
-		// Allocate the memory for the object
-		retPointer = engine->CallAlloc(descr->returnType.GetObjectType());
-#endif
-	}
-
-
 	retQW = CallSystemFunctionNative(context, descr, obj, args, sysFunc->hostReturnInMemory ? retPointer : 0, retQW2);
 	retQW = CallSystemFunctionNative(context, descr, obj, args, sysFunc->hostReturnInMemory ? retPointer : 0, retQW2);
 
 
 #if defined(COMPLEX_OBJS_PASSED_BY_REF) || defined(AS_LARGE_OBJS_PASSED_BY_REF)
 #if defined(COMPLEX_OBJS_PASSED_BY_REF) || defined(AS_LARGE_OBJS_PASSED_BY_REF)
@@ -546,24 +511,6 @@ int CallSystemFunction(int id, asCContext *context, void *objectPointer)
 
 
 			// Store the object in the register
 			// Store the object in the register
 			context->regs.objectRegister = retPointer;
 			context->regs.objectRegister = retPointer;
-
-#ifndef AS_OLD
-			// If the value is returned on the stack we shouldn't update the object register
-			if( descr->DoesReturnOnStack() )
-			{
-				context->regs.objectRegister = 0;
-
-				if( context->status == asEXECUTION_EXCEPTION )
-				{
-					// If the function raised a script exception it really shouldn't have 
-					// initialized the object. However, as it is a soft exception there is 
-					// no way for the application to not return a value, so instead we simply
-					// destroy it here, to pretend it was never created.
-					if( descr->returnType.GetObjectType()->beh.destruct )
-						engine->CallObjectMethod(retPointer, descr->returnType.GetObjectType()->beh.destruct);
-				}
-			}
-#endif
 		}
 		}
 	}
 	}
 	else
 	else

+ 235 - 235
ThirdParty/AngelScript/source/as_callfunc_arm_gcc.S

@@ -1,235 +1,235 @@
-/*
-  AngelCode Scripting Library
-  Copyright (c) 2003-2009 Andreas Jonsson
-
-  This software is provided 'as-is', without any express or implied
-  warranty. In no event will the authors be held liable for any
-  damages arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any
-  purpose, including commercial applications, and to alter it and
-  redistribute it freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you
-     must not claim that you wrote the original software. If you use
-     this software in a product, an acknowledgment in the product
-     documentation would be appreciated but is not required.
-
-  2. Altered source versions must be plainly marked as such, and
-     must not be misrepresented as being the original software.
-
-  3. This notice may not be removed or altered from any source
-     distribution.
-
-  The original version of this library can be located at:
-  http://www.angelcode.com/angelscript/
-
-  Andreas Jonsson
-  [email protected]
-*/
-
-
-// Assembly routines for the ARM call convention
-// Written by Fredrik Ehnbom in June 2009
-
-// Adapted to GNUC by darktemplar216 in September 2009
-
-#if defined(__arm__) || defined(__ARM__)
-
-.global armFunc
-.global armFuncR0
-.global armFuncR0R1
-.global armFuncObjLast
-.global armFuncR0ObjLast
-    
-armFunc:
-    stmdb   sp!, {r4-r8, lr}
-    mov     r6, r0  // arg table
-    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  // function address
-    mov     r8, #0
-
-    beq     nomoreargs
-
-    // Load the first 4 arguments into r0-r3
-    cmp     r7, #4
-    ldrge   r0, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r1, [r6],#4
-    cmp     r7, #3*4
-    ldrge   r2, [r6],#4
-    cmp     r7, #4*4
-    ldrge   r3, [r6],#4
-    ble     nomoreargs
-
-    // Load the rest of the arguments onto the stack
-    sub     r7, r7, #4*4    // skip the 4 registers already loaded into r0-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-stackargsloop:
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     stackargsloop
-nomoreargs:
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    ldmia   sp!, {r4-r8, pc}
-
-armFuncObjLast:
-    stmdb   sp!, {r4-r8, lr}
-    mov     r6, r0  // arg table
-    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  // function address
-    mov     r8, #0
-
-    mov     r0, r3          // objlast. might get overwritten
-    str     r3, [sp, #-4]!  // objlast again.
-
-    beq     nomoreargsarmFuncObjLast
-
-    // Load the first 4 arguments into r0-r3
-    cmp     r7, #4
-    ldrge   r0, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r1, [r6],#4
-    ldrlt   r1, [sp]    
-    cmp     r7, #3*4
-    ldrge   r2, [r6],#4
-    ldrlt   r2, [sp]
-    cmp     r7, #4*4
-    ldrge   r3, [r6],#4
-    ldrlt   r3, [sp]
-    ble     nomoreargsarmFuncObjLast
-
-    // Load the rest of the arguments onto the stack
-    sub     r7, r7, #4*4    // skip the 4 registers already loaded into r0-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-stackargslooparmFuncObjLast:
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     stackargslooparmFuncObjLast
-nomoreargsarmFuncObjLast:
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    add     sp, sp, #4
-    ldmia   sp!, {r4-r8, pc}
-
-armFuncR0ObjLast:
-    stmdb   sp!, {r4-r8, lr}
-    ldr     r7, [sp,#6*4]
-    str     r7, [sp,#-4]!
-
-    mov     r6, r0  // arg table
-    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  // function address
-    mov     r8, #0
-
-    mov     r0, r3      // r0 explicitly set
-    ldr     r1, [sp]    // objlast.  might get overwritten
-
-    beq     nomoreargsarmFuncR0ObjLast
-
-    // Load the first 3 arguments into r1-r3
-    cmp     r7, #1*4
-    ldrge   r1, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r2, [r6],#4
-    ldrlt   r2, [sp]
-    cmp     r7, #3*4
-    ldrge   r3, [r6],#4
-    ldrlt   r3, [sp]
-    ble     nomoreargsarmFuncR0ObjLast
-
-    // Load the rest of the arguments onto the stack
-    sub     r7, r7, #3*4    // skip the 3 registers already loaded into r1-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-stackargslooparmFuncR0ObjLast:
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     stackargslooparmFuncR0ObjLast
-nomoreargsarmFuncR0ObjLast:
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    add     sp, sp, #4
-    ldmia   sp!, {r4-r8, pc}
-
-
-armFuncR0:
-    stmdb   sp!, {r4-r8, lr}
-    mov     r6, r0  // arg table
-    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  // function address
-    mov     r8, #0
-
-    mov     r0, r3  // r0 explicitly set
-
-    beq     nomoreargsarmFuncR0
-
-    // Load the first 3 arguments into r1-r3
-    cmp     r7, #1*4
-    ldrge   r1, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r2, [r6],#4
-    cmp     r7, #3*4
-    ldrge   r3, [r6],#4
-    ble     nomoreargsarmFuncR0
-
-    // Load the rest of the arguments onto the stack
-    sub     r7, r7, #3*4    // skip the 3 registers already loaded into r1-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-stackargslooparmFuncR0:
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     stackargslooparmFuncR0
-nomoreargsarmFuncR0:
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    ldmia   sp!, {r4-r8, pc}
-
-
-armFuncR0R1:
-    stmdb   sp!, {r4-r8, lr}
-    mov     r6, r0  // arg table
-    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  // function address
-    mov     r8, #0
-
-    mov     r0, r3          // r0 explicitly set
-    ldr     r1, [sp, #6*4]  // r1 explicitly set too
-
-    beq     nomoreargsarmFuncR0R1
-
-    // Load the first 2 arguments into r2-r3
-    cmp     r7, #1*4
-    ldrge   r2, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r3, [r6],#4
-    ble     nomoreargsarmFuncR0R1
-
-    // Load the rest of the arguments onto the stack
-    sub     r7, r7, #2*4    // skip the 2 registers already loaded into r2-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-stackargslooparmFuncR0R1:
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     stackargslooparmFuncR0R1
-nomoreargsarmFuncR0R1:
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    ldmia   sp!, {r4-r8, pc}
-
-#endif
+/*
+  AngelCode Scripting Library
+  Copyright (c) 2003-2009 Andreas Jonsson
+
+  This software is provided 'as-is', without any express or implied
+  warranty. In no event will the authors be held liable for any
+  damages arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any
+  purpose, including commercial applications, and to alter it and
+  redistribute it freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you
+     must not claim that you wrote the original software. If you use
+     this software in a product, an acknowledgment in the product
+     documentation would be appreciated but is not required.
+
+  2. Altered source versions must be plainly marked as such, and
+     must not be misrepresented as being the original software.
+
+  3. This notice may not be removed or altered from any source
+     distribution.
+
+  The original version of this library can be located at:
+  http://www.angelcode.com/angelscript/
+
+  Andreas Jonsson
+  [email protected]
+*/
+
+
+// Assembly routines for the ARM call convention
+// Written by Fredrik Ehnbom in June 2009
+
+// Adapted to GNUC by darktemplar216 in September 2009
+
+#if defined(__arm__) || defined(__ARM__)
+
+.global armFunc
+.global armFuncR0
+.global armFuncR0R1
+.global armFuncObjLast
+.global armFuncR0ObjLast
+    
+armFunc:
+    stmdb   sp!, {r4-r8, lr}
+    mov     r6, r0  // arg table
+    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  // function address
+    mov     r8, #0
+
+    beq     nomoreargs
+
+    // Load the first 4 arguments into r0-r3
+    cmp     r7, #4
+    ldrge   r0, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r1, [r6],#4
+    cmp     r7, #3*4
+    ldrge   r2, [r6],#4
+    cmp     r7, #4*4
+    ldrge   r3, [r6],#4
+    ble     nomoreargs
+
+    // Load the rest of the arguments onto the stack
+    sub     r7, r7, #4*4    // skip the 4 registers already loaded into r0-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+stackargsloop:
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     stackargsloop
+nomoreargs:
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    ldmia   sp!, {r4-r8, pc}
+
+armFuncObjLast:
+    stmdb   sp!, {r4-r8, lr}
+    mov     r6, r0  // arg table
+    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  // function address
+    mov     r8, #0
+
+    mov     r0, r3          // objlast. might get overwritten
+    str     r3, [sp, #-4]!  // objlast again.
+
+    beq     nomoreargsarmFuncObjLast
+
+    // Load the first 4 arguments into r0-r3
+    cmp     r7, #4
+    ldrge   r0, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r1, [r6],#4
+    ldrlt   r1, [sp]    
+    cmp     r7, #3*4
+    ldrge   r2, [r6],#4
+    ldrlt   r2, [sp]
+    cmp     r7, #4*4
+    ldrge   r3, [r6],#4
+    ldrlt   r3, [sp]
+    ble     nomoreargsarmFuncObjLast
+
+    // Load the rest of the arguments onto the stack
+    sub     r7, r7, #4*4    // skip the 4 registers already loaded into r0-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+stackargslooparmFuncObjLast:
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     stackargslooparmFuncObjLast
+nomoreargsarmFuncObjLast:
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    add     sp, sp, #4
+    ldmia   sp!, {r4-r8, pc}
+
+armFuncR0ObjLast:
+    stmdb   sp!, {r4-r8, lr}
+    ldr     r7, [sp,#6*4]
+    str     r7, [sp,#-4]!
+
+    mov     r6, r0  // arg table
+    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  // function address
+    mov     r8, #0
+
+    mov     r0, r3      // r0 explicitly set
+    ldr     r1, [sp]    // objlast.  might get overwritten
+
+    beq     nomoreargsarmFuncR0ObjLast
+
+    // Load the first 3 arguments into r1-r3
+    cmp     r7, #1*4
+    ldrge   r1, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r2, [r6],#4
+    ldrlt   r2, [sp]
+    cmp     r7, #3*4
+    ldrge   r3, [r6],#4
+    ldrlt   r3, [sp]
+    ble     nomoreargsarmFuncR0ObjLast
+
+    // Load the rest of the arguments onto the stack
+    sub     r7, r7, #3*4    // skip the 3 registers already loaded into r1-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+stackargslooparmFuncR0ObjLast:
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     stackargslooparmFuncR0ObjLast
+nomoreargsarmFuncR0ObjLast:
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    add     sp, sp, #4
+    ldmia   sp!, {r4-r8, pc}
+
+
+armFuncR0:
+    stmdb   sp!, {r4-r8, lr}
+    mov     r6, r0  // arg table
+    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  // function address
+    mov     r8, #0
+
+    mov     r0, r3  // r0 explicitly set
+
+    beq     nomoreargsarmFuncR0
+
+    // Load the first 3 arguments into r1-r3
+    cmp     r7, #1*4
+    ldrge   r1, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r2, [r6],#4
+    cmp     r7, #3*4
+    ldrge   r3, [r6],#4
+    ble     nomoreargsarmFuncR0
+
+    // Load the rest of the arguments onto the stack
+    sub     r7, r7, #3*4    // skip the 3 registers already loaded into r1-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+stackargslooparmFuncR0:
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     stackargslooparmFuncR0
+nomoreargsarmFuncR0:
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    ldmia   sp!, {r4-r8, pc}
+
+
+armFuncR0R1:
+    stmdb   sp!, {r4-r8, lr}
+    mov     r6, r0  // arg table
+    movs    r7, r1  // arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  // function address
+    mov     r8, #0
+
+    mov     r0, r3          // r0 explicitly set
+    ldr     r1, [sp, #6*4]  // r1 explicitly set too
+
+    beq     nomoreargsarmFuncR0R1
+
+    // Load the first 2 arguments into r2-r3
+    cmp     r7, #1*4
+    ldrge   r2, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r3, [r6],#4
+    ble     nomoreargsarmFuncR0R1
+
+    // Load the rest of the arguments onto the stack
+    sub     r7, r7, #2*4    // skip the 2 registers already loaded into r2-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+stackargslooparmFuncR0R1:
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     stackargslooparmFuncR0R1
+nomoreargsarmFuncR0R1:
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    ldmia   sp!, {r4-r8, pc}
+
+#endif

+ 242 - 242
ThirdParty/AngelScript/source/as_callfunc_arm_msvc.asm

@@ -1,242 +1,242 @@
-;
-;  AngelCode Scripting Library
-;  Copyright (c) 2003-2009 Andreas Jonsson
-;
-;  This software is provided 'as-is', without any express or implied
-;  warranty. In no event will the authors be held liable for any
-;  damages arising from the use of this software.
-;
-;  Permission is granted to anyone to use this software for any
-;  purpose, including commercial applications, and to alter it and
-;  redistribute it freely, subject to the following restrictions:
-;
-;  1. The origin of this software must not be misrepresented; you
-;     must not claim that you wrote the original software. If you use
-;     this software in a product, an acknowledgment in the product
-;     documentation would be appreciated but is not required.
-;
-;  2. Altered source versions must be plainly marked as such, and
-;     must not be misrepresented as being the original software.
-;
-;  3. This notice may not be removed or altered from any source
-;     distribution.
-;
-;  The original version of this library can be located at:
-;  http://www.angelcode.com/angelscript/
-;
-;  Andreas Jonsson
-;  [email protected]
-;
-
-
-; Assembly routines for the ARM call convention
-; Written by Fredrik Ehnbom in June 2009
-
-; MSVC currently doesn't support inline assembly for the ARM platform
-; so this separate file is needed.
-
-
-    AREA	|.rdata|, DATA, READONLY
-    EXPORT |armFunc|
-    EXPORT armFuncR0
-    EXPORT armFuncR0R1
-    EXPORT armFuncObjLast
-    EXPORT armFuncR0ObjLast
-    
-
-    AREA	|.text|, CODE, ARM
-
-|armFunc| PROC
-    stmdb   sp!, {r4-r8, lr}
-    mov     r6, r0  ; arg table
-    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  ; function address
-    mov     r8, #0
-
-    beq     |nomoreargs|
-
-    ; Load the first 4 arguments into r0-r3
-    cmp     r7, #4
-    ldrge   r0, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r1, [r6],#4
-    cmp     r7, #3*4
-    ldrge   r2, [r6],#4
-    cmp     r7, #4*4
-    ldrge   r3, [r6],#4
-    ble     |nomoreargs|
-
-    ; Load the rest of the arguments onto the stack
-    sub     r7, r7, #4*4    ; skip the 4 registers already loaded into r0-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-|stackargsloop|
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     |stackargsloop|
-|nomoreargs|
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    ldmia   sp!, {r4-r8, pc}
-    ENDP
-
-armFuncObjLast PROC
-    stmdb   sp!, {r4-r8, lr}
-    mov     r6, r0  ; arg table
-    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  ; function address
-    mov     r8, #0
-
-    mov     r0, r3          ; objlast. might get overwritten
-    str     r3, [sp, #-4]!  ; objlast again.
-
-    beq     |nomoreargs@armFuncObjLast|
-
-    ; Load the first 4 arguments into r0-r3
-    cmp     r7, #4
-    ldrge   r0, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r1, [r6],#4
-    ldrlt   r1, [sp]    
-    cmp     r7, #3*4
-    ldrge   r2, [r6],#4
-    ldrlt   r2, [sp]
-    cmp     r7, #4*4
-    ldrge   r3, [r6],#4
-    ldrlt   r3, [sp]
-    ble     |nomoreargs@armFuncObjLast|
-
-    ; Load the rest of the arguments onto the stack
-    sub     r7, r7, #4*4    ; skip the 4 registers already loaded into r0-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-|stackargsloop@armFuncObjLast|
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     |stackargsloop@armFuncObjLast|
-|nomoreargs@armFuncObjLast|
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    add     sp, sp, #4
-    ldmia   sp!, {r4-r8, pc}
-    ENDP
-
-armFuncR0ObjLast PROC
-    stmdb   sp!, {r4-r8, lr}
-    ldr     r7, [sp,#6*4]
-    str     r7, [sp,#-4]!
-
-    mov     r6, r0  ; arg table
-    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  ; function address
-    mov     r8, #0
-
-    mov     r0, r3      ; r0 explicitly set
-    ldr     r1, [sp]    ; objlast.  might get overwritten
-
-    beq     |nomoreargs@armFuncR0ObjLast|
-
-    ; Load the first 3 arguments into r1-r3
-    cmp     r7, #1*4
-    ldrge   r1, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r2, [r6],#4
-    ldrlt   r2, [sp]
-    cmp     r7, #3*4
-    ldrge   r3, [r6],#4
-    ldrlt   r3, [sp]
-    ble     |nomoreargs@armFuncR0ObjLast|
-
-    ; Load the rest of the arguments onto the stack
-    sub     r7, r7, #3*4    ; skip the 3 registers already loaded into r1-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-|stackargsloop@armFuncR0ObjLast|
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     |stackargsloop@armFuncR0ObjLast|
-|nomoreargs@armFuncR0ObjLast|
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    add     sp, sp, #4
-    ldmia   sp!, {r4-r8, pc}
-    ENDP
-
-armFuncR0 PROC
-    stmdb   sp!, {r4-r8, lr}
-    mov     r6, r0  ; arg table
-    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  ; function address
-    mov     r8, #0
-
-    mov     r0, r3  ; r0 explicitly set
-
-    beq     |nomoreargs@armFuncR0|
-
-    ; Load the first 3 arguments into r1-r3
-    cmp     r7, #1*4
-    ldrge   r1, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r2, [r6],#4
-    cmp     r7, #3*4
-    ldrge   r3, [r6],#4
-    ble     |nomoreargs@armFuncR0|
-
-    ; Load the rest of the arguments onto the stack
-    sub     r7, r7, #3*4    ; skip the 3 registers already loaded into r1-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-|stackargsloop@armFuncR0|
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     |stackargsloop@armFuncR0|
-|nomoreargs@armFuncR0|
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    ldmia   sp!, {r4-r8, pc}
-    ENDP
-
-armFuncR0R1 PROC
-    stmdb   sp!, {r4-r8, lr}
-    mov     r6, r0  ; arg table
-    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
-    mov     r4, r2  ; function address
-    mov     r8, #0
-
-    mov     r0, r3          ; r0 explicitly set
-    ldr     r1, [sp, #6*4]  ; r1 explicitly set too
-
-    beq     |nomoreargs@armFuncR0R1|
-
-    ; Load the first 2 arguments into r2-r3
-    cmp     r7, #1*4
-    ldrge   r2, [r6],#4
-    cmp     r7, #2*4
-    ldrge   r3, [r6],#4
-    ble     |nomoreargs@armFuncR0R1|
-
-    ; Load the rest of the arguments onto the stack
-    sub     r7, r7, #2*4    ; skip the 2 registers already loaded into r2-r3
-    sub     sp, sp, r7
-    mov     r8, r7
-|stackargsloop@armFuncR0R1|
-    ldr     r5, [r6], #4
-    str     r5, [sp], #4
-    subs    r7, r7, #4
-    bne     |stackargsloop@armFuncR0R1|
-|nomoreargs@armFuncR0R1|
-    sub     sp, sp, r8
-    blx     r4
-    add     sp, sp, r8
-    ldmia   sp!, {r4-r8, pc}
-    ENDP
-
-    END
+;
+;  AngelCode Scripting Library
+;  Copyright (c) 2003-2009 Andreas Jonsson
+;
+;  This software is provided 'as-is', without any express or implied
+;  warranty. In no event will the authors be held liable for any
+;  damages arising from the use of this software.
+;
+;  Permission is granted to anyone to use this software for any
+;  purpose, including commercial applications, and to alter it and
+;  redistribute it freely, subject to the following restrictions:
+;
+;  1. The origin of this software must not be misrepresented; you
+;     must not claim that you wrote the original software. If you use
+;     this software in a product, an acknowledgment in the product
+;     documentation would be appreciated but is not required.
+;
+;  2. Altered source versions must be plainly marked as such, and
+;     must not be misrepresented as being the original software.
+;
+;  3. This notice may not be removed or altered from any source
+;     distribution.
+;
+;  The original version of this library can be located at:
+;  http://www.angelcode.com/angelscript/
+;
+;  Andreas Jonsson
+;  [email protected]
+;
+
+
+; Assembly routines for the ARM call convention
+; Written by Fredrik Ehnbom in June 2009
+
+; MSVC currently doesn't support inline assembly for the ARM platform
+; so this separate file is needed.
+
+
+    AREA	|.rdata|, DATA, READONLY
+    EXPORT |armFunc|
+    EXPORT armFuncR0
+    EXPORT armFuncR0R1
+    EXPORT armFuncObjLast
+    EXPORT armFuncR0ObjLast
+    
+
+    AREA	|.text|, CODE, ARM
+
+|armFunc| PROC
+    stmdb   sp!, {r4-r8, lr}
+    mov     r6, r0  ; arg table
+    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  ; function address
+    mov     r8, #0
+
+    beq     |nomoreargs|
+
+    ; Load the first 4 arguments into r0-r3
+    cmp     r7, #4
+    ldrge   r0, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r1, [r6],#4
+    cmp     r7, #3*4
+    ldrge   r2, [r6],#4
+    cmp     r7, #4*4
+    ldrge   r3, [r6],#4
+    ble     |nomoreargs|
+
+    ; Load the rest of the arguments onto the stack
+    sub     r7, r7, #4*4    ; skip the 4 registers already loaded into r0-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+|stackargsloop|
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     |stackargsloop|
+|nomoreargs|
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    ldmia   sp!, {r4-r8, pc}
+    ENDP
+
+armFuncObjLast PROC
+    stmdb   sp!, {r4-r8, lr}
+    mov     r6, r0  ; arg table
+    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  ; function address
+    mov     r8, #0
+
+    mov     r0, r3          ; objlast. might get overwritten
+    str     r3, [sp, #-4]!  ; objlast again.
+
+    beq     |nomoreargs@armFuncObjLast|
+
+    ; Load the first 4 arguments into r0-r3
+    cmp     r7, #4
+    ldrge   r0, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r1, [r6],#4
+    ldrlt   r1, [sp]    
+    cmp     r7, #3*4
+    ldrge   r2, [r6],#4
+    ldrlt   r2, [sp]
+    cmp     r7, #4*4
+    ldrge   r3, [r6],#4
+    ldrlt   r3, [sp]
+    ble     |nomoreargs@armFuncObjLast|
+
+    ; Load the rest of the arguments onto the stack
+    sub     r7, r7, #4*4    ; skip the 4 registers already loaded into r0-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+|stackargsloop@armFuncObjLast|
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     |stackargsloop@armFuncObjLast|
+|nomoreargs@armFuncObjLast|
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    add     sp, sp, #4
+    ldmia   sp!, {r4-r8, pc}
+    ENDP
+
+armFuncR0ObjLast PROC
+    stmdb   sp!, {r4-r8, lr}
+    ldr     r7, [sp,#6*4]
+    str     r7, [sp,#-4]!
+
+    mov     r6, r0  ; arg table
+    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  ; function address
+    mov     r8, #0
+
+    mov     r0, r3      ; r0 explicitly set
+    ldr     r1, [sp]    ; objlast.  might get overwritten
+
+    beq     |nomoreargs@armFuncR0ObjLast|
+
+    ; Load the first 3 arguments into r1-r3
+    cmp     r7, #1*4
+    ldrge   r1, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r2, [r6],#4
+    ldrlt   r2, [sp]
+    cmp     r7, #3*4
+    ldrge   r3, [r6],#4
+    ldrlt   r3, [sp]
+    ble     |nomoreargs@armFuncR0ObjLast|
+
+    ; Load the rest of the arguments onto the stack
+    sub     r7, r7, #3*4    ; skip the 3 registers already loaded into r1-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+|stackargsloop@armFuncR0ObjLast|
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     |stackargsloop@armFuncR0ObjLast|
+|nomoreargs@armFuncR0ObjLast|
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    add     sp, sp, #4
+    ldmia   sp!, {r4-r8, pc}
+    ENDP
+
+armFuncR0 PROC
+    stmdb   sp!, {r4-r8, lr}
+    mov     r6, r0  ; arg table
+    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  ; function address
+    mov     r8, #0
+
+    mov     r0, r3  ; r0 explicitly set
+
+    beq     |nomoreargs@armFuncR0|
+
+    ; Load the first 3 arguments into r1-r3
+    cmp     r7, #1*4
+    ldrge   r1, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r2, [r6],#4
+    cmp     r7, #3*4
+    ldrge   r3, [r6],#4
+    ble     |nomoreargs@armFuncR0|
+
+    ; Load the rest of the arguments onto the stack
+    sub     r7, r7, #3*4    ; skip the 3 registers already loaded into r1-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+|stackargsloop@armFuncR0|
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     |stackargsloop@armFuncR0|
+|nomoreargs@armFuncR0|
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    ldmia   sp!, {r4-r8, pc}
+    ENDP
+
+armFuncR0R1 PROC
+    stmdb   sp!, {r4-r8, lr}
+    mov     r6, r0  ; arg table
+    movs    r7, r1  ; arg size (also set the condition code flags so that we detect if there are no arguments)
+    mov     r4, r2  ; function address
+    mov     r8, #0
+
+    mov     r0, r3          ; r0 explicitly set
+    ldr     r1, [sp, #6*4]  ; r1 explicitly set too
+
+    beq     |nomoreargs@armFuncR0R1|
+
+    ; Load the first 2 arguments into r2-r3
+    cmp     r7, #1*4
+    ldrge   r2, [r6],#4
+    cmp     r7, #2*4
+    ldrge   r3, [r6],#4
+    ble     |nomoreargs@armFuncR0R1|
+
+    ; Load the rest of the arguments onto the stack
+    sub     r7, r7, #2*4    ; skip the 2 registers already loaded into r2-r3
+    sub     sp, sp, r7
+    mov     r8, r7
+|stackargsloop@armFuncR0R1|
+    ldr     r5, [r6], #4
+    str     r5, [sp], #4
+    subs    r7, r7, #4
+    bne     |stackargsloop@armFuncR0R1|
+|nomoreargs@armFuncR0R1|
+    sub     sp, sp, r8
+    blx     r4
+    add     sp, sp, r8
+    ldmia   sp!, {r4-r8, pc}
+    ENDP
+
+    END

+ 50 - 26
ThirdParty/AngelScript/source/as_callfunc_x64_gcc.cpp

@@ -121,7 +121,7 @@ static asDWORD GetReturnedFloat()
 		"movss    %%xmm0, (%%rax)"
 		"movss    %%xmm0, (%%rax)"
 		: /* no output */
 		: /* no output */
 		: "m" (retval)
 		: "m" (retval)
-		: "%rax", "%xmm0"
+		: "%rax"
 	);
 	);
 
 
 	// We need to avoid implicit conversions from float to unsigned - we need
 	// We need to avoid implicit conversions from float to unsigned - we need
@@ -141,27 +141,7 @@ static asQWORD GetReturnedDouble()
 		"movlpd  %%xmm0, (%%rax)"
 		"movlpd  %%xmm0, (%%rax)"
 		: /* no optput */
 		: /* no optput */
 		: "m" (retval)
 		: "m" (retval)
-		: "%rax", "%xmm0"
-	);
-
-	// We need to avoid implicit conversions from double to unsigned long long - we need
-	// a bit-wise-correct-and-complete copy of the value 
-	memcpy( &ret, &retval, sizeof( ret ) );
-
-	return ret;
-}
-
-static asQWORD GetReturnedHighBytes()
-{
-	double  retval = 0.0f;
-	asQWORD ret    = 0;
-
-	__asm__ __volatile__ (
-		"lea     %0, %%rax\n"
-		"movlpd  %%xmm1, (%%rax)"
-		: /* no optput */
-		: "m" (retval)
-		: "%rax", "%xmm1"
+		: "%rax"
 	);
 	);
 
 
 	// We need to avoid implicit conversions from double to unsigned long long - we need
 	// We need to avoid implicit conversions from double to unsigned long long - we need
@@ -304,6 +284,54 @@ asQWORD CallSystemFunctionNative(asCContext *context, asCScriptFunction *descr,
 	}
 	}
 	memset( tempType, 0, sizeof( tempType ) );
 	memset( tempType, 0, sizeof( tempType ) );
 
 
+	// TODO: This should be checked in PrepareSystemFunction
+#ifndef COMPLEX_OBJS_PASSED_BY_REF
+	if( sysFunc->takesObjByVal ) {
+		/* I currently know of no way we can predict register usage for passing complex
+		   objects by value when the compiler does not pass them by reference instead. I
+		   will quote the example from the AMD64 ABI to demonstrate this:
+
+		   (http://www.x86-64.org/documentation/abi.pdf - page 22)
+
+		------------------------------ BEGIN EXAMPLE -------------------------------
+
+		Let us consider the following C code:
+
+		typedef struct {
+			int a, b;
+			double d;
+		} structparm;
+
+		structparm s;
+		int e, f, g, h, i, j, k;
+		long double ld;
+		double m, n;
+
+		extern void func (int e, int f,
+			structparm s, int g, int h,
+			long double ld, double m,
+			double n, int i, int j, int k);
+
+		func (e, f, s, g, h, ld, m, n, i, j, k);
+
+		Register allocation for the call:
+		--------------------------+--------------------------+-------------------
+		General Purpose Registers | Floating Point Registers | Stack Frame Offset
+		--------------------------+--------------------------+-------------------
+		 %rdi: e                  | %xmm0: s.d               | 0:  ld
+		 %rsi: f                  | %xmm1: m                 | 16: j
+		 %rdx: s.a,s.b            | %xmm2: n                 | 24: k
+		 %rcx: g                  |                          |
+		 %r8:  h                  |                          |
+		 %r9:  i                  |                          |
+		--------------------------+--------------------------+-------------------
+		*/
+
+		context->SetInternalException( TXT_INVALID_CALLING_CONVENTION );
+		return 0;
+	}
+#endif
+
 	if ( obj && ( callConv == ICC_VIRTUAL_THISCALL || callConv == ICC_VIRTUAL_THISCALL_RETURNINMEM ) ) {
 	if ( obj && ( callConv == ICC_VIRTUAL_THISCALL || callConv == ICC_VIRTUAL_THISCALL_RETURNINMEM ) ) {
 		vftable = *( ( funcptr_t ** )obj );
 		vftable = *( ( funcptr_t ** )obj );
 		func    = ( void * )vftable[( asQWORD )func >> 3];
 		func    = ( void * )vftable[( asQWORD )func >> 3];
@@ -489,11 +517,7 @@ asQWORD CallSystemFunctionNative(asCContext *context, asCScriptFunction *descr,
 		if( sysFunc->hostReturnSize == 1 )
 		if( sysFunc->hostReturnSize == 1 )
 			*(asDWORD*)&retQW = GetReturnedFloat();
 			*(asDWORD*)&retQW = GetReturnedFloat();
 		else
 		else
-		{
 			retQW = GetReturnedDouble();
 			retQW = GetReturnedDouble();
-			if( sysFunc->hostReturnSize > 2 )
-				retQW2 = GetReturnedHighBytes();
-		}
 	}
 	}
 
 
 	return retQW;
 	return retQW;

+ 67 - 277
ThirdParty/AngelScript/source/as_compiler.cpp

@@ -234,14 +234,6 @@ int asCCompiler::CompileFunction(asCBuilder *builder, asCScriptCode *script, asC
 			str.Format(TXT_DATA_TYPE_CANT_BE_s, returnType.Format().AddressOf());
 			str.Format(TXT_DATA_TYPE_CANT_BE_s, returnType.Format().AddressOf());
 			Error(str.AddressOf(), func->firstChild);
 			Error(str.AddressOf(), func->firstChild);
 		}
 		}
-
-#ifndef AS_OLD
-		// If the return type is a value type returned by value the address of the
-		// location where the value will be stored is pushed on the stack before 
-		// the arguments
-		if( outFunc->DoesReturnOnStack() )
-			stackPos -= AS_PTR_SIZE;
-#endif
 	}
 	}
 	else
 	else
 	{
 	{
@@ -445,7 +437,7 @@ int asCCompiler::CompileFunction(asCBuilder *builder, asCScriptCode *script, asC
 	return 0;
 	return 0;
 }
 }
 
 
-int asCCompiler::CallCopyConstructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc, asSExprContext *arg, asCScriptNode *node, bool isGlobalVar, bool derefDest)
+int asCCompiler::CallCopyConstructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc, asSExprContext *arg, asCScriptNode *node, bool isGlobalVar)
 {
 {
 	if( !type.IsObject() )
 	if( !type.IsObject() )
 		return 0;
 		return 0;
@@ -524,11 +516,6 @@ int asCCompiler::CallCopyConstructor(asCDataType &type, int offset, bool isObjec
 			{
 			{
 				asASSERT( !isGlobalVar );
 				asASSERT( !isGlobalVar );
 				bc->InstrSHORT(asBC_PSF, (short)offset);
 				bc->InstrSHORT(asBC_PSF, (short)offset);
-				if( derefDest )
-				{
-					// The variable is a reference to the real location, so we need to dereference it
-					bc->Instr(asBC_RDSPTR);
-				}
 			}
 			}
 
 
 			asSExprContext ctx(engine);
 			asSExprContext ctx(engine);
@@ -554,7 +541,7 @@ int asCCompiler::CallCopyConstructor(asCDataType &type, int offset, bool isObjec
 	return -1;
 	return -1;
 }
 }
 
 
-int asCCompiler::CallDefaultConstructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc, asCScriptNode *node, bool isGlobalVar, bool deferDest)
+int asCCompiler::CallDefaultConstructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc, asCScriptNode *node, bool isGlobalVar)
 {
 {
 	if( !type.IsObject() ||
 	if( !type.IsObject() ||
 		(type.IsObjectHandle() && !(type.GetObjectType()->flags & asOBJ_ASHANDLE)) )
 		(type.IsObjectHandle() && !(type.GetObjectType()->flags & asOBJ_ASHANDLE)) )
@@ -616,8 +603,6 @@ int asCCompiler::CallDefaultConstructor(asCDataType &type, int offset, bool isOb
 				{
 				{
 					// Call the constructor as a normal function
 					// Call the constructor as a normal function
 					bc->InstrSHORT(asBC_PSF, (short)offset);
 					bc->InstrSHORT(asBC_PSF, (short)offset);
-					if( deferDest )
-						bc->Instr(asBC_RDSPTR);
 					asSExprContext ctx(engine);
 					asSExprContext ctx(engine);
 					PerformFunctionCall(func, &ctx, false, 0, type.GetObjectType());
 					PerformFunctionCall(func, &ctx, false, 0, type.GetObjectType());
 					bc->AddCode(&ctx.bc);
 					bc->AddCode(&ctx.bc);
@@ -1108,11 +1093,11 @@ void asCCompiler::PrepareArgument(asCDataType *paramType, asSExprContext *ctx, a
 			{
 			{
 				IsVariableInitialized(&ctx->type, node);
 				IsVariableInitialized(&ctx->type, node);
 
 
-				if( ctx->type.dataType.IsReference() ) ConvertToVariableNotIn(ctx, reservedVars);
+				if( ctx->type.dataType.IsReference() ) ConvertToVariable(ctx);
 				ImplicitConversion(ctx, dt, node, asIC_IMPLICIT_CONV, true, reservedVars);
 				ImplicitConversion(ctx, dt, node, asIC_IMPLICIT_CONV, true, reservedVars);
 
 
 				if( !(param.IsReadOnly() && ctx->type.isVariable) )
 				if( !(param.IsReadOnly() && ctx->type.isVariable) )
-					ConvertToTempVariableNotIn(ctx, reservedVars);
+					ConvertToTempVariable(ctx);
 
 
 				PushVariableOnStack(ctx, true);
 				PushVariableOnStack(ctx, true);
 				ctx->type.dataType.MakeReadOnly(param.IsReadOnly());
 				ctx->type.dataType.MakeReadOnly(param.IsReadOnly());
@@ -1228,8 +1213,6 @@ void asCCompiler::PrepareArgument(asCDataType *paramType, asSExprContext *ctx, a
 		}
 		}
 		else if( refType == asTM_INOUTREF )
 		else if( refType == asTM_INOUTREF )
 		{
 		{
-			ProcessPropertyGetAccessor(ctx, node);
-
 			// Literal constants cannot be passed to inout ref arguments
 			// Literal constants cannot be passed to inout ref arguments
 			if( !ctx->type.isVariable && ctx->type.isConstant )
 			if( !ctx->type.isVariable && ctx->type.isConstant )
 			{
 			{
@@ -1295,7 +1278,7 @@ void asCCompiler::PrepareArgument(asCDataType *paramType, asSExprContext *ctx, a
 		{
 		{
 			IsVariableInitialized(&ctx->type, node);
 			IsVariableInitialized(&ctx->type, node);
 
 
-			if( ctx->type.dataType.IsReference() ) ConvertToVariableNotIn(ctx, reservedVars);
+			if( ctx->type.dataType.IsReference() ) ConvertToVariable(ctx);
 
 
 			// Implicitly convert primitives to the parameter type
 			// Implicitly convert primitives to the parameter type
 			ImplicitConversion(ctx, dt, node, asIC_IMPLICIT_CONV, true, reservedVars);
 			ImplicitConversion(ctx, dt, node, asIC_IMPLICIT_CONV, true, reservedVars);
@@ -1306,7 +1289,7 @@ void asCCompiler::PrepareArgument(asCDataType *paramType, asSExprContext *ctx, a
 			}
 			}
 			else if( ctx->type.isConstant )
 			else if( ctx->type.isConstant )
 			{
 			{
-				ConvertToVariableNotIn(ctx, reservedVars);
+				ConvertToVariable(ctx);
 				PushVariableOnStack(ctx, dt.IsReference());
 				PushVariableOnStack(ctx, dt.IsReference());
 			}
 			}
 		}
 		}
@@ -1370,10 +1353,10 @@ void asCCompiler::PrepareArgument(asCDataType *paramType, asSExprContext *ctx, a
 	}
 	}
 }
 }
 
 
-void asCCompiler::PrepareFunctionCall(int funcId, asCByteCode *bc, asCArray<asSExprContext *> &args)
+void asCCompiler::PrepareFunctionCall(int funcID, asCByteCode *bc, asCArray<asSExprContext *> &args)
 {
 {
 	// When a match has been found, compile the final byte code using correct parameter types
 	// When a match has been found, compile the final byte code using correct parameter types
-	asCScriptFunction *descr = builder->GetFunctionDescription(funcId);
+	asCScriptFunction *descr = builder->GetFunctionDescription(funcID);
 
 
 	// Add code for arguments
 	// Add code for arguments
 	asSExprContext e(engine);
 	asSExprContext e(engine);
@@ -1392,20 +1375,14 @@ void asCCompiler::PrepareFunctionCall(int funcId, asCByteCode *bc, asCArray<asSE
 	bc->AddCode(&e.bc);
 	bc->AddCode(&e.bc);
 }
 }
 
 
-void asCCompiler::MoveArgsToStack(int funcId, asCByteCode *bc, asCArray<asSExprContext *> &args, bool addOneToOffset)
+void asCCompiler::MoveArgsToStack(int funcID, asCByteCode *bc, asCArray<asSExprContext *> &args, bool addOneToOffset)
 {
 {
-	asCScriptFunction *descr = builder->GetFunctionDescription(funcId);
+	asCScriptFunction *descr = builder->GetFunctionDescription(funcID);
 
 
 	int offset = 0;
 	int offset = 0;
 	if( addOneToOffset )
 	if( addOneToOffset )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
 
 
-#ifndef AS_OLD
-	// The address of where the return value should be stored is push on top of the arguments
-	if( descr->DoesReturnOnStack() )
-		offset += AS_PTR_SIZE;
-#endif
-
 	// Move the objects that are sent by value to the stack just before the call
 	// Move the objects that are sent by value to the stack just before the call
 	for( asUINT n = 0; n < descr->parameterTypes.GetLength(); n++ )
 	for( asUINT n = 0; n < descr->parameterTypes.GetLength(); n++ )
 	{
 	{
@@ -1601,20 +1578,13 @@ void asCCompiler::MatchFunctions(asCArray<int> &funcs, asCArray<asSExprContext*>
 
 
 			if( desc->parameterTypes.GetLength() != args.GetLength() )
 			if( desc->parameterTypes.GetLength() != args.GetLength() )
 			{
 			{
-				bool noMatch = true;
-				if( args.GetLength() < desc->parameterTypes.GetLength() )
-				{
-					// Count the number of default args
-					asUINT defaultArgs = 0;
-					for( asUINT d = 0; d < desc->defaultArgs.GetLength(); d++ )
-						if( desc->defaultArgs[d] )
-							defaultArgs++;
-
-					if( args.GetLength() >= desc->parameterTypes.GetLength() - defaultArgs )
-						noMatch = false;
-				}
+				// Count the number of default args
+				asUINT defaultArgs = 0;
+				for( asUINT d = 0; d < desc->defaultArgs.GetLength(); d++ )
+					if( desc->defaultArgs[d] )
+						defaultArgs++;
 
 
-				if( noMatch )
+				if( args.GetLength() < desc->parameterTypes.GetLength() - defaultArgs )
 				{
 				{
 					// remove it from the list
 					// remove it from the list
 					if( n == funcs.GetLength()-1 )
 					if( n == funcs.GetLength()-1 )
@@ -1734,18 +1704,6 @@ void asCCompiler::CompileDeclaration(asCScriptNode *decl, asCByteCode *bc)
 			type = asCDataType::CreatePrimitive(ttInt, false);
 			type = asCDataType::CreatePrimitive(ttInt, false);
 		}
 		}
 
 
-		// A shared object may not declare variables of non-shared types
-		if( outFunc->objectType && outFunc->objectType->IsShared() )
-		{
-			asCObjectType *ot = type.GetObjectType();
-			if( ot && !ot->IsShared() )
-			{
-				asCString msg;
-				msg.Format(TXT_SHARED_CANNOT_USE_NON_SHARED_TYPE_s, ot->name.AddressOf());
-				Error(msg.AddressOf(), decl);
-			}
-		}
-
 		// Get the name of the identifier
 		// Get the name of the identifier
 		asCString name(&script->code[node->tokenPos], node->tokenLength);
 		asCString name(&script->code[node->tokenPos], node->tokenLength);
 
 
@@ -3180,7 +3138,7 @@ void asCCompiler::CompileReturnStatement(asCScriptNode *rnode, asCByteCode *bc)
 					asCString str;
 					asCString str;
 					str.Format(TXT_NO_CONVERSION_s_TO_s, expr.type.dataType.Format().AddressOf(), v->type.Format().AddressOf());
 					str.Format(TXT_NO_CONVERSION_s_TO_s, expr.type.dataType.Format().AddressOf(), v->type.Format().AddressOf());
 					Error(str.AddressOf(), rnode);
 					Error(str.AddressOf(), rnode);
-					return;
+					r = -1;
 				}
 				}
 				else
 				else
 				{
 				{
@@ -3201,80 +3159,25 @@ void asCCompiler::CompileReturnStatement(asCScriptNode *rnode, asCByteCode *bc)
 			}
 			}
 			else if( v->type.IsObject() )
 			else if( v->type.IsObject() )
 			{
 			{
-#ifndef AS_OLD
-				// Value types are returned on the stack, in a location
-				// that has been reserved by the calling function. 
-				if( outFunc->DoesReturnOnStack() )
-				{
-					// TODO: optimize: If the return type has a constructor that takes the type of the expression,
-					//                 it should be called directly instead of first converting the expression and 
-					//                 then copy the value.
-					if( !v->type.IsEqualExceptRefAndConst(expr.type.dataType) ) 
-					{
-						ImplicitConversion(&expr, v->type, rnode->firstChild, asIC_IMPLICIT_CONV);
-						if( !v->type.IsEqualExceptRefAndConst(expr.type.dataType) )
-						{
-							asCString str;
-							str.Format(TXT_CANT_IMPLICITLY_CONVERT_s_TO_s, expr.type.dataType.Format().AddressOf(), v->type.Format().AddressOf());
-							Error(str.AddressOf(), rnode->firstChild);
-							return;
-						}
-					}
+				// Value types are still returned on the heap, so we must
+				// copy the value to an object allocated on the heap here
+				PrepareArgument(&v->type, &expr, rnode->firstChild, false, 0, 0, true);
 
 
-					int offset = outFunc->objectType ? -AS_PTR_SIZE : 0;
-					if( v->type.GetObjectType()->beh.copyconstruct )
-					{
-						PrepareForAssignment(&v->type, &expr, rnode->firstChild);					
-						CallCopyConstructor(v->type, offset, false, &expr.bc, &expr, rnode->firstChild, false, true);
-					}
-					else
-					{
-						// If the copy constructor doesn't exist, then a manual assignment needs to be done instead. 
-						CallDefaultConstructor(v->type, offset, false, &expr.bc, rnode->firstChild, false, true);
-						PrepareForAssignment(&v->type, &expr, rnode->firstChild);
-						expr.bc.InstrSHORT(asBC_PSF, (short)offset);
-						expr.bc.Instr(asBC_RDSPTR);
-
-						asSExprContext lexpr(engine);
-						lexpr.type.Set(v->type);
-						lexpr.type.isLValue = true;
-						PerformAssignment(&lexpr.type, &expr.type, &expr.bc, rnode->firstChild);
-						expr.bc.Pop(AS_PTR_SIZE);
-
-						// Release any temporary variable
-						ReleaseTemporaryVariable(expr.type, &expr.bc);
-					}
-
-					// Clean up the local variables and process deferred parameters
-					DestroyVariables(&expr.bc);
-					ProcessDeferredParams(&expr);
-				}
-				else
-#endif
-				{
-#ifndef AS_OLD
-					asASSERT( v->type.GetObjectType()->flags & asOBJ_REF );
-#endif
-					// Prepare the expression to be loaded into the object 
-					// register. This will place the reference in local variable
-					PrepareArgument(&v->type, &expr, rnode->firstChild, false, 0, 0, true);
-
-					// Pop the reference to the temporary variable
-					expr.bc.Pop(AS_PTR_SIZE);
+				// Pop the reference to the temporary variable again
+				expr.bc.Pop(AS_PTR_SIZE);
 
 
-					// Clean up the local variables and process deferred parameters
-					DestroyVariables(&expr.bc);
-					ProcessDeferredParams(&expr);
+				// Clean up the local variables and process deferred parameters
+				DestroyVariables(&expr.bc);
+				ProcessDeferredParams(&expr);
 
 
-					// Load the object pointer into the object register
-					// LOADOBJ also clears the address in the variable
-					expr.bc.InstrSHORT(asBC_LOADOBJ, expr.type.stackOffset);
+				// Load the object pointer into the object register
+				// LOADOBJ also clears the address in the variable
+				expr.bc.InstrSHORT(asBC_LOADOBJ, expr.type.stackOffset);
 
 
-					// LOADOBJ cleared the address in the variable so the object will not be freed
-					// here, but the temporary variable must still be freed so the slot can be reused
-					// By releasing without the bytecode we do just that.
-					ReleaseTemporaryVariable(expr.type, 0);
-				}
+				// LOADOBJ cleared the address in the variable so the object will not be freed
+				// here, but the temporary variable must still be freed so the slot can be reused
+				// By releasing without the bytecode we do just that.
+				ReleaseTemporaryVariable(expr.type, 0);
 			}
 			}
 		}
 		}
 
 
@@ -3557,15 +3460,11 @@ void asCCompiler::ReleaseTemporaryVariable(int offset, asCByteCode *bc)
 	{
 	{
 		// We need to call the destructor on the true variable type
 		// We need to call the destructor on the true variable type
 		int n = GetVariableSlot(offset);
 		int n = GetVariableSlot(offset);
-		asASSERT( n >= 0 );
-		if( n >= 0 )
-		{
-			asCDataType dt = variableAllocations[n];
-			bool isOnHeap = variableIsOnHeap[n];
+		asCDataType dt = variableAllocations[n];
+		bool isOnHeap = variableIsOnHeap[n];
 
 
-			// Call destructor
-			CallDestructor(dt, offset, isOnHeap, bc);
-		}
+		// Call destructor
+		CallDestructor(dt, offset, isOnHeap, bc);
 	}
 	}
 
 
 	DeallocateVariable(offset);
 	DeallocateVariable(offset);
@@ -3814,8 +3713,6 @@ bool asCCompiler::CompileRefCast(asSExprContext *ctx, const asCDataType &to, boo
 {
 {
 	bool conversionDone = false;
 	bool conversionDone = false;
 
 
-	// TODO: shared: Do not allow casting to non shared type
-
 	asCArray<int> ops;
 	asCArray<int> ops;
 	asUINT n;
 	asUINT n;
 
 
@@ -4600,18 +4497,7 @@ void asCCompiler::ImplicitConvObjectToObject(asSExprContext *ctx, const asCDataT
 			{
 			{
 				asCTypeInfo objType = ctx->type;
 				asCTypeInfo objType = ctx->type;
 				Dereference(ctx, true);
 				Dereference(ctx, true);
-
-				bool useVariable = false;
-				int  stackOffset = 0;
-#ifndef AS_OLD
-				if( f->DoesReturnOnStack() )
-				{
-					useVariable = true;
-					stackOffset = AllocateVariable(f->returnType, true);
-					ctx->bc.InstrSHORT(asBC_PSF, short(stackOffset));
-				}
-#endif
-				PerformFunctionCall(funcs[0], ctx, false, 0, 0, useVariable, stackOffset);
+				PerformFunctionCall(funcs[0], ctx);
 				ReleaseTemporaryVariable(objType, &ctx->bc);
 				ReleaseTemporaryVariable(objType, &ctx->bc);
 			}
 			}
 			else
 			else
@@ -6227,9 +6113,8 @@ int asCCompiler::CompileVariableAccess(const asCString &name, const asCString &s
 		{
 		{
 			bool isCompiled = true;
 			bool isCompiled = true;
 			bool isPureConstant = false;
 			bool isPureConstant = false;
-			bool isAppProp = false;
 			asQWORD constantValue;
 			asQWORD constantValue;
-			asCGlobalProperty *prop = builder->GetGlobalProperty(name.AddressOf(), &isCompiled, &isPureConstant, &constantValue, &isAppProp);
+			asCGlobalProperty *prop = builder->GetGlobalProperty(name.AddressOf(), &isCompiled, &isPureConstant, &constantValue);
 			if( prop )
 			if( prop )
 			{
 			{
 				found = true;
 				found = true;
@@ -6251,20 +6136,6 @@ int asCCompiler::CompileVariableAccess(const asCString &name, const asCString &s
 						ctx->type.SetConstantQW(prop->type, constantValue);
 						ctx->type.SetConstantQW(prop->type, constantValue);
 					else
 					else
 					{
 					{
-						// A shared type must not access global vars, unless they  
-						// too are shared, e.g. application registered vars
-						if( outFunc->objectType && outFunc->objectType->IsShared() )
-						{
-							if( !isAppProp )
-							{
-								asCString str;
-								str.Format(TXT_SHARED_CANNOT_ACCESS_NON_SHARED_VAR_s, prop->name.AddressOf());
-								Error(str.AddressOf(), errNode);
-
-								// Allow the compilation to continue to catch other problems
-							}
-						}
-
 						ctx->type.Set(prop->type);
 						ctx->type.Set(prop->type);
 						ctx->type.dataType.MakeReference(true);
 						ctx->type.dataType.MakeReference(true);
 						ctx->type.isLValue = true;
 						ctx->type.isLValue = true;
@@ -6324,8 +6195,6 @@ int asCCompiler::CompileVariableAccess(const asCString &name, const asCString &s
 		{
 		{
 			found = true;
 			found = true;
 
 
-			// TODO: shared: A shared object may not access global functions unless they too are shared (e.g. registered functions)
-
 			// Push the function pointer on the stack
 			// Push the function pointer on the stack
 			ctx->bc.InstrPTR(asBC_FuncPtr, engine->scriptFunctions[funcs[0]]);
 			ctx->bc.InstrPTR(asBC_FuncPtr, engine->scriptFunctions[funcs[0]]);
 			ctx->type.Set(asCDataType::CreateFuncDef(engine->scriptFunctions[funcs[0]]));
 			ctx->type.Set(asCDataType::CreateFuncDef(engine->scriptFunctions[funcs[0]]));
@@ -6365,9 +6234,6 @@ int asCCompiler::CompileVariableAccess(const asCString &name, const asCString &s
 
 
 		if( found )
 		if( found )
 		{
 		{
-			// Even if the enum type is not shared, and we're compiling a shared object,
-			// the use of the values are still allowed, since they are treated as constants.
-
 			// an enum value was resolved
 			// an enum value was resolved
 			ctx->type.SetConstantDW(dt, value);
 			ctx->type.SetConstantDW(dt, value);
 		}
 		}
@@ -6563,19 +6429,7 @@ int asCCompiler::CompileExpressionValue(asCScriptNode *node, asSExprContext *ctx
 					// Register the constant string with the engine
 					// Register the constant string with the engine
 					int id = engine->AddConstantString(str.AddressOf(), str.GetLength());
 					int id = engine->AddConstantString(str.AddressOf(), str.GetLength());
 					ctx->bc.InstrWORD(asBC_STR, (asWORD)id);
 					ctx->bc.InstrWORD(asBC_STR, (asWORD)id);
-
-					bool useVariable = false;
-					int stackOffset  = 0;
-#ifndef AS_OLD
-					if( descr->DoesReturnOnStack() )
-					{
-						useVariable = true;
-						stackOffset = AllocateVariable(descr->returnType, true);
-						ctx->bc.InstrSHORT(asBC_PSF, short(stackOffset));
-					}
-#endif
-
-					PerformFunctionCall(descr->id, ctx, false, 0, 0, useVariable, stackOffset);
+					PerformFunctionCall(descr->id, ctx);
 				}
 				}
 			}
 			}
 		}
 		}
@@ -7233,8 +7087,6 @@ void asCCompiler::ProcessDeferredParams(asSExprContext *ctx)
 
 
 void asCCompiler::CompileConstructCall(asCScriptNode *node, asSExprContext *ctx)
 void asCCompiler::CompileConstructCall(asCScriptNode *node, asSExprContext *ctx)
 {
 {
-	// TODO: shared: Do not allow constructing non-shared types
-
 	// The first node is a datatype node
 	// The first node is a datatype node
 	asCString name;
 	asCString name;
 	asCTypeInfo tempObj;
 	asCTypeInfo tempObj;
@@ -8626,7 +8478,7 @@ int asCCompiler::CompileExpressionPostOp(asCScriptNode *node, asSExprContext *ct
 			if( ctx->property_get )
 			if( ctx->property_get )
 				func = engine->scriptFunctions[ctx->property_get];
 				func = engine->scriptFunctions[ctx->property_get];
 			else
 			else
-				func = engine->scriptFunctions[ctx->property_set];
+				func = engine->scriptFunctions[ctx->property_get];
 			propertyName = func->GetName();
 			propertyName = func->GetName();
 			propertyName = propertyName.SubString(4);
 			propertyName = propertyName.SubString(4);
 
 
@@ -9112,15 +8964,9 @@ int asCCompiler::CompileOverloadedDualOperator2(asCScriptNode *node, const char
 				(!isConst || func->isReadOnly) )
 				(!isConst || func->isReadOnly) )
 			{
 			{
 				// Make sure the method is accessible by the module
 				// Make sure the method is accessible by the module
-				if( builder->module->accessMask & func->accessMask )
-				{
-#ifdef AS_DEPRECATED
-					// deprecated since 2011-10-04
-					asCConfigGroup *group = engine->FindConfigGroupForFunction(func->id);
-					if( !group || group->HasModuleAccess(builder->module->name.AddressOf()) )
-#endif
+				asCConfigGroup *group = engine->FindConfigGroupForFunction(func->id);
+				if( !group || group->HasModuleAccess(builder->module->name.AddressOf()) )
 					funcs.PushLast(func->id);
 					funcs.PushLast(func->id);
-				}
 			}
 			}
 		}
 		}
 
 
@@ -9238,24 +9084,10 @@ void asCCompiler::MakeFunctionCall(asSExprContext *ctx, int funcId, asCObjectTyp
 			ctx->bc.ExchangeVar(args[n]->type.stackOffset, newOffset);
 			ctx->bc.ExchangeVar(args[n]->type.stackOffset, newOffset);
 			args[n]->type.stackOffset = (short)newOffset;
 			args[n]->type.stackOffset = (short)newOffset;
 			args[n]->type.isTemporary = true;
 			args[n]->type.isTemporary = true;
-			args[n]->type.isVariable  = true;
+			args[n]->type.isVariable = true;
 		}
 		}
 	}
 	}
 
 
-#ifndef AS_OLD
-	// If the function will return a value type on the stack, then we must allocate space 
-	// for that here and push the address on the stack as a hidden argument to the function
-	asCScriptFunction *func = builder->GetFunctionDescription(funcId);
-	if( func->DoesReturnOnStack() )
-	{
-		asASSERT(!useVariable);
-
-		useVariable = true;
-		stackOffset = AllocateVariable(func->returnType, true);
-		ctx->bc.InstrSHORT(asBC_PSF, short(stackOffset));
-	}
-#endif
-
 	ctx->bc.AddCode(&objBC);
 	ctx->bc.AddCode(&objBC);
 
 
 	MoveArgsToStack(funcId, &ctx->bc, args, objectType ? true : false);
 	MoveArgsToStack(funcId, &ctx->bc, args, objectType ? true : false);
@@ -9968,7 +9800,7 @@ void asCCompiler::CompileBitwiseOperator(asCScriptNode *node, asSExprContext *lc
 		else if( !lctx->type.dataType.IsUnsignedType() )
 		else if( !lctx->type.dataType.IsUnsignedType() )
 		{
 		{
 			asCDataType to;
 			asCDataType to;
-			if( lctx->type.dataType.GetSizeInMemoryDWords() == 2 )
+			if( lctx->type.dataType.GetSizeInMemoryDWords() == 2  )
 				to.SetTokenType(ttInt64);
 				to.SetTokenType(ttInt64);
 			else
 			else
 				to.SetTokenType(ttInt);
 				to.SetTokenType(ttInt);
@@ -10717,18 +10549,6 @@ void asCCompiler::PerformFunctionCall(int funcId, asSExprContext *ctx, bool isCo
 {
 {
 	asCScriptFunction *descr = builder->GetFunctionDescription(funcId);
 	asCScriptFunction *descr = builder->GetFunctionDescription(funcId);
 
 
-	// A shared object may not call non-shared functions
-	if( outFunc->objectType && outFunc->objectType->IsShared() )
-	{
-		if( descr->funcType == asFUNC_SCRIPT &&
-			(descr->objectType == 0 || !descr->objectType->IsShared()) )
-		{
-			asCString msg;
-			msg.Format(TXT_SHARED_CANNOT_CALL_NON_SHARED_FUNC_s, descr->GetDeclarationStr().AddressOf());
-			Error(msg.AddressOf(), ctx->exprNode);
-		}
-	}
-
 	// Check if the function is private
 	// Check if the function is private
 	if( descr->isPrivate && descr->GetObjectType() != outFunc->GetObjectType() )
 	if( descr->isPrivate && descr->GetObjectType() != outFunc->GetObjectType() )
 	{
 	{
@@ -10784,73 +10604,43 @@ void asCCompiler::PerformFunctionCall(int funcId, asSExprContext *ctx, bool isCo
 
 
 		return;
 		return;
 	}
 	}
-	else
-	{
-		if( descr->objectType )
-			argSize += AS_PTR_SIZE;
-#ifndef AS_OLD
-		// If the function returns an object by value the address of the location
-		// where the value should be stored is passed as an argument too
-		if( descr->DoesReturnOnStack() )
-		{
-			argSize += AS_PTR_SIZE;
-		}
-#endif
-
-		if( descr->funcType == asFUNC_IMPORTED )
-			ctx->bc.Call(asBC_CALLBND , descr->id, argSize);
-		// TODO: Maybe we need two different byte codes
-		else if( descr->funcType == asFUNC_INTERFACE || descr->funcType == asFUNC_VIRTUAL )
-			ctx->bc.Call(asBC_CALLINTF, descr->id, argSize);
-		else if( descr->funcType == asFUNC_SCRIPT )
-			ctx->bc.Call(asBC_CALL    , descr->id, argSize);
-		else if( descr->funcType == asFUNC_SYSTEM )
-			ctx->bc.Call(asBC_CALLSYS , descr->id, argSize);
-		else if( descr->funcType == asFUNC_FUNCDEF )
-			ctx->bc.CallPtr(asBC_CallPtr, funcPtrVar, argSize);
-	}
+	else if( descr->funcType == asFUNC_IMPORTED )
+		ctx->bc.Call(asBC_CALLBND , descr->id, argSize + (descr->objectType ? AS_PTR_SIZE : 0));
+	// TODO: Maybe we need two different byte codes
+	else if( descr->funcType == asFUNC_INTERFACE || descr->funcType == asFUNC_VIRTUAL )
+		ctx->bc.Call(asBC_CALLINTF, descr->id, argSize + (descr->objectType ? AS_PTR_SIZE : 0));
+	else if( descr->funcType == asFUNC_SCRIPT )
+		ctx->bc.Call(asBC_CALL    , descr->id, argSize + (descr->objectType ? AS_PTR_SIZE : 0));
+	else if( descr->funcType == asFUNC_SYSTEM )
+		ctx->bc.Call(asBC_CALLSYS , descr->id, argSize + (descr->objectType ? AS_PTR_SIZE : 0));
+	else if( descr->funcType == asFUNC_FUNCDEF )
+		ctx->bc.CallPtr(asBC_CallPtr, funcPtrVar, argSize);
 
 
 	if( ctx->type.dataType.IsObject() && !descr->returnType.IsReference() )
 	if( ctx->type.dataType.IsObject() && !descr->returnType.IsReference() )
 	{
 	{
 		int returnOffset = 0;
 		int returnOffset = 0;
 
 
-#ifndef AS_OLD
-		if( descr->DoesReturnOnStack() )
+		if( useVariable )
 		{
 		{
-			asASSERT( useVariable );
-
-			// The variable was allocated before the function was called
+			// Use the given variable
 			returnOffset = varOffset;
 			returnOffset = varOffset;
-			ctx->type.SetVariable(descr->returnType, returnOffset, true);
-
-			// The variable was initialized by the function, so we need to mark it as initialized here
-			ctx->bc.ObjInfo(varOffset, asOBJ_INIT);
+			ctx->type.SetVariable(descr->returnType, returnOffset, false);
 		}
 		}
 		else
 		else
-#endif
 		{
 		{
-			if( useVariable )
-			{
-				// Use the given variable
-				returnOffset = varOffset;
-				ctx->type.SetVariable(descr->returnType, returnOffset, false);
-			}
-			else
-			{
-				// Allocate a temporary variable for the returned object
-				// The returned object will actually be allocated on the heap, so
-				// we must force the allocation of the variable to do the same
-				returnOffset = AllocateVariable(descr->returnType, true, true);
-				ctx->type.SetVariable(descr->returnType, returnOffset, true);
-			}
-
-			// Move the pointer from the object register to the temporary variable
-			ctx->bc.InstrSHORT(asBC_STOREOBJ, (short)returnOffset);
+			// Allocate a temporary variable for the returned object
+			// The returned object will actually be allocated on the heap, so
+			// we must force the allocation of the variable to do the same
+			returnOffset = AllocateVariable(descr->returnType, true, true);
+			ctx->type.SetVariable(descr->returnType, returnOffset, true);
 		}
 		}
 
 
-		ctx->type.dataType.MakeReference(IsVariableOnHeap(returnOffset));
+		ctx->type.dataType.MakeReference(true);
 		ctx->type.isLValue = false; // It is a reference, but not an lvalue
 		ctx->type.isLValue = false; // It is a reference, but not an lvalue
 
 
+		// Move the pointer from the object register to the temporary variable
+		ctx->bc.InstrSHORT(asBC_STOREOBJ, (short)returnOffset);
+
 		// Clean up arguments
 		// Clean up arguments
 		if( args )
 		if( args )
 			AfterFunctionCall(funcId, *args, ctx, false);
 			AfterFunctionCall(funcId, *args, ctx, false);

+ 2 - 2
ThirdParty/AngelScript/source/as_compiler.h

@@ -156,8 +156,8 @@ protected:
 
 
 	void CompileInitList(asCTypeInfo *var, asCScriptNode *node, asCByteCode *bc);
 	void CompileInitList(asCTypeInfo *var, asCScriptNode *node, asCByteCode *bc);
 
 
-	int  CallDefaultConstructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc, asCScriptNode *node, bool isGlobalVar = false, bool deferDest = false);
-	int  CallCopyConstructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc, asSExprContext *arg, asCScriptNode *node, bool isGlobalVar = false, bool derefDestination = false);
+	int  CallDefaultConstructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc, asCScriptNode *node, bool isGlobalVar = false);
+	int  CallCopyConstructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc, asSExprContext *arg, asCScriptNode *node, bool isGlobalVar = false);
 	void CallDestructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc);
 	void CallDestructor(asCDataType &type, int offset, bool isObjectOnHeap, asCByteCode *bc);
 	int  CompileArgumentList(asCScriptNode *node, asCArray<asSExprContext *> &args);
 	int  CompileArgumentList(asCScriptNode *node, asCArray<asSExprContext *> &args);
 	int  CompileDefaultArgs(asCScriptNode *node, asCArray<asSExprContext*> &args, asCScriptFunction *func);
 	int  CompileDefaultArgs(asCScriptNode *node, asCArray<asSExprContext*> &args, asCScriptFunction *func);

+ 0 - 6
ThirdParty/AngelScript/source/as_configgroup.cpp

@@ -46,10 +46,7 @@ BEGIN_AS_NAMESPACE
 asCConfigGroup::asCConfigGroup()
 asCConfigGroup::asCConfigGroup()
 {
 {
 	refCount = 0;
 	refCount = 0;
-#ifdef AS_DEPRECATED
-	// Deprecated since 2011-10-04
 	defaultAccess = true;
 	defaultAccess = true;
-#endif
 }
 }
 
 
 asCConfigGroup::~asCConfigGroup()
 asCConfigGroup::~asCConfigGroup()
@@ -210,8 +207,6 @@ void asCConfigGroup::ValidateNoUsage(asCScriptEngine *engine, asCObjectType *typ
 }
 }
 #endif
 #endif
 
 
-#ifdef AS_DEPRECATED
-// deprecated since 2011-10-04
 int asCConfigGroup::SetModuleAccess(const char *module, bool hasAccess)
 int asCConfigGroup::SetModuleAccess(const char *module, bool hasAccess)
 {
 {
 	if( module == asALL_MODULES )
 	if( module == asALL_MODULES )
@@ -245,6 +240,5 @@ bool asCConfigGroup::HasModuleAccess(const char *module)
 	
 	
 	return defaultAccess;
 	return defaultAccess;
 }
 }
-#endif
 
 
 END_AS_NAMESPACE
 END_AS_NAMESPACE

+ 1 - 10
ThirdParty/AngelScript/source/as_configgroup.h

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2010 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -44,10 +44,7 @@
 #include "as_string.h"
 #include "as_string.h"
 #include "as_array.h"
 #include "as_array.h"
 #include "as_objecttype.h"
 #include "as_objecttype.h"
-#ifdef AS_DEPRECATED
-// deprecated since 2011-10-04
 #include "as_map.h"
 #include "as_map.h"
-#endif
 
 
 BEGIN_AS_NAMESPACE
 BEGIN_AS_NAMESPACE
 
 
@@ -67,11 +64,8 @@ public:
 	bool HasLiveObjects();
 	bool HasLiveObjects();
 	void RemoveConfiguration(asCScriptEngine *engine, bool notUsed = false);
 	void RemoveConfiguration(asCScriptEngine *engine, bool notUsed = false);
 
 
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-04
 	int SetModuleAccess(const char *module, bool hasAccess);
 	int SetModuleAccess(const char *module, bool hasAccess);
 	bool HasModuleAccess(const char *module);
 	bool HasModuleAccess(const char *module);
-#endif
 
 
 #ifdef AS_DEBUG
 #ifdef AS_DEBUG
 	void ValidateNoUsage(asCScriptEngine *engine, asCObjectType *type);
 	void ValidateNoUsage(asCScriptEngine *engine, asCObjectType *type);
@@ -86,12 +80,9 @@ public:
 	asCArray<asCConfigGroup*>    referencedConfigGroups;
 	asCArray<asCConfigGroup*>    referencedConfigGroups;
 	asCArray<asCScriptFunction*> funcDefs;
 	asCArray<asCScriptFunction*> funcDefs;
 
 
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-04
 	// Module access
 	// Module access
 	bool defaultAccess;
 	bool defaultAccess;
 	asCMap<asCString, bool> moduleAccess;
 	asCMap<asCString, bool> moduleAccess;
-#endif
 };
 };
 
 
 END_AS_NAMESPACE
 END_AS_NAMESPACE

+ 27 - 150
ThirdParty/AngelScript/source/as_context.cpp

@@ -233,7 +233,6 @@ asIScriptEngine *asCContext::GetEngine() const
 	return engine;
 	return engine;
 }
 }
 
 
-// interface
 void *asCContext::SetUserData(void *data)
 void *asCContext::SetUserData(void *data)
 {
 {
 	void *oldData = userData;
 	void *oldData = userData;
@@ -241,31 +240,13 @@ void *asCContext::SetUserData(void *data)
 	return oldData;
 	return oldData;
 }
 }
 
 
-// interface
 void *asCContext::GetUserData() const
 void *asCContext::GetUserData() const
 {
 {
 	return userData;
 	return userData;
 }
 }
 
 
-// interface
-int asCContext::Prepare(int funcId)
+int asCContext::Prepare(int funcID)
 {
 {
-	if( funcId == -1 )
-	{
-		if( initialFunction == 0 )
-			return asNO_FUNCTION;
-
-		funcId = initialFunction->GetId();
-	}
-	return Prepare(engine->GetScriptFunction(funcId));
-}
-
-// interface
-int asCContext::Prepare(asIScriptFunction *func)
-{
-	if( func == 0 ) 
-		return asNO_FUNCTION;
-
 	if( status == asEXECUTION_ACTIVE || status == asEXECUTION_SUSPENDED )
 	if( status == asEXECUTION_ACTIVE || status == asEXECUTION_SUSPENDED )
 		return asCONTEXT_ACTIVE;
 		return asCONTEXT_ACTIVE;
 
 
@@ -276,9 +257,16 @@ int asCContext::Prepare(asIScriptFunction *func)
 	// Release the returned object (if any)
 	// Release the returned object (if any)
 	CleanReturnObject();
 	CleanReturnObject();
 
 
-	if( initialFunction && initialFunction == func )
+	if( funcID == -1 )
+	{
+		// Use the previously prepared function
+		if( initialFunction == 0 )
+			return asNO_FUNCTION;
+
+		currentFunction = initialFunction;
+	}
+	else if( initialFunction && initialFunction->id == funcID )
 	{
 	{
-		// If the same function is executed again, we can skip a lot of the setup 
 		currentFunction = initialFunction;
 		currentFunction = initialFunction;
 	}
 	}
 	else
 	else
@@ -289,27 +277,16 @@ int asCContext::Prepare(asIScriptFunction *func)
 		if( initialFunction )
 		if( initialFunction )
 			initialFunction->Release();
 			initialFunction->Release();
 
 
-		// We trust the application not to pass anything else but a asCScriptFunction
-		initialFunction = reinterpret_cast<asCScriptFunction *>(func);
+		initialFunction = engine->GetScriptFunction(funcID);
+		if( initialFunction == 0 )
+			return asNO_FUNCTION;
+
 		initialFunction->AddRef();
 		initialFunction->AddRef();
 		currentFunction = initialFunction;
 		currentFunction = initialFunction;
 
 
-		// TODO: optimize: GetSpaceNeededForArguments() should be precomputed
-		argumentsSize = currentFunction->GetSpaceNeededForArguments() + (currentFunction->objectType ? AS_PTR_SIZE : 0);
-
-#ifndef AS_OLD
-		// Reserve space for the arguments and return value
-		if( currentFunction->DoesReturnOnStack() )
-		{
-			returnValueSize = currentFunction->returnType.GetSizeInMemoryDWords();
-			argumentsSize += AS_PTR_SIZE;
-		}
-		else
-#endif
-			returnValueSize = 0;
-
 		// Determine the minimum stack size needed
 		// Determine the minimum stack size needed
-		int stackSize = argumentsSize + returnValueSize + currentFunction->stackNeeded + RESERVE_STACK;
+		// TODO: optimize: GetSpaceNeededForArguments() should be precomputed
+		int stackSize = currentFunction->GetSpaceNeededForArguments() + currentFunction->stackNeeded + RESERVE_STACK;
 
 
 		stackSize = stackSize > engine->initialContextStackSize ? stackSize : engine->initialContextStackSize;
 		stackSize = stackSize > engine->initialContextStackSize ? stackSize : engine->initialContextStackSize;
 
 
@@ -328,6 +305,12 @@ int asCContext::Prepare(asIScriptFunction *func)
 			asDWORD *stack = asNEWARRAY(asDWORD,stackBlockSize);
 			asDWORD *stack = asNEWARRAY(asDWORD,stackBlockSize);
 			stackBlocks.PushLast(stack);
 			stackBlocks.PushLast(stack);
 		}
 		}
+
+		// Reserve space for the arguments and return value
+		returnValueSize = currentFunction->GetSpaceNeededForReturnValue();
+
+		// TODO: optimize: GetSpaceNeededForArguments() should be precomputed
+		argumentsSize = currentFunction->GetSpaceNeededForArguments() + (currentFunction->objectType ? AS_PTR_SIZE : 0);
 	}
 	}
 
 
 	// Reset state
 	// Reset state
@@ -346,24 +329,12 @@ int asCContext::Prepare(asIScriptFunction *func)
 	status = asEXECUTION_PREPARED;
 	status = asEXECUTION_PREPARED;
 
 
 	// Reserve space for the arguments and return value
 	// Reserve space for the arguments and return value
-	regs.stackFramePointer = stackBlocks[0] + stackBlockSize - argumentsSize - returnValueSize;
+	regs.stackFramePointer = stackBlocks[0] + stackBlockSize - argumentsSize;
 	regs.stackPointer      = regs.stackFramePointer;
 	regs.stackPointer      = regs.stackFramePointer;
 
 
 	// Set arguments to 0
 	// Set arguments to 0
 	memset(regs.stackPointer, 0, 4*argumentsSize);
 	memset(regs.stackPointer, 0, 4*argumentsSize);
 
 
-#ifndef AS_OLD
-	if( returnValueSize )
-	{
-		// Set the address of the location where the return value should be put
-		asDWORD *ptr = regs.stackFramePointer;
-		if( currentFunction->objectType )
-			ptr += AS_PTR_SIZE;
-
-		*(void**)ptr = (void*)(stackBlocks[0] + stackBlockSize - returnValueSize);
-	}
-#endif
-
 	if( currentFunction->funcType == asFUNC_SCRIPT )
 	if( currentFunction->funcType == asFUNC_SCRIPT )
 	{
 	{
 		regs.programPointer = currentFunction->byteCode.AddressOf();
 		regs.programPointer = currentFunction->byteCode.AddressOf();
@@ -492,13 +463,7 @@ void *asCContext::GetReturnAddress()
 	if( dt->IsReference() )
 	if( dt->IsReference() )
 		return *(void**)&regs.valueRegister;
 		return *(void**)&regs.valueRegister;
 	else if( dt->IsObject() )
 	else if( dt->IsObject() )
-	{
-#ifndef AS_OLD
-		if( initialFunction->DoesReturnOnStack() )
-			return (void*)(stackBlocks[0] + stackBlockSize - returnValueSize);
-#endif		
 		return regs.objectRegister;
 		return regs.objectRegister;
-	}
 
 
 	return 0;
 	return 0;
 }
 }
@@ -514,13 +479,7 @@ void *asCContext::GetReturnObject()
 	if( dt->IsReference() )
 	if( dt->IsReference() )
 		return *(void**)(size_t)regs.valueRegister;
 		return *(void**)(size_t)regs.valueRegister;
 	else
 	else
-	{
-#ifndef AS_OLD
-		if( initialFunction->DoesReturnOnStack() )
-			return (void*)(stackBlocks[0] + stackBlockSize - returnValueSize);
-#endif
 		return regs.objectRegister;
 		return regs.objectRegister;
-	}
 }
 }
 
 
 void *asCContext::GetAddressOfReturnValue()
 void *asCContext::GetAddressOfReturnValue()
@@ -534,13 +493,7 @@ void *asCContext::GetAddressOfReturnValue()
 	{
 	{
 		// Need to dereference objects 
 		// Need to dereference objects 
 		if( !dt->IsObjectHandle() )
 		if( !dt->IsObjectHandle() )
-		{
-#ifndef AS_OLD
-			if( initialFunction->DoesReturnOnStack() )
-				return (void*)(stackBlocks[0] + stackBlockSize - returnValueSize);
-#endif
 			return *(void**)&regs.objectRegister;
 			return *(void**)&regs.objectRegister;
-		}
 		return &regs.objectRegister;
 		return &regs.objectRegister;
 	}
 	}
 
 
@@ -593,11 +546,6 @@ int asCContext::SetArgByte(asUINT arg, asBYTE value)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -636,11 +584,6 @@ int asCContext::SetArgWord(asUINT arg, asWORD value)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -679,11 +622,6 @@ int asCContext::SetArgDWord(asUINT arg, asDWORD value)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -722,11 +660,6 @@ int asCContext::SetArgQWord(asUINT arg, asQWORD value)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -765,11 +698,6 @@ int asCContext::SetArgFloat(asUINT arg, float value)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -808,11 +736,6 @@ int asCContext::SetArgDouble(asUINT arg, double value)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -845,11 +768,7 @@ int asCContext::SetArgAddress(asUINT arg, void *value)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
+
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -898,11 +817,6 @@ int asCContext::SetArgObject(asUINT arg, void *obj)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -928,11 +842,6 @@ void *asCContext::GetAddressOfArg(asUINT arg)
 	int offset = 0;
 	int offset = 0;
 	if( initialFunction->objectType )
 	if( initialFunction->objectType )
 		offset += AS_PTR_SIZE;
 		offset += AS_PTR_SIZE;
-#ifndef AS_OLD
-	// If function returns object by value an extra pointer is pushed on the stack
-	if( returnValueSize )
-		offset += AS_PTR_SIZE;
-#endif
 	for( asUINT n = 0; n < arg; n++ )
 	for( asUINT n = 0; n < arg; n++ )
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 		offset += initialFunction->parameterTypes[n].GetSizeOnStackDWords();
 
 
@@ -1278,11 +1187,11 @@ void asCContext::CallScriptFunction(asCScriptFunction *func)
 				stackBlocks.PushLast(stack);
 				stackBlocks.PushLast(stack);
 			}
 			}
 
 
-			regs.stackPointer = stackBlocks[stackIndex] + (stackBlockSize<<stackIndex) - func->GetSpaceNeededForArguments() - (func->objectType ? AS_PTR_SIZE : 0) - (func->DoesReturnOnStack() ? AS_PTR_SIZE : 0);
+			regs.stackPointer = stackBlocks[stackIndex] + (stackBlockSize<<stackIndex) - func->GetSpaceNeededForArguments() - (func->objectType ? AS_PTR_SIZE : 0);
 		} 
 		} 
 
 
 		// Copy the function arguments to the new stack space
 		// Copy the function arguments to the new stack space
-		int numDwords = func->GetSpaceNeededForArguments() + (func->objectType ? AS_PTR_SIZE : 0) + (func->DoesReturnOnStack() ? AS_PTR_SIZE : 0);
+		int numDwords = func->GetSpaceNeededForArguments() + (func->objectType ? AS_PTR_SIZE : 0);
 		memcpy(regs.stackPointer, oldStackPointer, sizeof(asDWORD)*numDwords);
 		memcpy(regs.stackPointer, oldStackPointer, sizeof(asDWORD)*numDwords);
 	}
 	}
 
 
@@ -3539,17 +3448,6 @@ void asCContext::SetInternalException(const char *descr)
 
 
 void asCContext::CleanReturnObject()
 void asCContext::CleanReturnObject()
 {
 {
-#ifndef AS_OLD
-	if( initialFunction && initialFunction->DoesReturnOnStack() && status == asEXECUTION_FINISHED )
-	{
-		// If function returns on stack we need to call the destructor on the returned object
-		if( initialFunction->returnType.GetObjectType()->beh.destruct )
-			engine->CallObjectMethod((void*)(stackBlocks[0] + stackBlockSize - returnValueSize), initialFunction->returnType.GetObjectType()->beh.destruct);
-
-		return;
-	}
-#endif
-
 	if( regs.objectRegister == 0 ) return;
 	if( regs.objectRegister == 0 ) return;
 
 
 	asASSERT( regs.objectType != 0 );
 	asASSERT( regs.objectType != 0 );
@@ -3667,25 +3565,13 @@ void asCContext::DetermineLiveObjects(asCArray<int> &liveObjects, asUINT stackLe
 		pos = asUINT((asDWORD*)s[2] - func->byteCode.AddressOf());
 		pos = asUINT((asDWORD*)s[2] - func->byteCode.AddressOf());
 	}
 	}
 
 
-	if( status == asEXECUTION_EXCEPTION )
-	{
-		// Don't consider the last instruction as executed, as it failed with an exception
-		// It's not actually necessary to decrease the exact size of the instruction. Just 
-		// before the current position is enough to disconsider it.
-		pos--;
-	}
-
 
 
 	// Determine which object variables that are really live ones
 	// Determine which object variables that are really live ones
 	liveObjects.SetLength(func->objVariablePos.GetLength());
 	liveObjects.SetLength(func->objVariablePos.GetLength());
 	memset(liveObjects.AddressOf(), 0, sizeof(int)*liveObjects.GetLength());
 	memset(liveObjects.AddressOf(), 0, sizeof(int)*liveObjects.GetLength());
 	for( int n = 0; n < (int)func->objVariableInfo.GetLength(); n++ )
 	for( int n = 0; n < (int)func->objVariableInfo.GetLength(); n++ )
 	{
 	{
-		// Find the first variable info with a larger position than the current
-		// As the variable info are always placed on the instruction right after the 
-		// one that initialized or freed the object, the current position needs to be 
-		// considered as valid.
-		if( func->objVariableInfo[n].programPos > pos )
+		if( func->objVariableInfo[n].programPos >= pos )
 		{
 		{
 			// We've determined how far the execution ran, now determine which variables are alive
 			// We've determined how far the execution ran, now determine which variables are alive
 			for( --n; n >= 0; n-- )
 			for( --n; n >= 0; n-- )
@@ -4008,15 +3894,6 @@ int asCContext::CallGeneric(int id, void *objectPointer)
 		}
 		}
 	}
 	}
 
 
-#ifndef AS_OLD
-	if( sysFunction->DoesReturnOnStack() )
-	{
-		// Skip the address where the return value will be stored
-		args += AS_PTR_SIZE;
-		popSize += AS_PTR_SIZE;
-	}
-#endif
-
 	asCGeneric gen(engine, sysFunction, currentObject, args);
 	asCGeneric gen(engine, sysFunction, currentObject, args);
 
 
 	isCallingSystemFunction = true;
 	isCallingSystemFunction = true;

+ 3 - 3
ThirdParty/AngelScript/source/as_context.h

@@ -51,6 +51,8 @@ BEGIN_AS_NAMESPACE
 class asCScriptFunction;
 class asCScriptFunction;
 class asCScriptEngine;
 class asCScriptEngine;
 
 
+// TODO: The context should be renamed to something that better describes it, e.g. asIVirtualMachine, asIExecuter, asIProcessor, asIScriptThread, or something like that
+
 class asCContext : public asIScriptContext
 class asCContext : public asIScriptContext
 {
 {
 public:
 public:
@@ -62,9 +64,7 @@ public:
 
 
 	asEContextState GetState() const;
 	asEContextState GetState() const;
 
 
-	int  Prepare(asIScriptFunction *func);
-	// TODO: interface: deprecate this
-	int  Prepare(int functionId);
+	int  Prepare(int functionID);
 	int  Unprepare();
 	int  Unprepare();
 
 
 	int SetArgByte(asUINT arg, asBYTE value);
 	int SetArgByte(asUINT arg, asBYTE value);

+ 0 - 1
ThirdParty/AngelScript/source/as_criticalsection.h

@@ -93,7 +93,6 @@ BEGIN_AS_NAMESPACE
 
 
 // Undefine macros that cause problems in our code
 // Undefine macros that cause problems in our code
 #undef GetObject
 #undef GetObject
-#undef RegisterClass
 
 
 class asCThreadCriticalSection
 class asCThreadCriticalSection
 {
 {

+ 2 - 36
ThirdParty/AngelScript/source/as_gc.cpp

@@ -41,7 +41,6 @@
 #include "as_gc.h"
 #include "as_gc.h"
 #include "as_scriptengine.h"
 #include "as_scriptengine.h"
 #include "as_scriptobject.h"
 #include "as_scriptobject.h"
-#include "as_texts.h"
 
 
 BEGIN_AS_NAMESPACE
 BEGIN_AS_NAMESPACE
 
 
@@ -366,18 +365,6 @@ int asCGarbageCollector::DestroyNewGarbage()
 	UNREACHABLE_RETURN;
 	UNREACHABLE_RETURN;
 }
 }
 
 
-void asCGarbageCollector::ReportUndestroyedObjects()
-{
-	for( asUINT n = 0; n < gcOldObjects.GetLength(); n++ )
-	{
-		asSObjTypePair gcObj = GetOldObjectAtIdx(n);
-
-		asCString msg;
-		msg.Format(TXT_GC_CANNOT_FREE_OBJ_OF_TYPE_s, gcObj.type->name.AddressOf());
-		engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, msg.AddressOf());
-	}
-}
-
 int asCGarbageCollector::DestroyOldGarbage()
 int asCGarbageCollector::DestroyOldGarbage()
 {
 {
 	for(;;)
 	for(;;)
@@ -408,24 +395,7 @@ int asCGarbageCollector::DestroyOldGarbage()
 			if( ++destroyOldIdx < gcOldObjects.GetLength() )
 			if( ++destroyOldIdx < gcOldObjects.GetLength() )
 			{
 			{
 				asSObjTypePair gcObj = GetOldObjectAtIdx(destroyOldIdx);
 				asSObjTypePair gcObj = GetOldObjectAtIdx(destroyOldIdx);
-
-				if( gcObj.type->beh.gcGetRefCount == 0 )
-				{
-					// If circular references are formed with registered types that hasn't 
-					// registered the GC behaviours, then the engine may be forced to free
-					// the object type before the actual object instance. In this case we
-					// will be forced to skip the destruction of the objects, so as not to 
-					// crash the application.
-					asCString msg;
-					msg.Format(TXT_GC_CANNOT_FREE_OBJ_OF_TYPE_s, gcObj.type->name.AddressOf());
-					engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, msg.AddressOf());
-
-					// Just remove the object, as we will not bother to destroy it
-					numDestroyed++;
-					RemoveOldObjectAtIdx(destroyOldIdx);
-					destroyOldIdx--;
-				}
-				else if( engine->CallObjectMethodRetInt(gcObj.obj, gcObj.type->beh.gcGetRefCount) == 1 )
+				if( engine->CallObjectMethodRetInt(gcObj.obj, gcObj.type->beh.gcGetRefCount) == 1 )
 				{
 				{
 					// Release the object immediately
 					// Release the object immediately
 
 
@@ -540,11 +510,7 @@ int asCGarbageCollector::IdentifyGarbageWithCyclicRefs()
 			{
 			{
 				// Add the gc count for this object
 				// Add the gc count for this object
 				asSObjTypePair gcObj = GetOldObjectAtIdx(detectIdx);
 				asSObjTypePair gcObj = GetOldObjectAtIdx(detectIdx);
-	
-				int refCount = 0;
-				if( gcObj.type->beh.gcGetRefCount )
-					refCount = engine->CallObjectMethodRetInt(gcObj.obj, gcObj.type->beh.gcGetRefCount);
-
+				int refCount = engine->CallObjectMethodRetInt(gcObj.obj, gcObj.type->beh.gcGetRefCount);
 				if( refCount > 1 )
 				if( refCount > 1 )
 				{
 				{
 					asSIntTypePair it = {refCount-1, gcObj.type};
 					asSIntTypePair it = {refCount-1, gcObj.type};

+ 0 - 2
ThirdParty/AngelScript/source/as_gc.h

@@ -60,8 +60,6 @@ public:
 	void GCEnumCallback(void *reference);
 	void GCEnumCallback(void *reference);
 	void AddScriptObjectToGC(void *obj, asCObjectType *objType);
 	void AddScriptObjectToGC(void *obj, asCObjectType *objType);
 
 
-	void ReportUndestroyedObjects();
-
 	asCScriptEngine *engine;
 	asCScriptEngine *engine;
 
 
 protected:
 protected:

+ 1 - 34
ThirdParty/AngelScript/source/as_generic.cpp

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2010 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -74,20 +74,11 @@ int asCGeneric::GetFunctionId() const
 	return sysFunction->id;
 	return sysFunction->id;
 }
 }
 
 
-#ifdef AS_DEPRECATED
-// deprecated since 2011-10-03
 // interface
 // interface
 asIScriptFunction *asCGeneric::GetFunctionDescriptor() const
 asIScriptFunction *asCGeneric::GetFunctionDescriptor() const
 {
 {
 	return sysFunction;
 	return sysFunction;
 }
 }
-#endif
-
-// interface
-asIScriptFunction *asCGeneric::GetFunction() const
-{
-	return sysFunction;
-}
 
 
 // interface
 // interface
 void *asCGeneric::GetFunctionUserData() const
 void *asCGeneric::GetFunctionUserData() const
@@ -474,16 +465,7 @@ int asCGeneric::SetReturnObject(void *obj)
 	}
 	}
 	else
 	else
 	{
 	{
-#ifndef AS_OLD
-		// If function returns object by value the memory is already allocated.
-		// Here we should just initialize that memory by calling the copy constructor
-		// or the default constructor followed by the assignment operator
-		void *mem = (void*)*(size_t*)&stackPointer[-AS_PTR_SIZE];
-		engine->ConstructScriptObjectCopy(mem, obj, dt->GetObjectType());
-		return 0;
-#else
 		obj = engine->CreateScriptObjectCopy(obj, engine->GetTypeIdFromDataType(*dt));
 		obj = engine->CreateScriptObjectCopy(obj, engine->GetTypeIdFromDataType(*dt));
-#endif
 	}
 	}
 
 
 	objectRegister = obj;
 	objectRegister = obj;
@@ -497,13 +479,7 @@ void *asCGeneric::GetReturnPointer()
 	asCDataType &dt = sysFunction->returnType;
 	asCDataType &dt = sysFunction->returnType;
 
 
 	if( dt.IsObject() && !dt.IsReference() )
 	if( dt.IsObject() && !dt.IsReference() )
-	{
-		// This function doesn't support returning on the stack but the use of 
-		// the function doesn't require it so we don't need to implement it here.
-		asASSERT( !sysFunction->DoesReturnOnStack() );
-
 		return &objectRegister;
 		return &objectRegister;
-	}
 
 
 	return &returnVal;
 	return &returnVal;
 }
 }
@@ -515,14 +491,6 @@ void *asCGeneric::GetAddressOfReturnLocation()
 
 
 	if( dt.IsObject() && !dt.IsReference() )
 	if( dt.IsObject() && !dt.IsReference() )
 	{
 	{
-#ifndef AS_OLD
-		if( sysFunction->DoesReturnOnStack() )
-		{
-			// The memory is already preallocated on the stack,
-			// and the pointer to the location is found before the first arg
-			return (void*)*(size_t*)&stackPointer[-AS_PTR_SIZE];
-		}
-#else
 		if( dt.GetObjectType()->flags & asOBJ_VALUE )
 		if( dt.GetObjectType()->flags & asOBJ_VALUE )
 		{
 		{
 			// Allocate the necessary memory for this object, 
 			// Allocate the necessary memory for this object, 
@@ -533,7 +501,6 @@ void *asCGeneric::GetAddressOfReturnLocation()
 
 
 			return objectRegister;
 			return objectRegister;
 		}
 		}
-#endif
 
 
 		// Reference types store the handle in the objectReference
 		// Reference types store the handle in the objectReference
 		return &objectRegister;
 		return &objectRegister;

+ 1 - 5
ThirdParty/AngelScript/source/as_generic.h

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2010 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -55,11 +55,7 @@ public:
 	// Miscellaneous
 	// Miscellaneous
 	asIScriptEngine   *GetEngine() const;
 	asIScriptEngine   *GetEngine() const;
 	int                GetFunctionId() const;
 	int                GetFunctionId() const;
-	asIScriptFunction *GetFunction() const;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-03
 	asIScriptFunction *GetFunctionDescriptor() const;
 	asIScriptFunction *GetFunctionDescriptor() const;
-#endif
 	void              *GetFunctionUserData() const;
 	void              *GetFunctionUserData() const;
 
 
 	// Object
 	// Object

+ 1 - 2
ThirdParty/AngelScript/source/as_globalproperty.cpp

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2010 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -43,7 +43,6 @@ asCGlobalProperty::asCGlobalProperty()
 	memoryAllocated = false; 
 	memoryAllocated = false; 
 	realAddress = 0; 
 	realAddress = 0; 
 	initFunc = 0;
 	initFunc = 0;
-	accessMask = 0xFFFFFFFF;
 
 
 	refCount.set(1);
 	refCount.set(1);
 }
 }

+ 3 - 3
ThirdParty/AngelScript/source/as_map.h

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2007 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -324,14 +324,14 @@ bool asCMap<KEY, VAL>::MoveTo(asSMapNode<KEY,VAL> **out, const KEY &key)
 			p = p->left;
 			p = p->left;
 		else if( key == p->key )
 		else if( key == p->key )
 		{
 		{
-			if( out ) *out = p;
+			*out = p;
 			return true;
 			return true;
 		}
 		}
 		else 
 		else 
 			p = p->right;
 			p = p->right;
 	}
 	}
 
 
-	if( out ) *out = 0;
+	*out = 0;
 	return false;
 	return false;
 }
 }
 
 

+ 4 - 66
ThirdParty/AngelScript/source/as_module.cpp

@@ -28,7 +28,7 @@
    [email protected]
    [email protected]
 */
 */
 
 
-// Modified by Lasse Öörni for Urho3D
+
 
 
 //
 //
 // as_module.cpp
 // as_module.cpp
@@ -50,11 +50,8 @@ asCModule::asCModule(const char *name, asCScriptEngine *engine)
 	this->name     = name;
 	this->name     = name;
 	this->engine   = engine;
 	this->engine   = engine;
 
 
-	userData = 0;
 	builder = 0;
 	builder = 0;
 	isGlobalVarInitialized = false;
 	isGlobalVarInitialized = false;
-
-	accessMask = 1;
 }
 }
 
 
 // internal
 // internal
@@ -68,10 +65,6 @@ asCModule::~asCModule()
 		builder = 0;
 		builder = 0;
 	}
 	}
 
 
-	// Clean the user data
-	if( userData && engine->cleanModuleFunc )
-		engine->cleanModuleFunc(this);
-
 	// Remove the module from the engine
 	// Remove the module from the engine
 	if( engine )
 	if( engine )
 	{
 	{
@@ -82,20 +75,6 @@ asCModule::~asCModule()
 	}
 	}
 }
 }
 
 
-// interface
-void *asCModule::SetUserData(void *data)
-{
-	void *oldData = userData;
-	userData = data;
-	return oldData;
-}
-
-// interface
-void *asCModule::GetUserData() const
-{
-	return userData;
-}
-
 // interface
 // interface
 asIScriptEngine *asCModule::GetEngine() const
 asIScriptEngine *asCModule::GetEngine() const
 {
 {
@@ -201,15 +180,6 @@ int asCModule::GetFunctionIdByIndex(asUINT index) const
 	return globalFunctions[index]->id;
 	return globalFunctions[index]->id;
 }
 }
 
 
-// interface
-asIScriptFunction *asCModule::GetFunctionByIndex(asUINT index) const
-{
-	if( index >= globalFunctions.GetLength() )
-		return 0;
-
-	return globalFunctions[index];
-}
-
 // internal
 // internal
 int asCModule::CallInit(asIScriptContext *myCtx)
 int asCModule::CallInit(asIScriptContext *myCtx)
 {
 {
@@ -259,7 +229,7 @@ int asCModule::CallInit(asIScriptContext *myCtx)
 					if( r == asEXECUTION_EXCEPTION )
 					if( r == asEXECUTION_EXCEPTION )
 					{
 					{
 						int funcId = ctx->GetExceptionFunction();
 						int funcId = ctx->GetExceptionFunction();
-						const asIScriptFunction *function = engine->GetFunctionById(funcId);
+						const asIScriptFunction *function = engine->GetFunctionDescriptorById(funcId);
 
 
 						msg.Format(TXT_EXCEPTION_s_IN_s, ctx->GetExceptionString(), function->GetDeclaration());
 						msg.Format(TXT_EXCEPTION_s_IN_s, ctx->GetExceptionString(), function->GetDeclaration());
 
 
@@ -414,17 +384,6 @@ int asCModule::GetFunctionIdByName(const char *name) const
 	return id;
 	return id;
 }
 }
 
 
-// interface
-asIScriptFunction *asCModule::GetFunctionByName(const char *name) const
-{
-	int id = GetFunctionIdByName(name);
-	if( id < 0 )
-		return 0;
-
-	// Urho3D: fix index / id mixup
-	return engine->GetFunctionById(id);
-}
-
 // interface
 // interface
 asUINT asCModule::GetImportedFunctionCount() const
 asUINT asCModule::GetImportedFunctionCount() const
 {
 {
@@ -524,16 +483,6 @@ int asCModule::GetFunctionIdByDecl(const char *decl) const
 	return id;
 	return id;
 }
 }
 
 
-// interface
-asIScriptFunction *asCModule::GetFunctionByDecl(const char *decl) const
-{
-	int id = GetFunctionIdByDecl(decl);
-	if( id < 0 ) return 0;
-	
-	// Urho3D: fixed index / id mixup
-	return engine->GetFunctionById(id);
-}
-
 // interface
 // interface
 asUINT asCModule::GetGlobalVarCount() const
 asUINT asCModule::GetGlobalVarCount() const
 {
 {
@@ -571,8 +520,6 @@ int asCModule::RemoveGlobalVar(asUINT index)
 	return 0;
 	return 0;
 }
 }
 
 
-#ifdef AS_DEPRECATED
-// deprecated since 2011-10-03
 // interface
 // interface
 asIScriptFunction *asCModule::GetFunctionDescriptorByIndex(asUINT index) const
 asIScriptFunction *asCModule::GetFunctionDescriptorByIndex(asUINT index) const
 {
 {
@@ -587,7 +534,6 @@ asIScriptFunction *asCModule::GetFunctionDescriptorById(int funcId) const
 {
 {
 	return engine->GetFunctionDescriptorById(funcId);
 	return engine->GetFunctionDescriptorById(funcId);
 }
 }
-#endif
 
 
 // interface
 // interface
 int asCModule::GetGlobalVarIndexByDecl(const char *decl) const
 int asCModule::GetGlobalVarIndexByDecl(const char *decl) const
@@ -1209,8 +1155,8 @@ bool asCModule::AreInterfacesEqual(asCObjectType *a, asCObjectType *b, asCArray<
 	{
 	{
 		match = false;
 		match = false;
 
 
-		asCScriptFunction *funcA = (asCScriptFunction*)engine->GetFunctionById(a->methods[n]);
-		asCScriptFunction *funcB = (asCScriptFunction*)engine->GetFunctionById(b->methods[n]);
+		asCScriptFunction *funcA = (asCScriptFunction*)engine->GetFunctionDescriptorById(a->methods[n]);
+		asCScriptFunction *funcB = (asCScriptFunction*)engine->GetFunctionDescriptorById(b->methods[n]);
 
 
 		// funcB can be null if the module that created the interface has been  
 		// funcB can be null if the module that created the interface has been  
 		// discarded but the type has not yet been released by the engine.
 		// discarded but the type has not yet been released by the engine.
@@ -1474,13 +1420,5 @@ int asCModule::AddFuncDef(const char *name)
 	return (int)funcDefs.GetLength()-1;
 	return (int)funcDefs.GetLength()-1;
 }
 }
 
 
-// interface
-asDWORD asCModule::SetAccessMask(asDWORD mask)
-{
-	asDWORD old = accessMask;
-	accessMask = mask;
-	return old;
-}
-
 END_AS_NAMESPACE
 END_AS_NAMESPACE
 
 

+ 7 - 17
ThirdParty/AngelScript/source/as_module.h

@@ -87,6 +87,9 @@ struct sObjectTypePair
 //       then it should simply replace the bytecode within the functions without
 //       then it should simply replace the bytecode within the functions without
 //       changing the values of existing global properties, etc.
 //       changing the values of existing global properties, etc.
 
 
+// TODO: interface: Should have user data in the modules as well. This may be 
+//                  used to store extra information, such as meta-data and source code files
+
 class asCModule : public asIScriptModule
 class asCModule : public asIScriptModule
 {
 {
 //-------------------------------------------
 //-------------------------------------------
@@ -98,25 +101,18 @@ public:
 	virtual const char      *GetName() const;
 	virtual const char      *GetName() const;
 
 
 	// Compilation
 	// Compilation
-	virtual int     AddScriptSection(const char *name, const char *code, size_t codeLength, int lineOffset);
-	virtual int     Build();
-	virtual int     CompileFunction(const char *sectionName, const char *code, int lineOffset, asDWORD reserved, asIScriptFunction **outFunc);
-	virtual int     CompileGlobalVar(const char *sectionName, const char *code, int lineOffset);
-	virtual asDWORD SetAccessMask(asDWORD accessMask);
+	virtual int  AddScriptSection(const char *name, const char *code, size_t codeLength, int lineOffset);
+	virtual int  Build();
+	virtual int  CompileFunction(const char *sectionName, const char *code, int lineOffset, asDWORD reserved, asIScriptFunction **outFunc);
+	virtual int  CompileGlobalVar(const char *sectionName, const char *code, int lineOffset);
 
 
 	// Script functions
 	// Script functions
 	virtual asUINT             GetFunctionCount() const;
 	virtual asUINT             GetFunctionCount() const;
 	virtual int                GetFunctionIdByIndex(asUINT index) const;
 	virtual int                GetFunctionIdByIndex(asUINT index) const;
 	virtual int                GetFunctionIdByName(const char *name) const;
 	virtual int                GetFunctionIdByName(const char *name) const;
 	virtual int                GetFunctionIdByDecl(const char *decl) const;
 	virtual int                GetFunctionIdByDecl(const char *decl) const;
-	virtual asIScriptFunction *GetFunctionByIndex(asUINT index) const;
-	virtual asIScriptFunction *GetFunctionByDecl(const char *decl) const;
-	virtual asIScriptFunction *GetFunctionByName(const char *name) const;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-03
 	virtual asIScriptFunction *GetFunctionDescriptorByIndex(asUINT index) const;
 	virtual asIScriptFunction *GetFunctionDescriptorByIndex(asUINT index) const;
 	virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) const;
 	virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) const;
-#endif
 	virtual int                RemoveFunction(int funcId);
 	virtual int                RemoveFunction(int funcId);
 
 
 	// Script global variables
 	// Script global variables
@@ -158,10 +154,6 @@ public:
 	virtual int SaveByteCode(asIBinaryStream *out) const;
 	virtual int SaveByteCode(asIBinaryStream *out) const;
 	virtual int LoadByteCode(asIBinaryStream *in);
 	virtual int LoadByteCode(asIBinaryStream *in);
 
 
-	// User data
-	virtual void *SetUserData(void *data);
-	virtual void *GetUserData() const;
-
 //-----------------------------------------------
 //-----------------------------------------------
 // Internal
 // Internal
 //-----------------------------------------------
 //-----------------------------------------------
@@ -204,8 +196,6 @@ public:
 
 
 	asCScriptEngine *engine;
 	asCScriptEngine *engine;
 	asCBuilder      *builder;
 	asCBuilder      *builder;
-	void            *userData;
-	asDWORD          accessMask;
 
 
 	// This array holds all functions, class members, factories, etc that were compiled with the module
 	// This array holds all functions, class members, factories, etc that were compiled with the module
 	asCArray<asCScriptFunction *>  scriptFunctions;
 	asCArray<asCScriptFunction *>  scriptFunctions;

+ 26 - 103
ThirdParty/AngelScript/source/as_objecttype.cpp

@@ -127,11 +127,7 @@ asCObjectType::asCObjectType()
 	derivedFrom = 0;
 	derivedFrom = 0;
 
 
 	acceptValueSubType = true;
 	acceptValueSubType = true;
-	acceptRefSubType   = true;
-
-	accessMask = 0xFFFFFFFF;
-
-	userData = 0;
+	acceptRefSubType = true;
 }
 }
 
 
 asCObjectType::asCObjectType(asCScriptEngine *engine) 
 asCObjectType::asCObjectType(asCScriptEngine *engine) 
@@ -142,10 +138,6 @@ asCObjectType::asCObjectType(asCScriptEngine *engine)
 
 
 	acceptValueSubType = true;
 	acceptValueSubType = true;
 	acceptRefSubType = true;
 	acceptRefSubType = true;
-
-	accessMask = 0xFFFFFFFF;
-
-	userData = 0;
 }
 }
 
 
 int asCObjectType::AddRef() const
 int asCObjectType::AddRef() const
@@ -160,18 +152,6 @@ int asCObjectType::Release() const
 	return refCount.atomicDec();
 	return refCount.atomicDec();
 }
 }
 
 
-void *asCObjectType::SetUserData(void *data)
-{
-	void *oldData = userData;
-	userData = data;
-	return oldData;
-}
-
-void *asCObjectType::GetUserData() const
-{
-	return userData;
-}
-
 int asCObjectType::GetRefCount()
 int asCObjectType::GetRefCount()
 {
 {
 	return refCount.get();
 	return refCount.get();
@@ -221,10 +201,6 @@ asCObjectType::~asCObjectType()
 	}
 	}
 
 
 	enumValues.SetLength(0);
 	enumValues.SetLength(0);
-
-	// Clean the user data
-	if( userData && engine->cleanObjectTypeFunc )
-		engine->cleanObjectTypeFunc(this);
 }
 }
 
 
 bool asCObjectType::Implements(const asCObjectType *objType) const
 bool asCObjectType::Implements(const asCObjectType *objType) const
@@ -255,15 +231,6 @@ bool asCObjectType::DerivesFrom(const asCObjectType *objType) const
 	return false;
 	return false;
 }
 }
 
 
-bool asCObjectType::IsShared() const
-{
-	// Objects that can be declared by scripts need to have the explicit flag asOBJ_SHARED
-	if( flags & (asOBJ_SCRIPT_OBJECT|asOBJ_ENUM) ) return flags & asOBJ_SHARED ? true : false;
-
-	// Otherwise we assume the object to be shared
-	return true;
-}
-
 // interface
 // interface
 const char *asCObjectType::GetName() const
 const char *asCObjectType::GetName() const
 {
 {
@@ -331,13 +298,11 @@ asIScriptEngine *asCObjectType::GetEngine() const
 	return engine;
 	return engine;
 }
 }
 
 
-// interface
 asUINT asCObjectType::GetFactoryCount() const
 asUINT asCObjectType::GetFactoryCount() const
 {
 {
 	return (asUINT)beh.factories.GetLength();
 	return (asUINT)beh.factories.GetLength();
 }
 }
 
 
-// interface
 int asCObjectType::GetFactoryIdByIndex(asUINT index) const
 int asCObjectType::GetFactoryIdByIndex(asUINT index) const
 {
 {
 	if( index >= beh.factories.GetLength() )
 	if( index >= beh.factories.GetLength() )
@@ -346,16 +311,6 @@ int asCObjectType::GetFactoryIdByIndex(asUINT index) const
 	return beh.factories[index];
 	return beh.factories[index];
 }
 }
 
 
-// interface
-asIScriptFunction *asCObjectType::GetFactoryByIndex(asUINT index) const
-{
-	if( index >= beh.factories.GetLength() )
-		return 0;
-
-	return engine->GetFunctionById(beh.factories[index]);
-}
-
-// interface
 int asCObjectType::GetFactoryIdByDecl(const char *decl) const
 int asCObjectType::GetFactoryIdByDecl(const char *decl) const
 {
 {
 	if( beh.factories.GetLength() == 0 )
 	if( beh.factories.GetLength() == 0 )
@@ -365,16 +320,6 @@ int asCObjectType::GetFactoryIdByDecl(const char *decl) const
 	return engine->GetFactoryIdByDecl(this, decl);
 	return engine->GetFactoryIdByDecl(this, decl);
 }
 }
 
 
-// interface
-asIScriptFunction *asCObjectType::GetFactoryByDecl(const char *decl) const
-{
-	if( beh.factories.GetLength() == 0 )
-		return 0;
-
-	// Let the engine parse the string and find the appropriate factory function
-	return engine->GetFunctionById(engine->GetFactoryIdByDecl(this, decl));
-}
-
 // interface
 // interface
 asUINT asCObjectType::GetMethodCount() const
 asUINT asCObjectType::GetMethodCount() const
 {
 {
@@ -397,12 +342,6 @@ int asCObjectType::GetMethodIdByIndex(asUINT index, bool getVirtual) const
 	return methods[index];
 	return methods[index];
 }
 }
 
 
-// interface
-asIScriptFunction *asCObjectType::GetMethodByIndex(asUINT index, bool getVirtual) const
-{
-	return engine->GetFunctionById(GetMethodIdByIndex(index, getVirtual));
-}
-
 // interface
 // interface
 int asCObjectType::GetMethodIdByName(const char *name, bool getVirtual) const
 int asCObjectType::GetMethodIdByName(const char *name, bool getVirtual) const
 {
 {
@@ -430,12 +369,6 @@ int asCObjectType::GetMethodIdByName(const char *name, bool getVirtual) const
 	return id;
 	return id;
 }
 }
 
 
-// interface
-asIScriptFunction *asCObjectType::GetMethodByName(const char *name, bool getVirtual) const
-{
-	return engine->GetFunctionById(GetMethodIdByName(name, getVirtual));
-}
-
 // interface
 // interface
 int asCObjectType::GetMethodIdByDecl(const char *decl, bool getVirtual) const
 int asCObjectType::GetMethodIdByDecl(const char *decl, bool getVirtual) const
 {
 {
@@ -463,14 +396,6 @@ int asCObjectType::GetMethodIdByDecl(const char *decl, bool getVirtual) const
 	return id;
 	return id;
 }
 }
 
 
-// interface
-asIScriptFunction *asCObjectType::GetMethodByDecl(const char *decl, bool getVirtual) const
-{
-	return engine->GetFunctionById(GetMethodIdByDecl(decl, getVirtual));
-}
-
-#ifdef AS_DEPRECATED
-// deprecated since 2011-10-03
 // interface
 // interface
 asIScriptFunction *asCObjectType::GetMethodDescriptorByIndex(asUINT index, bool getVirtual) const
 asIScriptFunction *asCObjectType::GetMethodDescriptorByIndex(asUINT index, bool getVirtual) const
 {
 {
@@ -486,7 +411,6 @@ asIScriptFunction *asCObjectType::GetMethodDescriptorByIndex(asUINT index, bool
 
 
 	return engine->scriptFunctions[methods[index]];
 	return engine->scriptFunctions[methods[index]];
 }
 }
-#endif
 
 
 // interface
 // interface
 asUINT asCObjectType::GetPropertyCount() const
 asUINT asCObjectType::GetPropertyCount() const
@@ -735,32 +659,6 @@ void asCObjectType::ReleaseAllFunctions()
 		engine->scriptFunctions[beh.destruct]->Release();
 		engine->scriptFunctions[beh.destruct]->Release();
 	beh.destruct  = 0;
 	beh.destruct  = 0;
 
 
-	if( beh.copy )
-		engine->scriptFunctions[beh.copy]->Release();
-	beh.copy = 0;
-
-	for( asUINT e = 1; e < beh.operators.GetLength(); e += 2 )
-	{
-		if( engine->scriptFunctions[beh.operators[e]] )
-			engine->scriptFunctions[beh.operators[e]]->Release();
-	}
-	beh.operators.SetLength(0);
-
-	for( asUINT c = 0; c < methods.GetLength(); c++ )
-	{
-		if( engine->scriptFunctions[methods[c]] ) 
-			engine->scriptFunctions[methods[c]]->Release();
-	}
-	methods.SetLength(0);
-
-	for( asUINT d = 0; d < virtualFunctionTable.GetLength(); d++ )
-	{
-		if( virtualFunctionTable[d] )
-			virtualFunctionTable[d]->Release();
-	}
-	virtualFunctionTable.SetLength(0);
-
-	// GC behaviours
 	if( beh.addref )
 	if( beh.addref )
 		engine->scriptFunctions[beh.addref]->Release();
 		engine->scriptFunctions[beh.addref]->Release();
 	beh.addref = 0;
 	beh.addref = 0;
@@ -769,6 +667,10 @@ void asCObjectType::ReleaseAllFunctions()
 		engine->scriptFunctions[beh.release]->Release();
 		engine->scriptFunctions[beh.release]->Release();
 	beh.release = 0;
 	beh.release = 0;
 
 
+	if( beh.copy )
+		engine->scriptFunctions[beh.copy]->Release();
+	beh.copy = 0;
+
 	if( beh.gcEnumReferences )
 	if( beh.gcEnumReferences )
 		engine->scriptFunctions[beh.gcEnumReferences]->Release();
 		engine->scriptFunctions[beh.gcEnumReferences]->Release();
 	beh.gcEnumReferences = 0;
 	beh.gcEnumReferences = 0;
@@ -788,6 +690,27 @@ void asCObjectType::ReleaseAllFunctions()
 	if( beh.gcSetFlag )
 	if( beh.gcSetFlag )
 		engine->scriptFunctions[beh.gcSetFlag]->Release();
 		engine->scriptFunctions[beh.gcSetFlag]->Release();
 	beh.gcSetFlag = 0;
 	beh.gcSetFlag = 0;
+
+	for( asUINT e = 1; e < beh.operators.GetLength(); e += 2 )
+	{
+		if( engine->scriptFunctions[beh.operators[e]] )
+			engine->scriptFunctions[beh.operators[e]]->Release();
+	}
+	beh.operators.SetLength(0);
+
+	for( asUINT c = 0; c < methods.GetLength(); c++ )
+	{
+		if( engine->scriptFunctions[methods[c]] ) 
+			engine->scriptFunctions[methods[c]]->Release();
+	}
+	methods.SetLength(0);
+
+	for( asUINT d = 0; d < virtualFunctionTable.GetLength(); d++ )
+	{
+		if( virtualFunctionTable[d] )
+			virtualFunctionTable[d]->Release();
+	}
+	virtualFunctionTable.SetLength(0);
 }
 }
 
 
 // internal
 // internal

+ 6 - 19
ThirdParty/AngelScript/source/as_objecttype.h

@@ -54,13 +54,14 @@ BEGIN_AS_NAMESPACE
 // TODO: The type id should have flags for diferenciating between value types and reference types. It should also have a flag for differenciating interface types.
 // TODO: The type id should have flags for diferenciating between value types and reference types. It should also have a flag for differenciating interface types.
 
 
 // Additional flag to the class object type
 // Additional flag to the class object type
-const asDWORD asOBJ_IMPLICIT_HANDLE  = 0x00400000;
+const asDWORD asOBJ_IMPLICIT_HANDLE  = 0x40000;
 const asDWORD asOBJ_TYPEDEF          = 0x40000000;
 const asDWORD asOBJ_TYPEDEF          = 0x40000000;
 const asDWORD asOBJ_ENUM             = 0x10000000;
 const asDWORD asOBJ_ENUM             = 0x10000000;
 const asDWORD asOBJ_TEMPLATE_SUBTYPE = 0x20000000;
 const asDWORD asOBJ_TEMPLATE_SUBTYPE = 0x20000000;
 
 
 
 
 
 
+
 // asOBJ_GC is used to indicate that the type can potentially 
 // asOBJ_GC is used to indicate that the type can potentially 
 // form circular references, thus is garbage collected.
 // form circular references, thus is garbage collected.
 
 
@@ -73,6 +74,10 @@ const asDWORD asOBJ_TEMPLATE_SUBTYPE = 0x20000000;
 // automatically make garbage collected as well, because we cannot know what type
 // automatically make garbage collected as well, because we cannot know what type
 // of references that object can contain, and must assume the worst.
 // of references that object can contain, and must assume the worst.
 
 
+// TODO: interface: asIObjectType should have methods for setting/getting user data
+//                  this can for example be used to store cached function ids for quicker
+//                  executions of class methods
+
 struct asSTypeBehaviour
 struct asSTypeBehaviour
 {
 {
 	asSTypeBehaviour() 
 	asSTypeBehaviour() 
@@ -147,7 +152,6 @@ public:
 	asUINT           GetSize() const;
 	asUINT           GetSize() const;
 	int              GetTypeId() const;
 	int              GetTypeId() const;
 	int              GetSubTypeId() const;
 	int              GetSubTypeId() const;
-	// TODO: access: Get/Set access mask for type
 
 
 	// Interfaces
 	// Interfaces
 	asUINT           GetInterfaceCount() const;
 	asUINT           GetInterfaceCount() const;
@@ -157,24 +161,15 @@ public:
 	asUINT             GetFactoryCount() const;
 	asUINT             GetFactoryCount() const;
 	int                GetFactoryIdByIndex(asUINT index) const;
 	int                GetFactoryIdByIndex(asUINT index) const;
 	int                GetFactoryIdByDecl(const char *decl) const;
 	int                GetFactoryIdByDecl(const char *decl) const;
-	asIScriptFunction *GetFactoryByIndex(asUINT index) const;
-	asIScriptFunction *GetFactoryByDecl(const char *decl) const;
 
 
 	// Methods
 	// Methods
 	asUINT             GetMethodCount() const;
 	asUINT             GetMethodCount() const;
 	int                GetMethodIdByIndex(asUINT index, bool getVirtual) const;
 	int                GetMethodIdByIndex(asUINT index, bool getVirtual) const;
 	int                GetMethodIdByName(const char *name, bool getVirtual) const;
 	int                GetMethodIdByName(const char *name, bool getVirtual) const;
 	int                GetMethodIdByDecl(const char *decl, bool getVirtual) const;
 	int                GetMethodIdByDecl(const char *decl, bool getVirtual) const;
-	asIScriptFunction *GetMethodByIndex(asUINT index, bool getVirtual) const;
-	asIScriptFunction *GetMethodByName(const char *name, bool getVirtual) const;
-	asIScriptFunction *GetMethodByDecl(const char *decl, bool getVirtual) const;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-03
 	asIScriptFunction *GetMethodDescriptorByIndex(asUINT index, bool getVirtual) const;
 	asIScriptFunction *GetMethodDescriptorByIndex(asUINT index, bool getVirtual) const;
-#endif
 
 
 	// Properties
 	// Properties
-	// TODO: access: Allow getting and setting property access mask
 	asUINT      GetPropertyCount() const;
 	asUINT      GetPropertyCount() const;
 	int         GetProperty(asUINT index, const char **name, int *typeId, bool *isPrivate, int *offset, bool *isReference) const;
 	int         GetProperty(asUINT index, const char **name, int *typeId, bool *isPrivate, int *offset, bool *isReference) const;
 	const char *GetPropertyDeclaration(asUINT index) const;
 	const char *GetPropertyDeclaration(asUINT index) const;
@@ -183,10 +178,6 @@ public:
 	asUINT GetBehaviourCount() const;
 	asUINT GetBehaviourCount() const;
 	int    GetBehaviourByIndex(asUINT index, asEBehaviours *outBehaviour) const;
 	int    GetBehaviourByIndex(asUINT index, asEBehaviours *outBehaviour) const;
 
 
-	// User data
-	void *SetUserData(void *data);
-	void *GetUserData() const;
-
 //===========================================
 //===========================================
 // Internal
 // Internal
 //===========================================
 //===========================================
@@ -203,11 +194,9 @@ public:
 
 
 	void ReleaseAllFunctions();
 	void ReleaseAllFunctions();
 
 
-	// TODO: interface: Implements and DerivesFrom could be made public methods in the asIObjectType interface
 	bool Implements(const asCObjectType *objType) const;
 	bool Implements(const asCObjectType *objType) const;
 	bool DerivesFrom(const asCObjectType *objType) const;
 	bool DerivesFrom(const asCObjectType *objType) const;
 	bool IsInterface() const;
 	bool IsInterface() const;
-	bool IsShared() const;
 
 
 	asCObjectProperty *AddPropertyToClass(const asCString &name, const asCDataType &dt, bool isPrivate);
 	asCObjectProperty *AddPropertyToClass(const asCString &name, const asCDataType &dt, bool isPrivate);
 
 
@@ -221,7 +210,6 @@ public:
 	asCArray<asCScriptFunction*> virtualFunctionTable;
 	asCArray<asCScriptFunction*> virtualFunctionTable;
 
 
 	asDWORD flags;
 	asDWORD flags;
-	asDWORD accessMask;
 
 
 	asSTypeBehaviour beh;
 	asSTypeBehaviour beh;
 
 
@@ -231,7 +219,6 @@ public:
 	bool           acceptRefSubType;
 	bool           acceptRefSubType;
 
 
 	asCScriptEngine *engine;
 	asCScriptEngine *engine;
-	void            *userData;
 
 
 protected:
 protected:
 	mutable asCAtomic refCount;
 	mutable asCAtomic refCount;

+ 3 - 38
ThirdParty/AngelScript/source/as_parser.cpp

@@ -335,14 +335,13 @@ asCScriptNode *asCParser::ParseScript()
 	asCScriptNode *node = new(engine->memoryMgr.AllocScriptNode()) asCScriptNode(snScript);
 	asCScriptNode *node = new(engine->memoryMgr.AllocScriptNode()) asCScriptNode(snScript);
 
 
 	// Determine type of node
 	// Determine type of node
-	sToken t1, t2;
+	sToken t1;
 
 
 	for(;;)
 	for(;;)
 	{
 	{
 		while( !isSyntaxError )
 		while( !isSyntaxError )
 		{
 		{
 			GetToken(&t1);
 			GetToken(&t1);
-			GetToken(&t2);
 			RewindTo(&t1);
 			RewindTo(&t1);
 
 
 			if( t1.type == ttImport )
 			if( t1.type == ttImport )
@@ -351,9 +350,9 @@ asCScriptNode *asCParser::ParseScript()
 				node->AddChildLast(ParseEnumeration());	//	Handle enumerations
 				node->AddChildLast(ParseEnumeration());	//	Handle enumerations
 			else if( t1.type == ttTypedef )
 			else if( t1.type == ttTypedef )
 				node->AddChildLast(ParseTypedef());		//	Handle primitive typedefs
 				node->AddChildLast(ParseTypedef());		//	Handle primitive typedefs
-			else if( t1.type == ttClass || (t1.type == ttIdentifier && t2.type == ttClass) )
+			else if( t1.type == ttClass )
 				node->AddChildLast(ParseClass());
 				node->AddChildLast(ParseClass());
-			else if( t1.type == ttInterface || (t1.type == ttIdentifier && t2.type == ttInterface) )
+			else if( t1.type == ttInterface )
 				node->AddChildLast(ParseInterface());
 				node->AddChildLast(ParseInterface());
 			else if( t1.type == ttFuncDef )
 			else if( t1.type == ttFuncDef )
 				node->AddChildLast(ParseFuncDef());
 				node->AddChildLast(ParseFuncDef());
@@ -919,23 +918,6 @@ asCScriptNode *asCParser::ParseInterface()
 
 
 	sToken t;
 	sToken t;
 	GetToken(&t);
 	GetToken(&t);
-
-	// Allow keyword 'shared' before 'interface'
-	if( t.type == ttIdentifier )
-	{
-		asCString str;
-		str.Assign(&script->code[t.pos], t.length);
-		if( str != SHARED_TOKEN )
-		{
-			Error(ExpectedToken(SHARED_TOKEN).AddressOf(), &t);
-			return node;
-		}
-
-		RewindTo(&t);
-		node->AddChildLast(ParseIdentifier());
-		GetToken(&t);
-	}
-
 	if( t.type != ttInterface )
 	if( t.type != ttInterface )
 	{
 	{
 		Error(ExpectedToken("interface").AddressOf(), &t);
 		Error(ExpectedToken("interface").AddressOf(), &t);
@@ -984,23 +966,6 @@ asCScriptNode *asCParser::ParseClass()
 
 
 	sToken t;
 	sToken t;
 	GetToken(&t);
 	GetToken(&t);
-
-	// Allow the keyword 'shared' before 'class'
-	if( t.type == ttIdentifier )
-	{
-		asCString str;
-		str.Assign(&script->code[t.pos], t.length);
-		if( str != SHARED_TOKEN )
-		{
-			Error(ExpectedToken(SHARED_TOKEN).AddressOf(), &t);
-			return node;
-		}
-
-		RewindTo(&t);
-		node->AddChildLast(ParseIdentifier());
-		GetToken(&t);
-	}
-
 	if( t.type != ttClass )
 	if( t.type != ttClass )
 	{
 	{
 		Error(ExpectedToken("class").AddressOf(), &t);
 		Error(ExpectedToken("class").AddressOf(), &t);

+ 1 - 5
ThirdParty/AngelScript/source/as_property.h

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2010 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -50,12 +50,10 @@ BEGIN_AS_NAMESPACE
 class asCObjectProperty
 class asCObjectProperty
 {
 {
 public:
 public:
-	asCObjectProperty() {accessMask = 0xFFFFFFFF;}
 	asCString   name;
 	asCString   name;
 	asCDataType type;
 	asCDataType type;
 	int         byteOffset;
 	int         byteOffset;
 	bool		isPrivate;
 	bool		isPrivate;
-	asDWORD     accessMask;
 };
 };
 
 
 class asCGlobalProperty
 class asCGlobalProperty
@@ -100,8 +98,6 @@ public:
 
 
 	asCScriptFunction *initFunc;
 	asCScriptFunction *initFunc;
 
 
-	asDWORD accessMask;
-
 	// The global property structure is reference counted, so that the
 	// The global property structure is reference counted, so that the
 	// engine can keep track of how many references to the property there are.
 	// engine can keep track of how many references to the property there are.
 	asCAtomic refCount;
 	asCAtomic refCount;

+ 47 - 163
ThirdParty/AngelScript/source/as_restore.cpp

@@ -39,7 +39,6 @@
 #include "as_restore.h"
 #include "as_restore.h"
 #include "as_bytecode.h"
 #include "as_bytecode.h"
 #include "as_scriptobject.h"
 #include "as_scriptobject.h"
-#include "as_texts.h"
 
 
 BEGIN_AS_NAMESPACE
 BEGIN_AS_NAMESPACE
 
 
@@ -252,39 +251,13 @@ int asCRestore::Restore()
 	{
 	{
 		asCObjectType *ot = asNEW(asCObjectType)(engine);
 		asCObjectType *ot = asNEW(asCObjectType)(engine);
 		ReadObjectTypeDeclaration(ot, 1);
 		ReadObjectTypeDeclaration(ot, 1);
-
-		// If the type is shared, then we should use the original if it exists
-		bool sharedExists = false;
-		if( ot->IsShared() )
-		{
-			for( asUINT n = 0; n < engine->classTypes.GetLength(); n++ )
-			{
-				asCObjectType *t = engine->classTypes[n];
-				if( t &&
-					t->IsShared() &&
-					t->name == ot->name &&
-					t->IsInterface() == ot->IsInterface() )
-				{
-					ot->Release();
-					ot = t;
-					sharedExists = true;
-					break;
-				}
-			}
-		}
-
-		if( sharedExists )
-			existingShared.Insert(ot, true);
-		else
-		{
-			engine->classTypes.PushLast(ot);
-
-			// Add script classes to the GC
-			if( (ot->GetFlags() & asOBJ_SCRIPT_OBJECT) && !ot->IsInterface() )
-				engine->gc.AddScriptObjectToGC(ot, &engine->objectTypeBehaviours);
-		}
+		engine->classTypes.PushLast(ot);
 		module->classTypes.PushLast(ot);
 		module->classTypes.PushLast(ot);
 		ot->AddRef();
 		ot->AddRef();
+
+		// Add script classes to the GC
+		if( (ot->GetFlags() & asOBJ_SCRIPT_OBJECT) && ot->GetSize() > 0 )
+			engine->gc.AddScriptObjectToGC(ot, &engine->objectTypeBehaviours);
 	}
 	}
 
 
 	// Read func defs
 	// Read func defs
@@ -354,11 +327,6 @@ int asCRestore::Restore()
 
 
 	// scriptGlobals[]
 	// scriptGlobals[]
 	count = ReadEncodedUInt();
 	count = ReadEncodedUInt();
-	if( engine->ep.disallowGlobalVars )
-	{
-		engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, TXT_GLOBAL_VARS_NOT_ALLOWED);
-		error = true;
-	}
 	module->scriptGlobals.Allocate(count, 0);
 	module->scriptGlobals.Allocate(count, 0);
 	for( i = 0; i < count; ++i ) 
 	for( i = 0; i < count; ++i ) 
 	{
 	{
@@ -991,155 +959,76 @@ void asCRestore::ReadObjectTypeDeclaration(asCObjectType *ot, int phase)
 		}
 		}
 		else
 		else
 		{
 		{
-			// If the type is shared and pre-existing, we should just 
-			// validate that the loaded methods match the original 
-			bool sharedExists = existingShared.MoveTo(0, ot);
-			if( sharedExists )
-			{
-				asCObjectType *dt = ReadObjectType();
-				if( ot->derivedFrom != dt )
-				{
-					// TODO: Write message
-					error = true;
-				}
-			}
-			else
-			{
-				ot->derivedFrom = ReadObjectType();
-				if( ot->derivedFrom )
-					ot->derivedFrom->AddRef();
-			}
+			ot->derivedFrom = ReadObjectType();
+			if( ot->derivedFrom )
+				ot->derivedFrom->AddRef();
 
 
 			// interfaces[]
 			// interfaces[]
 			int size = ReadEncodedUInt();
 			int size = ReadEncodedUInt();
-			if( sharedExists )
-			{
-				for( int n = 0; n < size; n++ )
-				{
-					asCObjectType *intf = ReadObjectType();
-					if( !ot->Implements(intf) )
-					{
-						// TODO: Write message
-						error = true;
-					}
-				}
-			}
-			else
+			ot->interfaces.Allocate(size,0);
+			int n;
+			for( n = 0; n < size; n++ )
 			{
 			{
-				ot->interfaces.Allocate(size,0);
-				for( int n = 0; n < size; n++ )
-				{
-					asCObjectType *intf = ReadObjectType();
-					ot->interfaces.PushLast(intf);
-				}
+				asCObjectType *intf = ReadObjectType();
+				ot->interfaces.PushLast(intf);
 			}
 			}
 
 
 			// behaviours
 			// behaviours
 			if( !ot->IsInterface() && ot->flags != asOBJ_TYPEDEF && ot->flags != asOBJ_ENUM )
 			if( !ot->IsInterface() && ot->flags != asOBJ_TYPEDEF && ot->flags != asOBJ_ENUM )
 			{
 			{
-				// For existing types we don't want to make any updates
-				asCScriptFunction *func = ReadFunction(!sharedExists, !sharedExists);
+				asCScriptFunction *func = ReadFunction();
 				if( func )
 				if( func )
 				{
 				{
-					if( sharedExists )
-					{
-						// TODO: shared: Find the real function in the object, and update the savedFunctions array
-						func->Release();
-					}
-					else 
-					{
-						engine->scriptFunctions[ot->beh.construct]->Release();
-						ot->beh.construct = func->id;
-						ot->beh.constructors[0] = func->id;
-						func->AddRef();
-					}
+					engine->scriptFunctions[ot->beh.construct]->Release();
+					ot->beh.construct = func->id;
+					ot->beh.constructors[0] = func->id;
+					func->AddRef();
 				}
 				}
 
 
 				func = ReadFunction();
 				func = ReadFunction();
 				if( func )
 				if( func )
 				{
 				{
-					if( sharedExists )
-					{
-						// TODO: shared: Find the real function in the object, and update the savedFunctions array
-						func->Release();
-					}
-					else
-					{
-						ot->beh.destruct = func->id;
-						func->AddRef();
-					}
+					ot->beh.destruct = func->id;
+					func->AddRef();
 				}
 				}
 
 
 				func = ReadFunction();
 				func = ReadFunction();
 				if( func )
 				if( func )
 				{
 				{
-					if( sharedExists )
-					{
-						// TODO: shared: Find the real function in the object, and update the savedFunctions array
-						func->Release();
-					}
-					else
-					{
-						engine->scriptFunctions[ot->beh.factory]->Release();
-						ot->beh.factory = func->id;
-						ot->beh.factories[0] = func->id;
-						func->AddRef();
-					}
+					engine->scriptFunctions[ot->beh.factory]->Release();
+					ot->beh.factory = func->id;
+					ot->beh.factories[0] = func->id;
+					func->AddRef();
 				}
 				}
 
 
 				size = ReadEncodedUInt();
 				size = ReadEncodedUInt();
-				for( int n = 0; n < size; n++ )
+				for( n = 0; n < size; n++ )
 				{
 				{
 					asCScriptFunction *func = ReadFunction();
 					asCScriptFunction *func = ReadFunction();
 					if( func )
 					if( func )
 					{
 					{
-						if( sharedExists )
-						{
-							// TODO: shared: Find the real function in the object, and update the savedFunctions array
-							func->Release();
-						}
-						else
-						{
-							ot->beh.constructors.PushLast(func->id);
-							func->AddRef();
-						}
+						ot->beh.constructors.PushLast(func->id);
+						func->AddRef();
 					}
 					}
 
 
 					func = ReadFunction();
 					func = ReadFunction();
 					if( func )
 					if( func )
 					{
 					{
-						if( sharedExists )
-						{
-							// TODO: shared: Find the real function in the object, and update the savedFunctions array
-							func->Release();
-						}
-						else
-						{
-							ot->beh.factories.PushLast(func->id);
-							func->AddRef();
-						}
+						ot->beh.factories.PushLast(func->id);
+						func->AddRef();
 					}
 					}
 				}
 				}
 			}
 			}
 
 
 			// methods[]
 			// methods[]
 			size = ReadEncodedUInt();
 			size = ReadEncodedUInt();
-			int n;
 			for( n = 0; n < size; n++ ) 
 			for( n = 0; n < size; n++ ) 
 			{
 			{
 				asCScriptFunction *func = ReadFunction();
 				asCScriptFunction *func = ReadFunction();
 				if( func )
 				if( func )
 				{
 				{
-					if( sharedExists )
-					{
-						// TODO: shared: Find the real function in the object, and update the savedFunctions array
-						func->Release();
-					}
-					else
-					{
-						ot->methods.PushLast(func->id);
-						func->AddRef();
-					}
+					ot->methods.PushLast(func->id);
+					func->AddRef();
 				}
 				}
 			}
 			}
 
 
@@ -1150,16 +1039,8 @@ void asCRestore::ReadObjectTypeDeclaration(asCObjectType *ot, int phase)
 				asCScriptFunction *func = ReadFunction();
 				asCScriptFunction *func = ReadFunction();
 				if( func )
 				if( func )
 				{
 				{
-					if( sharedExists )
-					{
-						// TODO: shared: Find the real function in the object, and update the savedFunctions array
-						func->Release();
-					}
-					else
-					{
-						ot->virtualFunctionTable.PushLast(func);
-						func->AddRef();
-					}
+					ot->virtualFunctionTable.PushLast(func);
+					func->AddRef();
 				}
 				}
 			}
 			}
 		}
 		}
@@ -1391,10 +1272,7 @@ void asCRestore::ReadObjectProperty(asCObjectType *ot)
 	bool isPrivate;
 	bool isPrivate;
 	READ_NUM(isPrivate);
 	READ_NUM(isPrivate);
 
 
-	// TODO: shared: If the type is shared and pre-existing, we should just 
-	//               validate that the loaded methods match the original 
-	if( !existingShared.MoveTo(0, ot) )
-		ot->AddPropertyToClass(name, dt, isPrivate);
+	ot->AddPropertyToClass(name, dt, isPrivate);
 }
 }
 
 
 void asCRestore::WriteDataType(const asCDataType *dt) 
 void asCRestore::WriteDataType(const asCDataType *dt) 
@@ -1472,7 +1350,7 @@ void asCRestore::ReadDataType(asCDataType *dt)
 		ReadFunctionSignature(&func);
 		ReadFunctionSignature(&func);
 		for( asUINT n = 0; n < engine->registeredFuncDefs.GetLength(); n++ )
 		for( asUINT n = 0; n < engine->registeredFuncDefs.GetLength(); n++ )
 		{
 		{
-			// TODO: access: Only return the definitions that the module has access to
+			// TODO: Only return the definitions for the config groups that the module has access to
 			if( engine->registeredFuncDefs[n]->name == func.name )
 			if( engine->registeredFuncDefs[n]->name == func.name )
 			{
 			{
 				funcDef = engine->registeredFuncDefs[n];
 				funcDef = engine->registeredFuncDefs[n];
@@ -1579,8 +1457,9 @@ asCObjectType* asCRestore::ReadObjectType()
 		asCObjectType *tmpl = engine->GetObjectType(typeName.AddressOf());
 		asCObjectType *tmpl = engine->GetObjectType(typeName.AddressOf());
 		if( tmpl == 0 )
 		if( tmpl == 0 )
 		{
 		{
+			// TODO: Move text to as_texts.h
 			asCString str;
 			asCString str;
-			str.Format(TXT_TEMPLATE_TYPE_s_DOESNT_EXIST, typeName.AddressOf());
+			str.Format("Template type '%s' doesn't exist", typeName.AddressOf());
 			engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 			engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 			error = true;
 			error = true;
 			return 0;
 			return 0;
@@ -1592,8 +1471,9 @@ asCObjectType* asCRestore::ReadObjectType()
 			ot = ReadObjectType();
 			ot = ReadObjectType();
 			if( ot == 0 )
 			if( ot == 0 )
 			{
 			{
+				// TODO: Move text to as_texts.h
 				asCString str;
 				asCString str;
-				str.Format(TXT_FAILED_READ_SUBTYPE_OF_TEMPLATE_s, typeName.AddressOf());
+				str.Format("Failed to read subtype of template type '%s'", typeName.AddressOf());
 				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 				error = true;
 				error = true;
 				return 0;
 				return 0;
@@ -1612,8 +1492,9 @@ asCObjectType* asCRestore::ReadObjectType()
 			
 			
 			if( ot == 0 )
 			if( ot == 0 )
 			{
 			{
+				// TODO: Move text to as_texts.h
 				asCString str;
 				asCString str;
-				str.Format(TXT_INSTANCING_INVLD_TMPL_TYPE_s_s, typeName.AddressOf(), dt.Format().AddressOf());
+				str.Format("Attempting to instanciate invalid template type '%s<%s>'", typeName.AddressOf(), dt.Format().AddressOf());
 				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 				error = true;
 				error = true;
 				return 0;
 				return 0;
@@ -1629,8 +1510,9 @@ asCObjectType* asCRestore::ReadObjectType()
 			
 			
 			if( ot == 0 )
 			if( ot == 0 )
 			{
 			{
+				// TODO: Move text to as_texts.h
 				asCString str;
 				asCString str;
-				str.Format(TXT_INSTANCING_INVLD_TMPL_TYPE_s_s, typeName.AddressOf(), dt.Format().AddressOf());
+				str.Format("Attempting to instanciate invalid template type '%s<%s>'", typeName.AddressOf(), dt.Format().AddressOf());
 				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 				error = true;
 				error = true;
 				return 0;
 				return 0;
@@ -1656,8 +1538,9 @@ asCObjectType* asCRestore::ReadObjectType()
 
 
 		if( ot == 0 )
 		if( ot == 0 )
 		{
 		{
+			// TODO: Move text to as_texts.h
 			asCString str;
 			asCString str;
-			str.Format(TXT_TEMPLATE_SUBTYPE_s_DOESNT_EXIST, typeName.AddressOf());
+			str.Format("Template subtype type '%s' doesn't exist", typeName.AddressOf());
 			engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 			engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 			error = true;
 			error = true;
 			return 0;
 			return 0;
@@ -1678,8 +1561,9 @@ asCObjectType* asCRestore::ReadObjectType()
 			
 			
 			if( ot == 0 )
 			if( ot == 0 )
 			{
 			{
+				// TODO: Move text to as_texts.h
 				asCString str;
 				asCString str;
-				str.Format(TXT_OBJECT_TYPE_s_DOESNT_EXIST, typeName.AddressOf());
+				str.Format("Object type '%s' doesn't exist", typeName.AddressOf());
 				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 				engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf());
 				error = true;
 				error = true;
 				return 0;
 				return 0;

+ 0 - 2
ThirdParty/AngelScript/source/as_restore.h

@@ -139,8 +139,6 @@ protected:
 		asUINT         oldSize;
 		asUINT         oldSize;
 	};
 	};
 	asCArray<SObjChangeSize>     oldObjectSizes;
 	asCArray<SObjChangeSize>     oldObjectSizes;
-
-	asCMap<void*,bool>           existingShared;
 };
 };
 
 
 END_AS_NAMESPACE
 END_AS_NAMESPACE

+ 44 - 198
ThirdParty/AngelScript/source/as_scriptengine.cpp

@@ -292,10 +292,6 @@ int asCScriptEngine::SetEngineProperty(asEEngineProp property, asPWORD value)
 		ep.autoGarbageCollect = value ? true : false;
 		ep.autoGarbageCollect = value ? true : false;
 		break;
 		break;
 
 
-	case asEP_DISALLOW_GLOBAL_VARS:
-		ep.disallowGlobalVars = value ? true : false;
-		break;
-
 	default:
 	default:
 		return asINVALID_ARG;
 		return asINVALID_ARG;
 	}
 	}
@@ -354,9 +350,6 @@ asPWORD asCScriptEngine::GetEngineProperty(asEEngineProp property) const
 
 
 	case asEP_AUTO_GARBAGE_COLLECT:
 	case asEP_AUTO_GARBAGE_COLLECT:
 		return ep.autoGarbageCollect;
 		return ep.autoGarbageCollect;
-
-	case asEP_DISALLOW_GLOBAL_VARS:
-		return ep.disallowGlobalVars;
 	}
 	}
 
 
 	return 0;
 	return 0;
@@ -400,7 +393,6 @@ asCScriptEngine::asCScriptEngine()
 		ep.propertyAccessorMode         = 2;         // 0 = disable, 1 = app registered only, 2 = app and script created
 		ep.propertyAccessorMode         = 2;         // 0 = disable, 1 = app registered only, 2 = app and script created
 		ep.expandDefaultArrayToTemplate = false;
 		ep.expandDefaultArrayToTemplate = false;
 		ep.autoGarbageCollect           = true;
 		ep.autoGarbageCollect           = true;
-		ep.disallowGlobalVars           = false;
 	}
 	}
 
 
 	gc.engine = this;
 	gc.engine = this;
@@ -413,20 +405,17 @@ asCScriptEngine::asCScriptEngine()
 	lastModule = 0;
 	lastModule = 0;
 
 
 	// User data
 	// User data
-	userData            = 0;
-	cleanEngineFunc     = 0;
-	cleanModuleFunc     = 0;
-	cleanContextFunc    = 0;
-	cleanFunctionFunc   = 0;
-	cleanObjectTypeFunc = 0;
+	userData          = 0;
+	cleanEngineFunc   = 0;
+	cleanContextFunc  = 0;
+	cleanFunctionFunc = 0;
 
 
 
 
 	initialContextStackSize = 1024;      // 4 KB (1024 * sizeof(asDWORD)
 	initialContextStackSize = 1024;      // 4 KB (1024 * sizeof(asDWORD)
 
 
 
 
-	typeIdSeqNbr      = 0;
-	currentGroup      = &defaultGroup;
-	defaultAccessMask = 1;
+	typeIdSeqNbr = 0;
+	currentGroup = &defaultGroup;
 
 
 	msgCallback = 0;
 	msgCallback = 0;
     jitCompiler = 0;
     jitCompiler = 0;
@@ -542,11 +531,6 @@ asCScriptEngine::~asCScriptEngine()
 	GarbageCollect(asGC_FULL_CYCLE);
 	GarbageCollect(asGC_FULL_CYCLE);
 	ClearUnusedTypes();
 	ClearUnusedTypes();
 
 
-	// If the application hasn't registered GC behaviours for all types 
-	// that can form circular references with script types, then there
-	// may still be objects in the GC.
-	gc.ReportUndestroyedObjects();
-
 	asSMapNode<int,asCDataType*> *cursor = 0;
 	asSMapNode<int,asCDataType*> *cursor = 0;
 	while( mapTypeIdToDataType.MoveFirst(&cursor) )
 	while( mapTypeIdToDataType.MoveFirst(&cursor) )
 	{
 	{
@@ -798,9 +782,6 @@ int asCScriptEngine::DiscardModule(const char *module)
 	FreeUnusedGlobalProperties();
 	FreeUnusedGlobalProperties();
 	ClearUnusedTypes();
 	ClearUnusedTypes();
 
 
-	if( ep.autoGarbageCollect )
-		GarbageCollect();
-
 	return 0;
 	return 0;
 }
 }
 
 
@@ -1079,7 +1060,6 @@ int asCScriptEngine::RegisterObjectProperty(const char *obj, const char *declara
 	prop->type       = type;
 	prop->type       = type;
 	prop->byteOffset = byteOffset;
 	prop->byteOffset = byteOffset;
 	prop->isPrivate  = false;
 	prop->isPrivate  = false;
-	prop->accessMask = defaultAccessMask;
 
 
 	dt.GetObjectType()->properties.PushLast(prop);
 	dt.GetObjectType()->properties.PushLast(prop);
 
 
@@ -1124,7 +1104,7 @@ int asCScriptEngine::RegisterInterface(const char *name)
 
 
 	// Register the object type for the interface
 	// Register the object type for the interface
 	asCObjectType *st = asNEW(asCObjectType)(this);
 	asCObjectType *st = asNEW(asCObjectType)(this);
-	st->flags = asOBJ_REF | asOBJ_SCRIPT_OBJECT | asOBJ_SHARED;
+	st->flags = asOBJ_REF | asOBJ_SCRIPT_OBJECT;
 	st->size = 0; // Cannot be instanciated
 	st->size = 0; // Cannot be instanciated
 	st->name = name;
 	st->name = name;
 
 
@@ -1245,35 +1225,26 @@ int asCScriptEngine::RegisterObjectType(const char *name, int byteSize, asDWORD
 		else if( flags & asOBJ_APP_PRIMITIVE )
 		else if( flags & asOBJ_APP_PRIMITIVE )
 		{
 		{
 			// Must not set the class flags nor the float flag
 			// Must not set the class flags nor the float flag
-			if( flags & (asOBJ_APP_CLASS                  |
-				         asOBJ_APP_CLASS_CONSTRUCTOR      |
-						 asOBJ_APP_CLASS_DESTRUCTOR       |
-						 asOBJ_APP_CLASS_ASSIGNMENT       |
-						 asOBJ_APP_CLASS_COPY_CONSTRUCTOR |
-						 asOBJ_APP_FLOAT                  |
-						 asOBJ_APP_CLASS_ALLINTS          |
-						 asOBJ_APP_CLASS_ALLFLOATS) )
+			if( flags & (asOBJ_APP_CLASS             |
+				         asOBJ_APP_CLASS_CONSTRUCTOR |
+						 asOBJ_APP_CLASS_DESTRUCTOR  |
+						 asOBJ_APP_CLASS_ASSIGNMENT  |
+						 asOBJ_APP_FLOAT) )
 				return ConfigError(asINVALID_ARG);
 				return ConfigError(asINVALID_ARG);
 		}
 		}
 		else if( flags & asOBJ_APP_FLOAT )
 		else if( flags & asOBJ_APP_FLOAT )
 		{
 		{
 			// Must not set the class flags nor the primitive flag
 			// Must not set the class flags nor the primitive flag
-			if( flags & (asOBJ_APP_CLASS                  |
-				         asOBJ_APP_CLASS_CONSTRUCTOR      |
-						 asOBJ_APP_CLASS_DESTRUCTOR       |
-						 asOBJ_APP_CLASS_ASSIGNMENT       |
-						 asOBJ_APP_CLASS_COPY_CONSTRUCTOR |
-						 asOBJ_APP_PRIMITIVE              |
-						 asOBJ_APP_CLASS_ALLINTS          |
-						 asOBJ_APP_CLASS_ALLFLOATS) )
+			if( flags & (asOBJ_APP_CLASS             |
+				         asOBJ_APP_CLASS_CONSTRUCTOR |
+						 asOBJ_APP_CLASS_DESTRUCTOR  |
+						 asOBJ_APP_CLASS_ASSIGNMENT  |
+						 asOBJ_APP_PRIMITIVE) )
 				return ConfigError(asINVALID_ARG);
 				return ConfigError(asINVALID_ARG);
 		}
 		}
-		else if( flags & (asOBJ_APP_CLASS_CONSTRUCTOR      |
-		                  asOBJ_APP_CLASS_DESTRUCTOR       |
-		                  asOBJ_APP_CLASS_ASSIGNMENT       |
-						  asOBJ_APP_CLASS_COPY_CONSTRUCTOR |
-						  asOBJ_APP_CLASS_ALLINTS          |
-						  asOBJ_APP_CLASS_ALLFLOATS) )
+		else if( flags & (asOBJ_APP_CLASS_CONSTRUCTOR |
+		                  asOBJ_APP_CLASS_DESTRUCTOR  |
+		                  asOBJ_APP_CLASS_ASSIGNMENT) )
 		{
 		{
 			// Must not set the class properties, without the class flag
 			// Must not set the class properties, without the class flag
 			return ConfigError(asINVALID_ARG);
 			return ConfigError(asINVALID_ARG);
@@ -1315,10 +1286,9 @@ int asCScriptEngine::RegisterObjectType(const char *name, int byteSize, asDWORD
 		}
 		}
 
 
 		asCObjectType *type = asNEW(asCObjectType)(this);
 		asCObjectType *type = asNEW(asCObjectType)(this);
-		type->name       = typeName;
-		type->size       = byteSize;
-		type->flags      = flags;
-		type->accessMask = defaultAccessMask;
+		type->name      = typeName;
+		type->size      = byteSize;
+		type->flags     = flags;
 
 
 		// Store it in the object types
 		// Store it in the object types
 		objectTypes.PushLast(type);
 		objectTypes.PushLast(type);
@@ -1399,10 +1369,9 @@ int asCScriptEngine::RegisterObjectType(const char *name, int byteSize, asDWORD
 
 
 			// Put the data type in the list
 			// Put the data type in the list
 			asCObjectType *type = asNEW(asCObjectType)(this);
 			asCObjectType *type = asNEW(asCObjectType)(this);
-			type->name       = typeName;
-			type->size       = byteSize;
-			type->flags      = flags;
-			type->accessMask = defaultAccessMask;
+			type->name      = typeName;
+			type->size      = byteSize;
+			type->flags     = flags;
 
 
 			objectTypes.PushLast(type);
 			objectTypes.PushLast(type);
 			registeredObjTypes.PushLast(type);
 			registeredObjTypes.PushLast(type);
@@ -1437,12 +1406,11 @@ int asCScriptEngine::RegisterObjectType(const char *name, int byteSize, asDWORD
 
 
 			// Put the data type in the list
 			// Put the data type in the list
 			asCObjectType *type = asNEW(asCObjectType)(this);
 			asCObjectType *type = asNEW(asCObjectType)(this);
-			type->name       = dt.GetObjectType()->name;
+			type->name      = dt.GetObjectType()->name;
 			type->templateSubType = dt.GetSubType();
 			type->templateSubType = dt.GetSubType();
 			if( type->templateSubType.GetObjectType() ) type->templateSubType.GetObjectType()->AddRef();
 			if( type->templateSubType.GetObjectType() ) type->templateSubType.GetObjectType()->AddRef();
-			type->size       = byteSize;
-			type->flags      = flags;
-			type->accessMask = defaultAccessMask;
+			type->size      = byteSize;
+			type->flags     = flags;
 
 
 			templateTypes.PushLast(type);
 			templateTypes.PushLast(type);
 
 
@@ -1891,7 +1859,6 @@ int asCScriptEngine::AddBehaviourFunction(asCScriptFunction &func, asSSystemFunc
 	f->objectType  = func.objectType;
 	f->objectType  = func.objectType;
 	f->id          = id;
 	f->id          = id;
 	f->isReadOnly  = func.isReadOnly;
 	f->isReadOnly  = func.isReadOnly;
-	f->accessMask  = defaultAccessMask;
 	for( n = 0; n < func.parameterTypes.GetLength(); n++ )
 	for( n = 0; n < func.parameterTypes.GetLength(); n++ )
 	{
 	{
 		f->parameterTypes.PushLast(func.parameterTypes[n]);
 		f->parameterTypes.PushLast(func.parameterTypes[n]);
@@ -1937,7 +1904,6 @@ int asCScriptEngine::RegisterGlobalProperty(const char *declaration, void *point
 	asCGlobalProperty *prop = AllocateGlobalProperty();
 	asCGlobalProperty *prop = AllocateGlobalProperty();
 	prop->name        = name;
 	prop->name        = name;
 	prop->type        = type;
 	prop->type        = type;
-	prop->accessMask  = defaultAccessMask;
 
 
 	prop->SetRegisteredAddress(pointer);
 	prop->SetRegisteredAddress(pointer);
 	
 	
@@ -1987,9 +1953,9 @@ void asCScriptEngine::FreeUnusedGlobalProperties()
 }
 }
 
 
 // interface
 // interface
-asUINT asCScriptEngine::GetGlobalPropertyCount() const
+int asCScriptEngine::GetGlobalPropertyCount() const
 {
 {
-	return registeredGlobalProps.GetLength();
+	return (int)registeredGlobalProps.GetLength();
 }
 }
 
 
 // interface
 // interface
@@ -2091,7 +2057,6 @@ int asCScriptEngine::RegisterMethodToObjectType(asCObjectType *objectType, const
 
 
 	func->id = GetNextScriptFunctionId();
 	func->id = GetNextScriptFunctionId();
 	func->objectType->methods.PushLast(func->id);
 	func->objectType->methods.PushLast(func->id);
-	func->accessMask = defaultAccessMask;
 	SetScriptFunction(func);
 	SetScriptFunction(func);
 
 
 	// TODO: This code is repeated in many places
 	// TODO: This code is repeated in many places
@@ -2195,7 +2160,6 @@ int asCScriptEngine::RegisterGlobalFunction(const char *declaration, const asSFu
 	SetScriptFunction(func);
 	SetScriptFunction(func);
 
 
 	currentGroup->scriptFunctions.PushLast(func);
 	currentGroup->scriptFunctions.PushLast(func);
-	func->accessMask = defaultAccessMask;
 	registeredGlobalFuncs.PushLast(func);
 	registeredGlobalFuncs.PushLast(func);
 
 
 	// If parameter type from other groups are used, add references
 	// If parameter type from other groups are used, add references
@@ -2218,9 +2182,9 @@ int asCScriptEngine::RegisterGlobalFunction(const char *declaration, const asSFu
 }
 }
 
 
 // interface
 // interface
-asUINT asCScriptEngine::GetGlobalFunctionCount() const
+int asCScriptEngine::GetGlobalFunctionCount() const
 {
 {
-	return registeredGlobalFuncs.GetLength();
+	return (int)registeredGlobalFuncs.GetLength();
 }
 }
 
 
 // interface
 // interface
@@ -2232,59 +2196,8 @@ int asCScriptEngine::GetGlobalFunctionIdByIndex(asUINT index) const
 	return registeredGlobalFuncs[index]->id;
 	return registeredGlobalFuncs[index]->id;
 }
 }
 
 
-// interface
-asIScriptFunction *asCScriptEngine::GetGlobalFunctionByIndex(asUINT index) const
-{
-	if( index >= registeredGlobalFuncs.GetLength() )
-		return 0;
 
 
-	return registeredGlobalFuncs[index];
-}
 
 
-// interface
-asIScriptFunction *asCScriptEngine::GetGlobalFunctionByDecl(const char *decl) const
-{
-	asCBuilder bld(const_cast<asCScriptEngine*>(this), 0);
-
-	asCScriptFunction func(const_cast<asCScriptEngine*>(this), 0, asFUNC_DUMMY);
-	int r = bld.ParseFunctionDeclaration(0, decl, &func, false);
-	if( r < 0 )
-		return 0;
-
-	// TODO: optimize: Improve linear search
-	// Search registered functions for matching interface
-	int id = -1;
-	for( size_t n = 0; n < registeredGlobalFuncs.GetLength(); ++n )
-	{
-		if( registeredGlobalFuncs[n]->objectType == 0 && 
-			func.name == registeredGlobalFuncs[n]->name && 
-			func.returnType == registeredGlobalFuncs[n]->returnType &&
-			func.parameterTypes.GetLength() == registeredGlobalFuncs[n]->parameterTypes.GetLength() )
-		{
-			bool match = true;
-			for( size_t p = 0; p < func.parameterTypes.GetLength(); ++p )
-			{
-				if( func.parameterTypes[p] != registeredGlobalFuncs[n]->parameterTypes[p] )
-				{
-					match = false;
-					break;
-				}
-			}
-
-			if( match )
-			{
-				if( id == -1 )
-					id = registeredGlobalFuncs[n]->id;
-				else
-					return 0; // Multiple matches
-			}
-		}
-	}
-
-	if( id < 0 ) return 0; // No matches
-
-	return registeredGlobalFuncs[id];
-}
 
 
 
 
 asCObjectType *asCScriptEngine::GetObjectType(const char *type)
 asCObjectType *asCScriptEngine::GetObjectType(const char *type)
@@ -2907,7 +2820,6 @@ bool asCScriptEngine::GenerateNewTemplateFunction(asCObjectType *templateType, a
 void asCScriptEngine::CallObjectMethod(void *obj, int func)
 void asCScriptEngine::CallObjectMethod(void *obj, int func)
 {
 {
 	asCScriptFunction *s = scriptFunctions[func];
 	asCScriptFunction *s = scriptFunctions[func];
-	asASSERT( s != 0 );
 	CallObjectMethod(obj, s->sysFuncIntf, s);
 	CallObjectMethod(obj, s->sysFuncIntf, s);
 }
 }
 
 
@@ -2977,7 +2889,6 @@ void asCScriptEngine::CallObjectMethod(void *obj, asSSystemFunctionInterface *i,
 bool asCScriptEngine::CallObjectMethodRetBool(void *obj, int func)
 bool asCScriptEngine::CallObjectMethodRetBool(void *obj, int func)
 {
 {
 	asCScriptFunction *s = scriptFunctions[func];
 	asCScriptFunction *s = scriptFunctions[func];
-	asASSERT( s != 0 );
 	asSSystemFunctionInterface *i = s->sysFuncIntf;
 	asSSystemFunctionInterface *i = s->sysFuncIntf;
 
 
 #ifdef __GNUC__
 #ifdef __GNUC__
@@ -3045,7 +2956,6 @@ bool asCScriptEngine::CallObjectMethodRetBool(void *obj, int func)
 int asCScriptEngine::CallObjectMethodRetInt(void *obj, int func)
 int asCScriptEngine::CallObjectMethodRetInt(void *obj, int func)
 {
 {
 	asCScriptFunction *s = scriptFunctions[func];
 	asCScriptFunction *s = scriptFunctions[func];
-	asASSERT( s != 0 );
 	asSSystemFunctionInterface *i = s->sysFuncIntf;
 	asSSystemFunctionInterface *i = s->sysFuncIntf;
 
 
 #ifdef __GNUC__
 #ifdef __GNUC__
@@ -3113,14 +3023,12 @@ int asCScriptEngine::CallObjectMethodRetInt(void *obj, int func)
 void *asCScriptEngine::CallGlobalFunctionRetPtr(int func)
 void *asCScriptEngine::CallGlobalFunctionRetPtr(int func)
 {
 {
 	asCScriptFunction *s = scriptFunctions[func];
 	asCScriptFunction *s = scriptFunctions[func];
-	asASSERT( s != 0 );
 	return CallGlobalFunctionRetPtr(s->sysFuncIntf, s);
 	return CallGlobalFunctionRetPtr(s->sysFuncIntf, s);
 }
 }
 
 
 void *asCScriptEngine::CallGlobalFunctionRetPtr(int func, void *param1)
 void *asCScriptEngine::CallGlobalFunctionRetPtr(int func, void *param1)
 {
 {
 	asCScriptFunction *s = scriptFunctions[func];
 	asCScriptFunction *s = scriptFunctions[func];
-	asASSERT( s != 0 );
 	return CallGlobalFunctionRetPtr(s->sysFuncIntf, s, param1);
 	return CallGlobalFunctionRetPtr(s->sysFuncIntf, s, param1);
 }
 }
 
 
@@ -3169,7 +3077,6 @@ void *asCScriptEngine::CallGlobalFunctionRetPtr(asSSystemFunctionInterface *i, a
 void asCScriptEngine::CallObjectMethod(void *obj, void *param, int func)
 void asCScriptEngine::CallObjectMethod(void *obj, void *param, int func)
 {
 {
 	asCScriptFunction *s = scriptFunctions[func];
 	asCScriptFunction *s = scriptFunctions[func];
-	asASSERT( s != 0 );
 	CallObjectMethod(obj, param, s->sysFuncIntf, s);
 	CallObjectMethod(obj, param, s->sysFuncIntf, s);
 }
 }
 
 
@@ -3507,20 +3414,6 @@ void *asCScriptEngine::CreateScriptObjectCopy(void *origObj, int typeId)
 	return newObj;
 	return newObj;
 }
 }
 
 
-// internal
-void asCScriptEngine::ConstructScriptObjectCopy(void *mem, void *obj, asCObjectType *type)
-{
-	// This function is only meant to be used for value types
-	asASSERT( type->flags & asOBJ_VALUE );
-
-	// TODO: Should use the copy constructor when available
-	int funcIndex = type->beh.construct;
-	if( funcIndex )
-		CallObjectMethod(mem, funcIndex);
-
-	CopyScriptObject(mem, obj, type->GetTypeId());
-}
-
 void asCScriptEngine::CopyScriptObject(void *dstObj, void *srcObj, int typeId)
 void asCScriptEngine::CopyScriptObject(void *dstObj, void *srcObj, int typeId)
 {
 {
 	// TODO: optimize: Use the copy constructor when available
 	// TODO: optimize: Use the copy constructor when available
@@ -3763,8 +3656,6 @@ asCConfigGroup *asCScriptEngine::FindConfigGroupForFuncDef(asCScriptFunction *fu
 	return 0;
 	return 0;
 }
 }
 
 
-#ifdef AS_DEPRECATED
-// deprecated since 2011-10-04
 int asCScriptEngine::SetConfigGroupModuleAccess(const char *groupName, const char *module, bool hasAccess)
 int asCScriptEngine::SetConfigGroupModuleAccess(const char *groupName, const char *module, bool hasAccess)
 {
 {
 	asCConfigGroup *group = 0;
 	asCConfigGroup *group = 0;
@@ -3784,15 +3675,6 @@ int asCScriptEngine::SetConfigGroupModuleAccess(const char *groupName, const cha
 
 
 	return group->SetModuleAccess(module, hasAccess);
 	return group->SetModuleAccess(module, hasAccess);
 }
 }
-#endif
-
-// interface
-asDWORD asCScriptEngine::SetDefaultAccessMask(asDWORD defaultMask)
-{
-	asDWORD old = defaultAccessMask;
-	defaultAccessMask = defaultMask;
-	return old;
-}
 
 
 int asCScriptEngine::GetNextScriptFunctionId()
 int asCScriptEngine::GetNextScriptFunctionId()
 {
 {
@@ -3908,9 +3790,9 @@ int asCScriptEngine::RegisterFuncdef(const char *decl)
 }
 }
 
 
 // interface
 // interface
-asUINT asCScriptEngine::GetFuncdefCount() const
+int asCScriptEngine::GetFuncdefCount() const
 {
 {
-	return registeredFuncDefs.GetLength();
+	return (int)registeredFuncDefs.GetLength();
 }
 }
 
 
 // interface
 // interface
@@ -4007,9 +3889,9 @@ int asCScriptEngine::RegisterTypedef(const char *type, const char *decl)
 }
 }
 
 
 // interface
 // interface
-asUINT asCScriptEngine::GetTypedefCount() const
+int asCScriptEngine::GetTypedefCount() const
 {
 {
-	return registeredTypeDefs.GetLength();
+	return (int)registeredTypeDefs.GetLength();
 }
 }
 
 
 // interface
 // interface
@@ -4071,7 +3953,7 @@ int asCScriptEngine::RegisterEnum(const char *name)
 	asCDataType dataType;
 	asCDataType dataType;
 	dataType.CreatePrimitive(ttInt, false);
 	dataType.CreatePrimitive(ttInt, false);
 
 
-	st->flags = asOBJ_ENUM | asOBJ_SHARED;
+	st->flags = asOBJ_ENUM;
 	st->size = 4;
 	st->size = 4;
 	st->name = name;
 	st->name = name;
 
 
@@ -4126,9 +4008,9 @@ int asCScriptEngine::RegisterEnumValue(const char *typeName, const char *valueNa
 }
 }
 
 
 // interface
 // interface
-asUINT asCScriptEngine::GetEnumCount() const
+int asCScriptEngine::GetEnumCount() const
 {
 {
-	return registeredEnums.GetLength();
+	return (int)registeredEnums.GetLength();
 }
 }
 
 
 // interface
 // interface
@@ -4182,9 +4064,9 @@ const char *asCScriptEngine::GetEnumValueByIndex(int enumTypeId, asUINT index, i
 }
 }
 
 
 // interface
 // interface
-asUINT asCScriptEngine::GetObjectTypeCount() const
+int asCScriptEngine::GetObjectTypeCount() const
 {
 {
-	return registeredObjTypes.GetLength();
+	return (int)registeredObjTypes.GetLength();
 }
 }
 
 
 // interface
 // interface
@@ -4211,19 +4093,12 @@ asIObjectType *asCScriptEngine::GetObjectTypeById(int typeId) const
 	return dt->GetObjectType();
 	return dt->GetObjectType();
 }
 }
 
 
-// interface
-asIScriptFunction *asCScriptEngine::GetFunctionById(int funcId) const
-{
-	return GetScriptFunction(funcId);
-}
 
 
-#ifdef AS_DEPRECATED
-// deprecated since 2011-10-03
 asIScriptFunction *asCScriptEngine::GetFunctionDescriptorById(int funcId) const
 asIScriptFunction *asCScriptEngine::GetFunctionDescriptorById(int funcId) const
 {
 {
 	return GetScriptFunction(funcId);
 	return GetScriptFunction(funcId);
 }
 }
-#endif
+
 
 
 // internal
 // internal
 bool asCScriptEngine::IsTemplateType(const char *name) const
 bool asCScriptEngine::IsTemplateType(const char *name) const
@@ -4289,36 +4164,6 @@ int asCScriptEngine::GetScriptSectionNameIndex(const char *name)
 	return int(scriptSectionNames.GetLength()-1);
 	return int(scriptSectionNames.GetLength()-1);
 }
 }
 
 
-// interface 
-void asCScriptEngine::SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback)
-{
-	cleanEngineFunc = callback;
-}
-
-// interface 
-void asCScriptEngine::SetModuleUserDataCleanupCallback(asCLEANMODULEFUNC_t callback)
-{
-	cleanModuleFunc = callback;
-}
-
-// interface
-void asCScriptEngine::SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback)
-{
-	cleanContextFunc = callback;
-}
-
-// interface
-void asCScriptEngine::SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback)
-{
-	cleanFunctionFunc = callback;
-}
-
-// interface
-void asCScriptEngine::SetObjectTypeUserDataCleanupCallback(asCLEANOBJECTTYPEFUNC_t callback)
-{
-	cleanObjectTypeFunc = callback;
-}
-
 // Urho3D: modified for smaller executable size
 // Urho3D: modified for smaller executable size
 asSFuncPtr::asSFuncPtr()
 asSFuncPtr::asSFuncPtr()
 {
 {
@@ -4331,5 +4176,6 @@ asSFuncPtr::asSFuncPtr(asBYTE f)
 	flag = f;
 	flag = f;
 }
 }
 
 
+
 END_AS_NAMESPACE
 END_AS_NAMESPACE
 
 

+ 23 - 37
ThirdParty/AngelScript/source/as_scriptengine.h

@@ -96,18 +96,16 @@ public:
     virtual asIJITCompiler *GetJITCompiler() const;
     virtual asIJITCompiler *GetJITCompiler() const;
 
 
 	// Global functions
 	// Global functions
-	virtual int                RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv);
-	virtual asUINT             GetGlobalFunctionCount() const;
-	virtual int                GetGlobalFunctionIdByIndex(asUINT index) const;
-	virtual asIScriptFunction *GetGlobalFunctionByIndex(asUINT index) const;
-	virtual asIScriptFunction *GetGlobalFunctionByDecl(const char *declaration) const;
+	virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv);
+	// TODO: interface: Should return asUINT
+	virtual int GetGlobalFunctionCount() const;
+	virtual int GetGlobalFunctionIdByIndex(asUINT index) const;
 
 
 	// Global properties
 	// Global properties
-	virtual int    RegisterGlobalProperty(const char *declaration, void *pointer);
-	virtual asUINT GetGlobalPropertyCount() const;
-	// TODO: access: Return the current access mask
-	virtual int    GetGlobalPropertyByIndex(asUINT index, const char **name, int *typeId = 0, bool *isConst = 0, const char **configGroup = 0, void **pointer = 0) const;
-	// TODO: access: Allow changing the access mask
+	virtual int RegisterGlobalProperty(const char *declaration, void *pointer);
+	// TODO: interface: Should return asUINT
+	virtual int GetGlobalPropertyCount() const;
+	virtual int GetGlobalPropertyByIndex(asUINT index, const char **name, int *typeId = 0, bool *isConst = 0, const char **configGroup = 0, void **pointer = 0) const;
 	
 	
 	// Type registration
 	// Type registration
 	virtual int            RegisterObjectType(const char *obj, int byteSize, asDWORD flags);
 	virtual int            RegisterObjectType(const char *obj, int byteSize, asDWORD flags);
@@ -116,7 +114,8 @@ public:
 	virtual int            RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv);
 	virtual int            RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv);
 	virtual int            RegisterInterface(const char *name);
 	virtual int            RegisterInterface(const char *name);
 	virtual int            RegisterInterfaceMethod(const char *intf, const char *declaration);
 	virtual int            RegisterInterfaceMethod(const char *intf, const char *declaration);
-	virtual asUINT         GetObjectTypeCount() const;
+	// TODO: interface: Should return asUINT
+	virtual int            GetObjectTypeCount() const;
 	virtual asIObjectType *GetObjectTypeByIndex(asUINT index) const;
 	virtual asIObjectType *GetObjectTypeByIndex(asUINT index) const;
 	
 	
 	// String factory
 	// String factory
@@ -130,41 +129,36 @@ public:
 	// Enums
 	// Enums
 	virtual int         RegisterEnum(const char *type);
 	virtual int         RegisterEnum(const char *type);
 	virtual int         RegisterEnumValue(const char *type, const char *name, int value);
 	virtual int         RegisterEnumValue(const char *type, const char *name, int value);
-	virtual asUINT      GetEnumCount() const;
+	// TODO: interface: Should return asUINT
+	virtual int         GetEnumCount() const;
 	virtual const char *GetEnumByIndex(asUINT index, int *enumTypeId, const char **configGroup = 0) const;
 	virtual const char *GetEnumByIndex(asUINT index, int *enumTypeId, const char **configGroup = 0) const;
 	virtual int         GetEnumValueCount(int enumTypeId) const;
 	virtual int         GetEnumValueCount(int enumTypeId) const;
 	virtual const char *GetEnumValueByIndex(int enumTypeId, asUINT index, int *outValue) const;
 	virtual const char *GetEnumValueByIndex(int enumTypeId, asUINT index, int *outValue) const;
 
 
 	// Funcdefs
 	// Funcdefs
 	virtual int                RegisterFuncdef(const char *decl);
 	virtual int                RegisterFuncdef(const char *decl);
-	virtual asUINT             GetFuncdefCount() const;
+	// TODO: interface: Should return asUINT
+	virtual int                GetFuncdefCount() const;
 	virtual asIScriptFunction *GetFuncdefByIndex(asUINT index, const char **configGroup = 0) const;
 	virtual asIScriptFunction *GetFuncdefByIndex(asUINT index, const char **configGroup = 0) const;
 
 
 	// Typedefs
 	// Typedefs
 	virtual int         RegisterTypedef(const char *type, const char *decl);
 	virtual int         RegisterTypedef(const char *type, const char *decl);
-	virtual asUINT      GetTypedefCount() const;
+	// TODO: interface: Should return asUINT
+	virtual int         GetTypedefCount() const;
 	virtual const char *GetTypedefByIndex(asUINT index, int *typeId, const char **configGroup = 0) const;
 	virtual const char *GetTypedefByIndex(asUINT index, int *typeId, const char **configGroup = 0) const;
 
 
 	// Configuration groups
 	// Configuration groups
-	virtual int     BeginConfigGroup(const char *groupName);
-	virtual int     EndConfigGroup();
-	virtual int     RemoveConfigGroup(const char *groupName);
-	virtual asDWORD SetDefaultAccessMask(asDWORD defaultMask);
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-04
+	virtual int BeginConfigGroup(const char *groupName);
+	virtual int EndConfigGroup();
+	virtual int RemoveConfigGroup(const char *groupName);
 	virtual int SetConfigGroupModuleAccess(const char *groupName, const char *module, bool hasAccess);
 	virtual int SetConfigGroupModuleAccess(const char *groupName, const char *module, bool hasAccess);
-#endif
 
 
 	// Script modules
 	// Script modules
 	virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag);
 	virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag);
 	virtual int              DiscardModule(const char *module);
 	virtual int              DiscardModule(const char *module);
 
 
 	// Script functions
 	// Script functions
-	virtual asIScriptFunction *GetFunctionById(int funcId) const;
-#ifdef AS_DEPRECATED
-	// deprecated since 2011-10-03
 	virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) const;
 	virtual asIScriptFunction *GetFunctionDescriptorById(int funcId) const;
-#endif
 
 
 	// Type identification
 	// Type identification
 	virtual asIObjectType *GetObjectTypeById(int typeId) const;
 	virtual asIObjectType *GetObjectTypeById(int typeId) const;
@@ -194,10 +188,8 @@ public:
 	virtual void *SetUserData(void *data);
 	virtual void *SetUserData(void *data);
 	virtual void *GetUserData() const;
 	virtual void *GetUserData() const;
 	virtual void  SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback);
 	virtual void  SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback);
-	virtual void  SetModuleUserDataCleanupCallback(asCLEANMODULEFUNC_t callback);
 	virtual void  SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback);
 	virtual void  SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback);
 	virtual void  SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback);
 	virtual void  SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback);
-	virtual void  SetObjectTypeUserDataCleanupCallback(asCLEANOBJECTTYPEFUNC_t callback);
 
 
 //===========================================================
 //===========================================================
 // internal methods
 // internal methods
@@ -236,8 +228,6 @@ public:
 	void  CallGlobalFunction(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc);
 	void  CallGlobalFunction(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc);
 	bool  CallGlobalFunctionRetBool(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc);
 	bool  CallGlobalFunctionRetBool(void *param1, void *param2, asSSystemFunctionInterface *func, asCScriptFunction *desc);
 
 
-	void ConstructScriptObjectCopy(void *mem, void *obj, asCObjectType *type);
-
 	void ClearUnusedTypes();
 	void ClearUnusedTypes();
 	void RemoveTemplateInstanceType(asCObjectType *t);
 	void RemoveTemplateInstanceType(asCObjectType *t);
 	void RemoveTypeAndRelatedFromList(asCArray<asCObjectType*> &types, asCObjectType *ot);
 	void RemoveTypeAndRelatedFromList(asCArray<asCObjectType*> &types, asCObjectType *ot);
@@ -367,7 +357,6 @@ public:
 	asCConfigGroup             defaultGroup;
 	asCConfigGroup             defaultGroup;
 	asCArray<asCConfigGroup*>  configGroups;
 	asCArray<asCConfigGroup*>  configGroups;
 	asCConfigGroup            *currentGroup;
 	asCConfigGroup            *currentGroup;
-	asDWORD                    defaultAccessMask;
 
 
 	// Message callback
 	// Message callback
 	bool                        msgCallback;
 	bool                        msgCallback;
@@ -380,12 +369,10 @@ public:
 	asCArray<asCString*>        stringConstants;
 	asCArray<asCString*>        stringConstants;
 
 
 	// User data
 	// User data
-	void                   *userData;
-	asCLEANENGINEFUNC_t     cleanEngineFunc;
-	asCLEANMODULEFUNC_t     cleanModuleFunc;
-	asCLEANCONTEXTFUNC_t    cleanContextFunc;
-	asCLEANFUNCTIONFUNC_t   cleanFunctionFunc;
-	asCLEANOBJECTTYPEFUNC_t cleanObjectTypeFunc;
+	void                  *userData;
+	asCLEANENGINEFUNC_t    cleanEngineFunc;
+	asCLEANCONTEXTFUNC_t   cleanContextFunc;
+	asCLEANFUNCTIONFUNC_t  cleanFunctionFunc;
 
 
 	// Critical sections for threads
 	// Critical sections for threads
 	DECLARECRITICALSECTION(engineCritical);
 	DECLARECRITICALSECTION(engineCritical);
@@ -409,7 +396,6 @@ public:
 		int  propertyAccessorMode;
 		int  propertyAccessorMode;
 		bool expandDefaultArrayToTemplate;
 		bool expandDefaultArrayToTemplate;
 		bool autoGarbageCollect;
 		bool autoGarbageCollect;
-		bool disallowGlobalVars;
 	} ep;
 	} ep;
 };
 };
 
 

+ 18 - 12
ThirdParty/AngelScript/source/as_scriptfunction.cpp

@@ -143,7 +143,6 @@ asCScriptFunction::asCScriptFunction(asCScriptEngine *engine, asCModule *mod, as
 	gcFlag                 = false;
 	gcFlag                 = false;
 	userData               = 0;
 	userData               = 0;
 	id                     = 0;
 	id                     = 0;
-	accessMask             = 0xFFFFFFFF;
 
 
 	// TODO: optimize: The engine could notify the GC just before it wants to
 	// TODO: optimize: The engine could notify the GC just before it wants to
 	//                 discard the function. That way the GC won't waste time
 	//                 discard the function. That way the GC won't waste time
@@ -216,6 +215,24 @@ int asCScriptFunction::Release() const
 	return r;
 	return r;
 }
 }
 
 
+// interface 
+void asCScriptEngine::SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback)
+{
+	cleanEngineFunc = callback;
+}
+
+// interface
+void asCScriptEngine::SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback)
+{
+	cleanContextFunc = callback;
+}
+
+// interface
+void asCScriptEngine::SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback)
+{
+	cleanFunctionFunc = callback;
+}
+
 // interface
 // interface
 const char *asCScriptFunction::GetModuleName() const
 const char *asCScriptFunction::GetModuleName() const
 {
 {
@@ -277,17 +294,6 @@ int asCScriptFunction::GetSpaceNeededForReturnValue()
 	return returnType.GetSizeOnStackDWords();
 	return returnType.GetSizeOnStackDWords();
 }
 }
 
 
-// internal
-bool asCScriptFunction::DoesReturnOnStack() const
-{
-	if( returnType.GetObjectType() &&
-		(returnType.GetObjectType()->flags & asOBJ_VALUE) &&
-		!returnType.IsReference() )
-		return true;
-		
-	return false;
-}
-
 // internal
 // internal
 asCString asCScriptFunction::GetDeclarationStr(bool includeObjectName) const
 asCString asCScriptFunction::GetDeclarationStr(bool includeObjectName) const
 {
 {

+ 1 - 10
ThirdParty/AngelScript/source/as_scriptfunction.h

@@ -86,11 +86,6 @@ struct asSSystemFunctionInterface;
 //       also functions/methods that are being called. This could be used to build a 
 //       also functions/methods that are being called. This could be used to build a 
 //       code database with call graphs, etc.
 //       code database with call graphs, etc.
 
 
-// TODO: optimize: The GC should only be notified of the script function when the last module
-//                 removes it from the scope. Must make sure it is only added to the GC once
-//                 in case the function is added to another module after the GC already knows 
-//                 about the function.
-
 void RegisterScriptFunction(asCScriptEngine *engine);
 void RegisterScriptFunction(asCScriptEngine *engine);
 
 
 class asCScriptFunction : public asIScriptFunction
 class asCScriptFunction : public asIScriptFunction
@@ -114,7 +109,6 @@ public:
 	const char          *GetConfigGroup() const;
 	const char          *GetConfigGroup() const;
 	bool                 IsReadOnly() const;
 	bool                 IsReadOnly() const;
 	bool                 IsPrivate() const;
 	bool                 IsPrivate() const;
-	// TODO: access: Get/Set access mask for function
 
 
 	asUINT               GetParamCount() const;
 	asUINT               GetParamCount() const;
 	int                  GetParamTypeId(asUINT index, asDWORD *flags = 0) const;
 	int                  GetParamTypeId(asUINT index, asDWORD *flags = 0) const;
@@ -150,9 +144,7 @@ public:
 	bool      IsSignatureEqual(const asCScriptFunction *func) const;
 	bool      IsSignatureEqual(const asCScriptFunction *func) const;
 	bool      IsSignatureExceptNameEqual(const asCScriptFunction *func) const;
 	bool      IsSignatureExceptNameEqual(const asCScriptFunction *func) const;
 
 
-	bool      DoesReturnOnStack() const;
-
-	void      JITCompile();
+    void      JITCompile();
 
 
 	void      AddReferences();
 	void      AddReferences();
 	void      ReleaseReferences();
 	void      ReleaseReferences();
@@ -191,7 +183,6 @@ public:
 	int                          id;
 	int                          id;
 
 
 	asEFuncType                  funcType;
 	asEFuncType                  funcType;
-	asDWORD                      accessMask;
 
 
 	// Used by asFUNC_SCRIPT
 	// Used by asFUNC_SCRIPT
 	asCArray<asDWORD>               byteCode;
 	asCArray<asDWORD>               byteCode;

+ 4 - 3
ThirdParty/AngelScript/source/as_scriptobject.cpp

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2010 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -339,9 +339,10 @@ int asCScriptObject::GetTypeId() const
 	return objType->engine->GetTypeIdFromDataType(dt);
 	return objType->engine->GetTypeIdFromDataType(dt);
 }
 }
 
 
-asUINT asCScriptObject::GetPropertyCount() const
+int asCScriptObject::GetPropertyCount() const
 {
 {
-	return objType->properties.GetLength();
+	// TODO: interface: Should return asUINT, as the function cannot fail
+	return (int)objType->properties.GetLength();
 }
 }
 
 
 int asCScriptObject::GetPropertyTypeId(asUINT prop) const
 int asCScriptObject::GetPropertyTypeId(asUINT prop) const

+ 2 - 2
ThirdParty/AngelScript/source/as_scriptobject.h

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2010 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -68,7 +68,7 @@ public:
 	asIObjectType *GetObjectType() const;
 	asIObjectType *GetObjectType() const;
 
 
 	// Class properties
 	// Class properties
-	asUINT      GetPropertyCount() const;
+	int         GetPropertyCount() const;
 	int         GetPropertyTypeId(asUINT prop) const;
 	int         GetPropertyTypeId(asUINT prop) const;
 	const char *GetPropertyName(asUINT prop) const;
 	const char *GetPropertyName(asUINT prop) const;
 	void       *GetAddressOfProperty(asUINT prop);
 	void       *GetAddressOfProperty(asUINT prop);

+ 1 - 15
ThirdParty/AngelScript/source/as_texts.h

@@ -92,7 +92,6 @@
 #define TXT_FUNCTION_s_NOT_FOUND          "Function '%s' not found"
 #define TXT_FUNCTION_s_NOT_FOUND          "Function '%s' not found"
 
 
 #define TXT_GET_SET_ACCESSOR_TYPE_MISMATCH_FOR_s "The property '%s' has mismatching types for the get and set accessors"
 #define TXT_GET_SET_ACCESSOR_TYPE_MISMATCH_FOR_s "The property '%s' has mismatching types for the get and set accessors"
-#define TXT_GLOBAL_VARS_NOT_ALLOWED              "Global variables have been disabled by the application"
 
 
 #define TXT_HANDLE_ASSIGN_ON_NON_HANDLE_PROP     "It is not allowed to perform a handle assignment on a non-handle property"
 #define TXT_HANDLE_ASSIGN_ON_NON_HANDLE_PROP     "It is not allowed to perform a handle assignment on a non-handle property"
 #define TXT_HANDLE_COMPARISON                    "The operand is implicitly converted to handle in order to compare them"
 #define TXT_HANDLE_COMPARISON                    "The operand is implicitly converted to handle in order to compare them"
@@ -181,12 +180,6 @@
 #define TXT_REF_CANT_BE_RETURNED_DEFERRED_PARAM "Resulting reference cannot be returned. There are deferred arguments that may invalidate it."
 #define TXT_REF_CANT_BE_RETURNED_DEFERRED_PARAM "Resulting reference cannot be returned. There are deferred arguments that may invalidate it."
 #define TXT_REF_CANT_BE_RETURNED_LOCAL_VARS     "Resulting reference cannot be returned. The expression uses objects that during cleanup may invalidate it."
 #define TXT_REF_CANT_BE_RETURNED_LOCAL_VARS     "Resulting reference cannot be returned. The expression uses objects that during cleanup may invalidate it."
 
 
-#define TXT_SHARED_CANNOT_ACCESS_NON_SHARED_VAR_s      "Shared code cannot access non-shared global variable '%s'"
-#define TXT_SHARED_CANNOT_CALL_NON_SHARED_FUNC_s       "Shared code cannot call non-shared function '%s'"
-#define TXT_SHARED_CANNOT_IMPLEMENT_NON_SHARED_s       "Shared class cannot implement non-shared interface '%s'"
-#define TXT_SHARED_CANNOT_INHERIT_FROM_NON_SHARED_s    "Shared class cannot inherit from non-shared class '%s'"
-#define TXT_SHARED_CANNOT_USE_NON_SHARED_TYPE_s        "Shared code cannot use non-shared type '%s'"
-#define TXT_SHARED_DOESNT_MATCH_ORIGINAL               "Shared type doesn't match the original declaration in other module"
 #define TXT_SIGNED_UNSIGNED_MISMATCH                   "Signed/Unsigned mismatch"
 #define TXT_SIGNED_UNSIGNED_MISMATCH                   "Signed/Unsigned mismatch"
 #define TXT_STRINGS_NOT_RECOGNIZED                     "Strings are not recognized by the application"
 #define TXT_STRINGS_NOT_RECOGNIZED                     "Strings are not recognized by the application"
 #define TXT_SWITCH_CASE_MUST_BE_CONSTANT               "Case expressions must be constants"
 #define TXT_SWITCH_CASE_MUST_BE_CONSTANT               "Case expressions must be constants"
@@ -219,14 +212,7 @@
 #define TXT_NON_POD_REQUIRE_CONSTR_DESTR_BEHAVIOUR "A non-pod value type must have the default constructor and destructor behaviours"
 #define TXT_NON_POD_REQUIRE_CONSTR_DESTR_BEHAVIOUR "A non-pod value type must have the default constructor and destructor behaviours"
 #define TXT_CANNOT_PASS_TYPE_s_BY_VAL              "Can't pass type '%s' by value unless the application type is informed in the registration"
 #define TXT_CANNOT_PASS_TYPE_s_BY_VAL              "Can't pass type '%s' by value unless the application type is informed in the registration"
 #define TXT_CANNOT_RET_TYPE_s_BY_VAL               "Can't return type '%s' by value unless the application type is informed in the registration"
 #define TXT_CANNOT_RET_TYPE_s_BY_VAL               "Can't return type '%s' by value unless the application type is informed in the registration"
-#define TXT_DONT_SUPPORT_TYPE_s_BY_VAL             "Don't support passing type '%s' by value to application. Use generic calling convention instead"
-#define TXT_DONT_SUPPORT_RET_TYPE_s_BY_VAL         "Don't support returning type '%s' by value from application. Use generic calling convention instead"
-#define TXT_GC_CANNOT_FREE_OBJ_OF_TYPE_s           "GC cannot free an object of type '%s'. Make sure all types that can form circular references have the GC behaviours"
-#define TXT_OBJECT_TYPE_s_DOESNT_EXIST             "Object type '%s' doesn't exist"
-#define TXT_TEMPLATE_TYPE_s_DOESNT_EXIST           "Template type '%s' doesn't exist"
-#define TXT_TEMPLATE_SUBTYPE_s_DOESNT_EXIST        "Template subtype '%s' doesn't exist"
-#define TXT_FAILED_READ_SUBTYPE_OF_TEMPLATE_s      "Failed to read subtype of template type '%s'"
-#define TXT_INSTANCING_INVLD_TMPL_TYPE_s_s         "Attempting to instanciate invalid template type '%s<%s>'"
+#define TXT_DONT_SUPPORT_TYPE_s_BY_VAL             "Don't support passing type '%s' by value to application"
 
 
 // Internal names
 // Internal names
 
 

+ 4 - 5
ThirdParty/AngelScript/source/as_tokendef.h

@@ -1,6 +1,6 @@
 /*
 /*
    AngelCode Scripting Library
    AngelCode Scripting Library
-   Copyright (c) 2003-2011 Andreas Jonsson
+   Copyright (c) 2003-2010 Andreas Jonsson
 
 
    This software is provided 'as-is', without any express or implied 
    This software is provided 'as-is', without any express or implied 
    warranty. In no event will the authors be held liable for any 
    warranty. In no event will the authors be held liable for any 
@@ -285,10 +285,9 @@ const unsigned int numTokenWords = sizeof(tokenWords)/sizeof(sTokenWord);
 const char * const whiteSpace = " \t\r\n";
 const char * const whiteSpace = " \t\r\n";
 
 
 // Some keywords that are not considered tokens by the parser
 // Some keywords that are not considered tokens by the parser
-const char * const THIS_TOKEN   = "this";
-const char * const FROM_TOKEN   = "from";
-const char * const SUPER_TOKEN  = "super";
-const char * const SHARED_TOKEN = "shared";
+const char * const THIS_TOKEN = "this";
+const char * const FROM_TOKEN = "from";
+const char * const SUPER_TOKEN = "super";
 
 
 END_AS_NAMESPACE
 END_AS_NAMESPACE