Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/mujs/mujs.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 #ifndef mujs_h | |
| 2 #define mujs_h | |
| 3 | |
| 4 #include <setjmp.h> /* required for setjmp in fz_try macro */ | |
| 5 | |
| 6 #ifdef __cplusplus | |
| 7 extern "C" { | |
| 8 #endif | |
| 9 | |
| 10 #define JS_VERSION_MAJOR 1 | |
| 11 #define JS_VERSION_MINOR 3 | |
| 12 #define JS_VERSION_PATCH 5 | |
| 13 | |
| 14 #define JS_VERSION (JS_VERSION_MAJOR * 10000 + JS_VERSION_MINOR * 100 + JS_VERSION_PATCH) | |
| 15 #define JS_CHECKVERSION(x,y,z) (JS_VERSION >= ((x) * 10000 + (y) * 100 + (z))) | |
| 16 | |
| 17 /* noreturn is a GCC extension */ | |
| 18 #ifdef __GNUC__ | |
| 19 #define JS_NORETURN __attribute__((noreturn)) | |
| 20 #else | |
| 21 #ifdef _MSC_VER | |
| 22 #define JS_NORETURN __declspec(noreturn) | |
| 23 #else | |
| 24 #define JS_NORETURN | |
| 25 #endif | |
| 26 #endif | |
| 27 | |
| 28 /* GCC can do type checking of printf strings */ | |
| 29 #ifdef __printflike | |
| 30 #define JS_PRINTFLIKE __printflike | |
| 31 #else | |
| 32 #if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7 | |
| 33 #define JS_PRINTFLIKE(fmtarg, firstvararg) \ | |
| 34 __attribute__((__format__ (__printf__, fmtarg, firstvararg))) | |
| 35 #else | |
| 36 #define JS_PRINTFLIKE(fmtarg, firstvararg) | |
| 37 #endif | |
| 38 #endif | |
| 39 | |
| 40 typedef struct js_State js_State; | |
| 41 | |
| 42 typedef void *(*js_Alloc)(void *memctx, void *ptr, int size); | |
| 43 typedef void (*js_Panic)(js_State *J); | |
| 44 typedef void (*js_CFunction)(js_State *J); | |
| 45 typedef void (*js_Finalize)(js_State *J, void *p); | |
| 46 typedef int (*js_HasProperty)(js_State *J, void *p, const char *name); | |
| 47 typedef int (*js_Put)(js_State *J, void *p, const char *name); | |
| 48 typedef int (*js_Delete)(js_State *J, void *p, const char *name); | |
| 49 typedef void (*js_Report)(js_State *J, const char *message); | |
| 50 | |
| 51 /* Basic functions */ | |
| 52 js_State *js_newstate(js_Alloc alloc, void *actx, int flags); | |
| 53 void js_setcontext(js_State *J, void *uctx); | |
| 54 void *js_getcontext(js_State *J); | |
| 55 void js_setreport(js_State *J, js_Report report); | |
| 56 js_Panic js_atpanic(js_State *J, js_Panic panic); | |
| 57 void js_freestate(js_State *J); | |
| 58 void js_gc(js_State *J, int report); | |
| 59 | |
| 60 int js_dostring(js_State *J, const char *source); | |
| 61 int js_dofile(js_State *J, const char *filename); | |
| 62 int js_ploadstring(js_State *J, const char *filename, const char *source); | |
| 63 int js_ploadfile(js_State *J, const char *filename); | |
| 64 int js_pcall(js_State *J, int n); | |
| 65 int js_pconstruct(js_State *J, int n); | |
| 66 | |
| 67 /* Exception handling */ | |
| 68 | |
| 69 void *js_savetry(js_State *J); /* returns a jmp_buf */ | |
| 70 | |
| 71 #define js_try(J) \ | |
| 72 setjmp(js_savetry(J)) | |
| 73 | |
| 74 void js_endtry(js_State *J); | |
| 75 | |
| 76 /* State constructor flags */ | |
| 77 enum { | |
| 78 JS_STRICT = 1, | |
| 79 }; | |
| 80 | |
| 81 /* RegExp flags */ | |
| 82 enum { | |
| 83 JS_REGEXP_G = 1, | |
| 84 JS_REGEXP_I = 2, | |
| 85 JS_REGEXP_M = 4, | |
| 86 }; | |
| 87 | |
| 88 /* Property attribute flags */ | |
| 89 enum { | |
| 90 JS_READONLY = 1, | |
| 91 JS_DONTENUM = 2, | |
| 92 JS_DONTCONF = 4, | |
| 93 }; | |
| 94 | |
| 95 /* enum for js_type() */ | |
| 96 enum { | |
| 97 JS_ISUNDEFINED, | |
| 98 JS_ISNULL, | |
| 99 JS_ISBOOLEAN, | |
| 100 JS_ISNUMBER, | |
| 101 JS_ISSTRING, | |
| 102 JS_ISFUNCTION, | |
| 103 JS_ISOBJECT | |
| 104 }; | |
| 105 | |
| 106 void js_report(js_State *J, const char *message); | |
| 107 | |
| 108 void js_newerror(js_State *J, const char *message); | |
| 109 void js_newevalerror(js_State *J, const char *message); | |
| 110 void js_newrangeerror(js_State *J, const char *message); | |
| 111 void js_newreferenceerror(js_State *J, const char *message); | |
| 112 void js_newsyntaxerror(js_State *J, const char *message); | |
| 113 void js_newtypeerror(js_State *J, const char *message); | |
| 114 void js_newurierror(js_State *J, const char *message); | |
| 115 | |
| 116 JS_NORETURN void js_error(js_State *J, const char *fmt, ...) JS_PRINTFLIKE(2,3); | |
| 117 JS_NORETURN void js_evalerror(js_State *J, const char *fmt, ...) JS_PRINTFLIKE(2,3); | |
| 118 JS_NORETURN void js_rangeerror(js_State *J, const char *fmt, ...) JS_PRINTFLIKE(2,3); | |
| 119 JS_NORETURN void js_referenceerror(js_State *J, const char *fmt, ...) JS_PRINTFLIKE(2,3); | |
| 120 JS_NORETURN void js_syntaxerror(js_State *J, const char *fmt, ...) JS_PRINTFLIKE(2,3); | |
| 121 JS_NORETURN void js_typeerror(js_State *J, const char *fmt, ...) JS_PRINTFLIKE(2,3); | |
| 122 JS_NORETURN void js_urierror(js_State *J, const char *fmt, ...) JS_PRINTFLIKE(2,3); | |
| 123 JS_NORETURN void js_throw(js_State *J); | |
| 124 | |
| 125 void js_loadstring(js_State *J, const char *filename, const char *source); | |
| 126 void js_loadfile(js_State *J, const char *filename); | |
| 127 | |
| 128 void js_eval(js_State *J); | |
| 129 void js_call(js_State *J, int n); | |
| 130 void js_construct(js_State *J, int n); | |
| 131 | |
| 132 const char *js_ref(js_State *J); | |
| 133 void js_unref(js_State *J, const char *ref); | |
| 134 | |
| 135 void js_getregistry(js_State *J, const char *name); | |
| 136 void js_setregistry(js_State *J, const char *name); | |
| 137 void js_delregistry(js_State *J, const char *name); | |
| 138 | |
| 139 void js_getglobal(js_State *J, const char *name); | |
| 140 void js_setglobal(js_State *J, const char *name); | |
| 141 void js_defglobal(js_State *J, const char *name, int atts); | |
| 142 void js_delglobal(js_State *J, const char *name); | |
| 143 | |
| 144 int js_hasproperty(js_State *J, int idx, const char *name); | |
| 145 void js_getproperty(js_State *J, int idx, const char *name); | |
| 146 void js_setproperty(js_State *J, int idx, const char *name); | |
| 147 void js_defproperty(js_State *J, int idx, const char *name, int atts); | |
| 148 void js_delproperty(js_State *J, int idx, const char *name); | |
| 149 void js_defaccessor(js_State *J, int idx, const char *name, int atts); | |
| 150 | |
| 151 int js_getlength(js_State *J, int idx); | |
| 152 void js_setlength(js_State *J, int idx, int len); | |
| 153 int js_hasindex(js_State *J, int idx, int i); | |
| 154 void js_getindex(js_State *J, int idx, int i); | |
| 155 void js_setindex(js_State *J, int idx, int i); | |
| 156 void js_delindex(js_State *J, int idx, int i); | |
| 157 | |
| 158 void js_currentfunction(js_State *J); | |
| 159 void *js_currentfunctiondata(js_State *J); | |
| 160 void js_pushglobal(js_State *J); | |
| 161 void js_pushundefined(js_State *J); | |
| 162 void js_pushnull(js_State *J); | |
| 163 void js_pushboolean(js_State *J, int v); | |
| 164 void js_pushnumber(js_State *J, double v); | |
| 165 void js_pushstring(js_State *J, const char *v); | |
| 166 void js_pushlstring(js_State *J, const char *v, int n); | |
| 167 void js_pushliteral(js_State *J, const char *v); | |
| 168 | |
| 169 void js_newobjectx(js_State *J); | |
| 170 void js_newobject(js_State *J); | |
| 171 void js_newarray(js_State *J); | |
| 172 void js_newboolean(js_State *J, int v); | |
| 173 void js_newnumber(js_State *J, double v); | |
| 174 void js_newstring(js_State *J, const char *v); | |
| 175 void js_newcfunction(js_State *J, js_CFunction fun, const char *name, int length); | |
| 176 void js_newcfunctionx(js_State *J, js_CFunction fun, const char *name, int length, void *data, js_Finalize finalize); | |
| 177 void js_newcconstructor(js_State *J, js_CFunction fun, js_CFunction con, const char *name, int length); | |
| 178 void js_newuserdata(js_State *J, const char *tag, void *data, js_Finalize finalize); | |
| 179 void js_newuserdatax(js_State *J, const char *tag, void *data, js_HasProperty has, js_Put put, js_Delete del, js_Finalize finalize); | |
| 180 void js_newregexp(js_State *J, const char *pattern, int flags); | |
| 181 | |
| 182 void js_pushiterator(js_State *J, int idx, int own); | |
| 183 const char *js_nextiterator(js_State *J, int idx); | |
| 184 | |
| 185 int js_isdefined(js_State *J, int idx); | |
| 186 int js_isundefined(js_State *J, int idx); | |
| 187 int js_isnull(js_State *J, int idx); | |
| 188 int js_isboolean(js_State *J, int idx); | |
| 189 int js_isnumber(js_State *J, int idx); | |
| 190 int js_isstring(js_State *J, int idx); | |
| 191 int js_isprimitive(js_State *J, int idx); | |
| 192 int js_isobject(js_State *J, int idx); | |
| 193 int js_isarray(js_State *J, int idx); | |
| 194 int js_isregexp(js_State *J, int idx); | |
| 195 int js_iscoercible(js_State *J, int idx); | |
| 196 int js_iscallable(js_State *J, int idx); | |
| 197 int js_isuserdata(js_State *J, int idx, const char *tag); | |
| 198 int js_iserror(js_State *J, int idx); | |
| 199 int js_isnumberobject(js_State *J, int idx); | |
| 200 int js_isstringobject(js_State *J, int idx); | |
| 201 int js_isbooleanobject(js_State *J, int idx); | |
| 202 int js_isdateobject(js_State *J, int idx); | |
| 203 | |
| 204 int js_toboolean(js_State *J, int idx); | |
| 205 double js_tonumber(js_State *J, int idx); | |
| 206 const char *js_tostring(js_State *J, int idx); | |
| 207 void *js_touserdata(js_State *J, int idx, const char *tag); | |
| 208 | |
| 209 const char *js_trystring(js_State *J, int idx, const char *error); | |
| 210 double js_trynumber(js_State *J, int idx, double error); | |
| 211 int js_tryinteger(js_State *J, int idx, int error); | |
| 212 int js_tryboolean(js_State *J, int idx, int error); | |
| 213 | |
| 214 int js_tointeger(js_State *J, int idx); | |
| 215 int js_toint32(js_State *J, int idx); | |
| 216 unsigned int js_touint32(js_State *J, int idx); | |
| 217 short js_toint16(js_State *J, int idx); | |
| 218 unsigned short js_touint16(js_State *J, int idx); | |
| 219 | |
| 220 int js_gettop(js_State *J); | |
| 221 void js_pop(js_State *J, int n); | |
| 222 void js_rot(js_State *J, int n); | |
| 223 void js_copy(js_State *J, int idx); | |
| 224 void js_remove(js_State *J, int idx); | |
| 225 void js_insert(js_State *J, int idx); | |
| 226 void js_replace(js_State* J, int idx); | |
| 227 | |
| 228 void js_dup(js_State *J); | |
| 229 void js_dup2(js_State *J); | |
| 230 void js_rot2(js_State *J); | |
| 231 void js_rot3(js_State *J); | |
| 232 void js_rot4(js_State *J); | |
| 233 void js_rot2pop1(js_State *J); | |
| 234 void js_rot3pop2(js_State *J); | |
| 235 | |
| 236 void js_concat(js_State *J); | |
| 237 int js_compare(js_State *J, int *okay); | |
| 238 int js_equal(js_State *J); | |
| 239 int js_strictequal(js_State *J); | |
| 240 int js_instanceof(js_State *J); | |
| 241 const char *js_typeof(js_State *J, int idx); | |
| 242 int js_type(js_State *J, int idx); | |
| 243 | |
| 244 void js_repr(js_State *J, int idx); | |
| 245 const char *js_torepr(js_State *J, int idx); | |
| 246 const char *js_tryrepr(js_State *J, int idx, const char *error); | |
| 247 | |
| 248 #ifdef __cplusplus | |
| 249 } | |
| 250 #endif | |
| 251 | |
| 252 #endif |
