1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ 2 /* 3 * Copyright (c) 2010 litl, LLC 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * of this software and associated documentation files (the "Software"), to 7 * deal in the Software without restriction, including without limitation the 8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 * sell copies of the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24 #ifndef GI_FOREIGN_H_ 25 #define GI_FOREIGN_H_ 26 27 #include <config.h> 28 29 #include <girepository.h> 30 31 #include <js/RootingAPI.h> 32 #include <js/TypeDecls.h> 33 #include <js/Value.h> 34 35 #include "gi/arg.h" 36 #include "cjs/macros.h" 37 38 typedef bool (*GjsArgOverrideToGArgumentFunc) (JSContext *context, 39 JS::Value value, 40 const char *arg_name, 41 GjsArgumentType argument_type, 42 GITransfer transfer, 43 bool may_be_null, 44 GArgument *arg); 45 46 typedef bool (*GjsArgOverrideFromGArgumentFunc) (JSContext *context, 47 JS::MutableHandleValue value_p, 48 GIArgument *arg); 49 50 typedef bool (*GjsArgOverrideReleaseGArgumentFunc) (JSContext *context, 51 GITransfer transfer, 52 GArgument *arg); 53 54 typedef struct { 55 GjsArgOverrideToGArgumentFunc to_func; 56 GjsArgOverrideFromGArgumentFunc from_func; 57 GjsArgOverrideReleaseGArgumentFunc release_func; 58 } GjsForeignInfo; 59 60 void gjs_struct_foreign_register(const char* gi_namespace, 61 const char* type_name, GjsForeignInfo* info); 62 63 GJS_JSAPI_RETURN_CONVENTION 64 bool gjs_struct_foreign_convert_to_g_argument (JSContext *context, 65 JS::Value value, 66 GIBaseInfo *interface_info, 67 const char *arg_name, 68 GjsArgumentType argument_type, 69 GITransfer transfer, 70 bool may_be_null, 71 GArgument *arg); 72 GJS_JSAPI_RETURN_CONVENTION 73 bool gjs_struct_foreign_convert_from_g_argument(JSContext *context, 74 JS::MutableHandleValue value_p, 75 GIBaseInfo *interface_info, 76 GIArgument *arg); 77 78 GJS_JSAPI_RETURN_CONVENTION 79 bool gjs_struct_foreign_release_g_argument (JSContext *context, 80 GITransfer transfer, 81 GIBaseInfo *interface_info, 82 GArgument *arg); 83 84 #endif // GI_FOREIGN_H_ 85