packages feed

hslua-objectorientation 2.0.0 → 2.0.1

raw patch · 5 files changed

+40/−6 lines, 5 filesdep ~hslua-marshallingPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hslua-marshalling

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -2,9 +2,19 @@  `hslua-objectorientation` uses [PVP Versioning][1]. -## hslua-objectorientation 1.0.0+## hslua-objectorientation 2.0.1 -Release pending.+Release 2021-11-04.++  - Excludes absent properties from `pairs`: Properties that are+    optional and not present in a sum-type value are no longer+    included in the iterator output produced by `pairs` (i.e., the+    `__pairs` metamethod). Previously, the names of absent+    properties were pushed with a `nil` value.++## hslua-objectorientation 2.0.0++Release 2021-10-21.  - Published without warning. 
cbits/hslobj.c view
@@ -98,8 +98,9 @@    * list of properties is the second object. */   for (int i = 1; i <= lua_rawlen(L, -2); i++) {     lua_rawgeti(L, -2, i);-    lua_gettable(L, -2);  /* get property */+    int objtype = lua_gettable(L, -2);  /* get property */     lua_remove(L, -2);    /* remove previous object */+    if (!objtype) break;  /* abort if this property of the alias is absent */   }   return 1; }
hslua-objectorientation.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                hslua-objectorientation-version:             2.0.0+version:             2.0.1 synopsis:            Object orientation tools for HsLua description:         Expose Haskell objects to Lua with an object oriented                      interface.@@ -35,7 +35,7 @@                      , containers        >= 0.5.9  && < 0.7                      , exceptions        >= 0.8    && < 0.11                      , hslua-core        >= 2.0    && < 2.1-                     , hslua-marshalling >= 2.0    && < 2.1+                     , hslua-marshalling >= 2.0.1  && < 2.1                      , mtl               >= 2.2    && < 2.3                      , text              >= 1.0    && < 1.3   ghc-options:         -Wall
src/HsLua/ObjectOrientation.hs view
@@ -313,7 +313,9 @@         MemberProperty name prop -> do           pushName name           getresults <- propertyGet prop obj-          return $ getresults + 1+          if getresults == 0+            then 0 <$ pop 1  -- property is absent, don't push anything+            else return $ getresults + 1         MemberMethod name f -> do           pushName name           udFnPusher ty f
test/HsLua/ObjectOrientationTests.hs view
@@ -134,6 +134,19 @@           , "return result"           ]         forcePeek $ peekList peekText top++    , "absent properties are not included in `pairs`" =:+      [("num", "number"), ("str", "string"), ("show", "function")]+      `shouldBeResultOf` do+        openlibs+        pushUD typeQux $ Quux 1 "a"+        setglobal "a"+        OK <- dostring $ Char8.unlines+          [ "local result = {}"+          , "for k, v in pairs(a) do result[#result+1] = {k, type(v)} end"+          , "return result"+          ]+        forcePeek $ peekList (peekPair peekText peekText) top     ]    , testGroup "Bar type"@@ -240,6 +253,14 @@           -- msg <- forcePeek $ peekString top           -- liftIO $ putStrLn msg           forcePeek $ peekPoint top+      , "absent alias returns `nil`" =:+        TypeNil `shouldBeResultOf` do+          openlibs+          pushUD typeQux (Quux 9 "to five")+          setglobal "quux"+          dostring "return quux.x" >>= \case+            OK -> ltype top+            _ -> failLua =<< forcePeek (peekString top)       ]     ]   ]