• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright JS Foundation and other contributors, http://js.foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "jerryscript-ext/handler.h"
17 
18 /**
19  * Get the resource name (usually a file name) of the currently executed script or the given function object
20  *
21  * Note: returned value must be freed with jerry_release_value, when it is no longer needed
22  *
23  * @return JS string constructed from
24  *         - the currently executed function object's resource name, if the given value is undefined
25  *         - resource name of the function object, if the given value is a function object
26  *         - "<anonymous>", otherwise
27  */
28 jerry_value_t
jerryx_handler_resource_name(const jerry_value_t func_obj_val,const jerry_value_t this_p,const jerry_value_t args_p[],const jerry_length_t args_cnt)29 jerryx_handler_resource_name (const jerry_value_t func_obj_val, /**< function object */
30                               const jerry_value_t this_p, /**< this arg */
31                               const jerry_value_t args_p[], /**< function arguments */
32                               const jerry_length_t args_cnt) /**< number of function arguments */
33 {
34   (void) func_obj_val; /* unused */
35   (void) this_p; /* unused */
36 
37   jerry_value_t undefined_value = jerry_create_undefined ();
38   jerry_value_t resource_name = jerry_get_resource_name (args_cnt > 0 ? args_p[0] : undefined_value);
39   jerry_release_value (undefined_value);
40 
41   return resource_name;
42 } /* jerryx_handler_resource_name */
43