Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
NLua
Commits
e2fd560d
Commit
e2fd560d
authored
Nov 13, 2013
by
Vinicius Jarina
Browse files
Fix #45 support for com objects (update with com.lua from @prabirshrestha)
parent
7e8c165a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Samples/com.lua
View file @
e2fd560d
--require 'luanet'
require
'CLRPackage'
import
'System'
import
'System'
import
'System.Reflection'
import
'System.Reflection'
local
get_flags
=
luanet
.
enum
(
BindingFlags
,
'GetProperty,IgnoreCase,Public'
)
local
get_flags
=
luanet
.
enum
(
BindingFlags
,
'GetProperty,IgnoreCase,Public'
)
...
@@ -36,19 +34,12 @@ function com_wrapper(obj)
...
@@ -36,19 +34,12 @@ function com_wrapper(obj)
local
T
=
obj
:
GetType
()
local
T
=
obj
:
GetType
()
return
setmetatable
({},{
return
setmetatable
({},{
__index
=
function
(
self
,
key
)
__index
=
function
(
self
,
key
)
local
ok
,
res
=
pcall
(
T
.
InvokeMember
,
T
,
key
,
get_flags
,
nil
,
obj
,
empty
)
local
ok
,
res
=
pcall
(
T
.
InvokeMember
,
T
,
key
,
get_flags
,
nil
,
obj
,
empty
)
if
not
ok
then
if
ok
then
res
=
tostring
(
res
)
return
maybe_wrap
(
res
)
if
res
:
match
'Member not found'
then
else
return
caller
(
obj
,
key
)
--local c =
return
caller
(
obj
,
key
)
--~ rawset(self,key,c)
end
--~ return c
else
error
(
"cannot find "
..
key
,
2
)
end
else
return
maybe_wrap
(
res
)
end
end
;
end
;
__newindex
=
function
(
self
,
key
,
value
)
__newindex
=
function
(
self
,
key
,
value
)
T
:
InvokeMember
(
key
,
put_flags
,
nil
,
A
{
value
})
T
:
InvokeMember
(
key
,
put_flags
,
nil
,
A
{
value
})
...
@@ -66,4 +57,4 @@ end
...
@@ -66,4 +57,4 @@ end
com
.
wrap
=
maybe_wrap
com
.
wrap
=
maybe_wrap
return
com
return
com
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment