Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wireplumber
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
wireplumber
Commits
067da200
Commit
067da200
authored
4 years ago
by
George Kiagiadakis
Browse files
Options
Downloads
Patches
Plain Diff
wplua: use the error handler also when loading chunks
... and improve its output
parent
0054559b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/wplua/closure.c
+2
-42
2 additions, 42 deletions
lib/wplua/closure.c
lib/wplua/private.h
+3
-0
3 additions, 0 deletions
lib/wplua/private.h
lib/wplua/wplua.c
+39
-3
39 additions, 3 deletions
lib/wplua/wplua.c
with
44 additions
and
45 deletions
lib/wplua/closure.c
+
2
−
42
View file @
067da200
...
...
@@ -7,6 +7,7 @@
*/
#include
"wplua.h"
#include
"private.h"
#include
<wp/wp.h>
typedef
struct
_WpLuaClosure
WpLuaClosure
;
...
...
@@ -16,47 +17,6 @@ struct _WpLuaClosure
int
func_ref
;
};
static
int
_wplua_closure_errhandler
(
lua_State
*
L
)
{
wp_warning
(
"%s"
,
lua_tostring
(
L
,
-
1
));
lua_pop
(
L
,
1
);
luaL_traceback
(
L
,
L
,
"traceback:
\n
"
,
1
);
wp_warning
(
"%s"
,
lua_tostring
(
L
,
-
1
));
lua_pop
(
L
,
1
);
return
0
;
}
static
int
_wplua_closure_pcall
(
lua_State
*
L
,
int
nargs
,
int
nret
)
{
int
hpos
=
lua_gettop
(
L
)
-
nargs
;
int
ret
=
LUA_OK
;
lua_pushcfunction
(
L
,
_wplua_closure_errhandler
);
lua_insert
(
L
,
hpos
);
ret
=
lua_pcall
(
L
,
nargs
,
nret
,
hpos
);
switch
(
ret
)
{
case
LUA_ERRMEM
:
wp_critical
(
"not enough memory"
);
break
;
case
LUA_ERRERR
:
wp_critical
(
"error running the message handler"
);
break
;
case
LUA_ERRGCMM
:
wp_critical
(
"error running __gc"
);
break
;
default:
break
;
}
lua_remove
(
L
,
hpos
);
return
ret
;
}
static
void
_wplua_closure_marshal
(
GClosure
*
closure
,
GValue
*
return_value
,
guint
n_param_values
,
const
GValue
*
param_values
,
...
...
@@ -81,7 +41,7 @@ _wplua_closure_marshal (GClosure *closure, GValue *return_value,
wplua_gvalue_to_lua
(
L
,
&
param_values
[
i
]);
/* call in protected mode */
int
res
=
_wplua_
closure_
pcall
(
L
,
n_param_values
,
return_value
?
1
:
0
);
int
res
=
_wplua_pcall
(
L
,
n_param_values
,
return_value
?
1
:
0
);
/* handle the result */
if
(
res
==
LUA_OK
&&
return_value
&&
lua_gettop
(
L
)
>=
1
)
...
...
This diff is collapsed.
Click to expand it.
lib/wplua/private.h
+
3
−
0
View file @
067da200
...
...
@@ -29,6 +29,9 @@ gboolean _wplua_isgvalue_userdata (lua_State *L, int idx, GType type);
int
_wplua_gvalue_userdata___gc
(
lua_State
*
L
);
int
_wplua_gvalue_userdata___eq
(
lua_State
*
L
);
/* wplua.c */
int
_wplua_pcall
(
lua_State
*
L
,
int
nargs
,
int
nret
);
G_END_DECLS
#endif
This diff is collapsed.
Click to expand it.
lib/wplua/wplua.c
+
39
−
3
View file @
067da200
...
...
@@ -42,6 +42,43 @@ _wplua_openlibs (lua_State *L)
}
}
static
int
_wplua_errhandler
(
lua_State
*
L
)
{
luaL_traceback
(
L
,
L
,
NULL
,
1
);
wp_warning
(
"%s
\n
%s"
,
lua_tostring
(
L
,
-
2
),
lua_tostring
(
L
,
-
1
));
lua_pop
(
L
,
2
);
return
0
;
}
int
_wplua_pcall
(
lua_State
*
L
,
int
nargs
,
int
nret
)
{
int
hpos
=
lua_gettop
(
L
)
-
nargs
;
int
ret
=
LUA_OK
;
lua_pushcfunction
(
L
,
_wplua_errhandler
);
lua_insert
(
L
,
hpos
);
ret
=
lua_pcall
(
L
,
nargs
,
nret
,
hpos
);
switch
(
ret
)
{
case
LUA_ERRMEM
:
wp_critical
(
"not enough memory"
);
break
;
case
LUA_ERRERR
:
wp_critical
(
"error running the message handler"
);
break
;
case
LUA_ERRGCMM
:
wp_critical
(
"error running __gc"
);
break
;
default:
break
;
}
lua_remove
(
L
,
hpos
);
return
ret
;
}
lua_State
*
wplua_new
(
void
)
{
...
...
@@ -152,11 +189,10 @@ _wplua_load_buffer (lua_State * L, const gchar *buf, gsize size,
return
FALSE
;
}
ret
=
lua_pcall
(
L
,
sandbox
,
0
,
0
);
ret
=
_wp
lua_pcall
(
L
,
sandbox
,
0
);
if
(
ret
!=
LUA_OK
)
{
g_set_error
(
error
,
WP_DOMAIN_LUA
,
WP_LUA_ERROR_RUNTIME
,
"Failed to run: %s"
,
lua_tostring
(
L
,
-
1
));
lua_pop
(
L
,
1
);
"Runtime error while loading '%s'"
,
name
);
return
FALSE
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment