append(): Fixing the test for convertability after consultation with
[python/dscho.git] / Mac / Modules / htmlrender / HtmlRendermodule.c
blob08df21f3c34888287cd40e9a2e7811bfb19458dc
2 /* ======================= Module HtmlRender ======================== */
4 #include "Python.h"
8 #define SystemSevenOrLater 1
10 #include "macglue.h"
11 #include <Memory.h>
12 #include <Dialogs.h>
13 #include <Menus.h>
14 #include <Controls.h>
16 extern PyObject *ResObj_New(Handle);
17 extern int ResObj_Convert(PyObject *, Handle *);
18 extern PyObject *OptResObj_New(Handle);
19 extern int OptResObj_Convert(PyObject *, Handle *);
21 extern PyObject *WinObj_New(WindowPtr);
22 extern int WinObj_Convert(PyObject *, WindowPtr *);
23 extern PyTypeObject Window_Type;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject *DlgObj_New(DialogPtr);
27 extern int DlgObj_Convert(PyObject *, DialogPtr *);
28 extern PyTypeObject Dialog_Type;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject *MenuObj_New(MenuHandle);
32 extern int MenuObj_Convert(PyObject *, MenuHandle *);
34 extern PyObject *CtlObj_New(ControlHandle);
35 extern int CtlObj_Convert(PyObject *, ControlHandle *);
37 extern PyObject *GrafObj_New(GrafPtr);
38 extern int GrafObj_Convert(PyObject *, GrafPtr *);
40 extern PyObject *BMObj_New(BitMapPtr);
41 extern int BMObj_Convert(PyObject *, BitMapPtr *);
43 extern PyObject *WinObj_WhichWindow(WindowPtr);
45 #include <HTMLRendering.h>
47 static PyObject *Html_Error;
49 /* --------------------- Object type HtmlObject --------------------- */
51 PyTypeObject HtmlObject_Type;
53 #define HtmlObj_Check(x) ((x)->ob_type == &HtmlObject_Type)
55 typedef struct HtmlObjectObject {
56 PyObject_HEAD
57 HRReference ob_itself;
58 } HtmlObjectObject;
60 PyObject *HtmlObj_New(itself)
61 HRReference itself;
63 HtmlObjectObject *it;
64 it = PyObject_NEW(HtmlObjectObject, &HtmlObject_Type);
65 if (it == NULL) return NULL;
66 it->ob_itself = itself;
67 return (PyObject *)it;
69 HtmlObj_Convert(v, p_itself)
70 PyObject *v;
71 HRReference *p_itself;
73 if (!HtmlObj_Check(v))
75 PyErr_SetString(PyExc_TypeError, "HtmlObject required");
76 return 0;
78 *p_itself = ((HtmlObjectObject *)v)->ob_itself;
79 return 1;
82 static void HtmlObj_dealloc(self)
83 HtmlObjectObject *self;
85 /* Cleanup of self->ob_itself goes here */
86 PyObject_DEL(self);
89 static PyObject *HtmlObj_HRDisposeReference(_self, _args)
90 HtmlObjectObject *_self;
91 PyObject *_args;
93 PyObject *_res = NULL;
94 OSStatus _err;
95 if (!PyArg_ParseTuple(_args, ""))
96 return NULL;
97 _err = HRDisposeReference(_self->ob_itself);
98 if (_err != noErr) return PyMac_Error(_err);
99 Py_INCREF(Py_None);
100 _res = Py_None;
101 return _res;
104 static PyObject *HtmlObj_HRSetGrafPtr(_self, _args)
105 HtmlObjectObject *_self;
106 PyObject *_args;
108 PyObject *_res = NULL;
109 OSStatus _err;
110 GrafPtr grafPtr;
111 if (!PyArg_ParseTuple(_args, "O&",
112 GrafObj_Convert, &grafPtr))
113 return NULL;
114 _err = HRSetGrafPtr(_self->ob_itself,
115 grafPtr);
116 if (_err != noErr) return PyMac_Error(_err);
117 Py_INCREF(Py_None);
118 _res = Py_None;
119 return _res;
122 static PyObject *HtmlObj_HRActivate(_self, _args)
123 HtmlObjectObject *_self;
124 PyObject *_args;
126 PyObject *_res = NULL;
127 OSStatus _err;
128 if (!PyArg_ParseTuple(_args, ""))
129 return NULL;
130 _err = HRActivate(_self->ob_itself);
131 if (_err != noErr) return PyMac_Error(_err);
132 Py_INCREF(Py_None);
133 _res = Py_None;
134 return _res;
137 static PyObject *HtmlObj_HRDeactivate(_self, _args)
138 HtmlObjectObject *_self;
139 PyObject *_args;
141 PyObject *_res = NULL;
142 OSStatus _err;
143 if (!PyArg_ParseTuple(_args, ""))
144 return NULL;
145 _err = HRDeactivate(_self->ob_itself);
146 if (_err != noErr) return PyMac_Error(_err);
147 Py_INCREF(Py_None);
148 _res = Py_None;
149 return _res;
152 static PyObject *HtmlObj_HRDraw(_self, _args)
153 HtmlObjectObject *_self;
154 PyObject *_args;
156 PyObject *_res = NULL;
157 OSStatus _err;
158 RgnHandle updateRgnH;
159 if (!PyArg_ParseTuple(_args, "O&",
160 ResObj_Convert, &updateRgnH))
161 return NULL;
162 _err = HRDraw(_self->ob_itself,
163 updateRgnH);
164 if (_err != noErr) return PyMac_Error(_err);
165 Py_INCREF(Py_None);
166 _res = Py_None;
167 return _res;
170 static PyObject *HtmlObj_HRSetRenderingRect(_self, _args)
171 HtmlObjectObject *_self;
172 PyObject *_args;
174 PyObject *_res = NULL;
175 OSStatus _err;
176 Rect renderingRect;
177 if (!PyArg_ParseTuple(_args, "O&",
178 PyMac_GetRect, &renderingRect))
179 return NULL;
180 _err = HRSetRenderingRect(_self->ob_itself,
181 &renderingRect);
182 if (_err != noErr) return PyMac_Error(_err);
183 Py_INCREF(Py_None);
184 _res = Py_None;
185 return _res;
188 static PyObject *HtmlObj_HRGetRenderedImageSize(_self, _args)
189 HtmlObjectObject *_self;
190 PyObject *_args;
192 PyObject *_res = NULL;
193 OSStatus _err;
194 Point renderingSize;
195 if (!PyArg_ParseTuple(_args, ""))
196 return NULL;
197 _err = HRGetRenderedImageSize(_self->ob_itself,
198 &renderingSize);
199 if (_err != noErr) return PyMac_Error(_err);
200 _res = Py_BuildValue("O&",
201 PyMac_BuildPoint, renderingSize);
202 return _res;
205 static PyObject *HtmlObj_HRScrollToLocation(_self, _args)
206 HtmlObjectObject *_self;
207 PyObject *_args;
209 PyObject *_res = NULL;
210 OSStatus _err;
211 Point location;
212 if (!PyArg_ParseTuple(_args, ""))
213 return NULL;
214 _err = HRScrollToLocation(_self->ob_itself,
215 &location);
216 if (_err != noErr) return PyMac_Error(_err);
217 _res = Py_BuildValue("O&",
218 PyMac_BuildPoint, location);
219 return _res;
222 static PyObject *HtmlObj_HRForceQuickdraw(_self, _args)
223 HtmlObjectObject *_self;
224 PyObject *_args;
226 PyObject *_res = NULL;
227 OSStatus _err;
228 Boolean forceQuickdraw;
229 if (!PyArg_ParseTuple(_args, "b",
230 &forceQuickdraw))
231 return NULL;
232 _err = HRForceQuickdraw(_self->ob_itself,
233 forceQuickdraw);
234 if (_err != noErr) return PyMac_Error(_err);
235 Py_INCREF(Py_None);
236 _res = Py_None;
237 return _res;
240 static PyObject *HtmlObj_HRSetScrollbarState(_self, _args)
241 HtmlObjectObject *_self;
242 PyObject *_args;
244 PyObject *_res = NULL;
245 OSStatus _err;
246 HRScrollbarState hScrollbarState;
247 HRScrollbarState vScrollbarState;
248 if (!PyArg_ParseTuple(_args, "hh",
249 &hScrollbarState,
250 &vScrollbarState))
251 return NULL;
252 _err = HRSetScrollbarState(_self->ob_itself,
253 hScrollbarState,
254 vScrollbarState);
255 if (_err != noErr) return PyMac_Error(_err);
256 Py_INCREF(Py_None);
257 _res = Py_None;
258 return _res;
261 static PyObject *HtmlObj_HRSetDrawBorder(_self, _args)
262 HtmlObjectObject *_self;
263 PyObject *_args;
265 PyObject *_res = NULL;
266 OSStatus _err;
267 Boolean drawBorder;
268 if (!PyArg_ParseTuple(_args, "b",
269 &drawBorder))
270 return NULL;
271 _err = HRSetDrawBorder(_self->ob_itself,
272 drawBorder);
273 if (_err != noErr) return PyMac_Error(_err);
274 Py_INCREF(Py_None);
275 _res = Py_None;
276 return _res;
279 static PyObject *HtmlObj_HRSetGrowboxCutout(_self, _args)
280 HtmlObjectObject *_self;
281 PyObject *_args;
283 PyObject *_res = NULL;
284 OSStatus _err;
285 Boolean allowCutout;
286 if (!PyArg_ParseTuple(_args, "b",
287 &allowCutout))
288 return NULL;
289 _err = HRSetGrowboxCutout(_self->ob_itself,
290 allowCutout);
291 if (_err != noErr) return PyMac_Error(_err);
292 Py_INCREF(Py_None);
293 _res = Py_None;
294 return _res;
297 static PyObject *HtmlObj_HRGoToFile(_self, _args)
298 HtmlObjectObject *_self;
299 PyObject *_args;
301 PyObject *_res = NULL;
302 OSStatus _err;
303 FSSpec fsspec;
304 Boolean addToHistory;
305 Boolean forceRefresh;
306 if (!PyArg_ParseTuple(_args, "O&bb",
307 PyMac_GetFSSpec, &fsspec,
308 &addToHistory,
309 &forceRefresh))
310 return NULL;
311 _err = HRGoToFile(_self->ob_itself,
312 &fsspec,
313 addToHistory,
314 forceRefresh);
315 if (_err != noErr) return PyMac_Error(_err);
316 Py_INCREF(Py_None);
317 _res = Py_None;
318 return _res;
321 static PyObject *HtmlObj_HRGoToURL(_self, _args)
322 HtmlObjectObject *_self;
323 PyObject *_args;
325 PyObject *_res = NULL;
326 OSStatus _err;
327 char * url;
328 Boolean addToHistory;
329 Boolean forceRefresh;
330 if (!PyArg_ParseTuple(_args, "sbb",
331 &url,
332 &addToHistory,
333 &forceRefresh))
334 return NULL;
335 _err = HRGoToURL(_self->ob_itself,
336 url,
337 addToHistory,
338 forceRefresh);
339 if (_err != noErr) return PyMac_Error(_err);
340 Py_INCREF(Py_None);
341 _res = Py_None;
342 return _res;
345 static PyObject *HtmlObj_HRGoToAnchor(_self, _args)
346 HtmlObjectObject *_self;
347 PyObject *_args;
349 PyObject *_res = NULL;
350 OSStatus _err;
351 char * anchorName;
352 if (!PyArg_ParseTuple(_args, "s",
353 &anchorName))
354 return NULL;
355 _err = HRGoToAnchor(_self->ob_itself,
356 anchorName);
357 if (_err != noErr) return PyMac_Error(_err);
358 Py_INCREF(Py_None);
359 _res = Py_None;
360 return _res;
363 static PyObject *HtmlObj_HRGoToPtr(_self, _args)
364 HtmlObjectObject *_self;
365 PyObject *_args;
367 PyObject *_res = NULL;
368 OSStatus _err;
369 char *buffer__in__;
370 long buffer__len__;
371 int buffer__in_len__;
372 Boolean addToHistory;
373 Boolean forceRefresh;
374 if (!PyArg_ParseTuple(_args, "s#bb",
375 &buffer__in__, &buffer__in_len__,
376 &addToHistory,
377 &forceRefresh))
378 return NULL;
379 buffer__len__ = buffer__in_len__;
380 _err = HRGoToPtr(_self->ob_itself,
381 buffer__in__, buffer__len__,
382 addToHistory,
383 forceRefresh);
384 if (_err != noErr) return PyMac_Error(_err);
385 Py_INCREF(Py_None);
386 _res = Py_None;
387 buffer__error__: ;
388 return _res;
391 static PyObject *HtmlObj_HRGetRootURL(_self, _args)
392 HtmlObjectObject *_self;
393 PyObject *_args;
395 PyObject *_res = NULL;
396 OSStatus _err;
397 Handle rootURLH;
398 if (!PyArg_ParseTuple(_args, "O&",
399 ResObj_Convert, &rootURLH))
400 return NULL;
401 _err = HRGetRootURL(_self->ob_itself,
402 rootURLH);
403 if (_err != noErr) return PyMac_Error(_err);
404 Py_INCREF(Py_None);
405 _res = Py_None;
406 return _res;
409 static PyObject *HtmlObj_HRGetBaseURL(_self, _args)
410 HtmlObjectObject *_self;
411 PyObject *_args;
413 PyObject *_res = NULL;
414 OSStatus _err;
415 Handle baseURLH;
416 if (!PyArg_ParseTuple(_args, "O&",
417 ResObj_Convert, &baseURLH))
418 return NULL;
419 _err = HRGetBaseURL(_self->ob_itself,
420 baseURLH);
421 if (_err != noErr) return PyMac_Error(_err);
422 Py_INCREF(Py_None);
423 _res = Py_None;
424 return _res;
427 static PyObject *HtmlObj_HRGetHTMLURL(_self, _args)
428 HtmlObjectObject *_self;
429 PyObject *_args;
431 PyObject *_res = NULL;
432 OSStatus _err;
433 Handle HTMLURLH;
434 if (!PyArg_ParseTuple(_args, "O&",
435 ResObj_Convert, &HTMLURLH))
436 return NULL;
437 _err = HRGetHTMLURL(_self->ob_itself,
438 HTMLURLH);
439 if (_err != noErr) return PyMac_Error(_err);
440 Py_INCREF(Py_None);
441 _res = Py_None;
442 return _res;
445 static PyObject *HtmlObj_HRGetTitle(_self, _args)
446 HtmlObjectObject *_self;
447 PyObject *_args;
449 PyObject *_res = NULL;
450 OSStatus _err;
451 StringPtr title;
452 if (!PyArg_ParseTuple(_args, "s",
453 &title))
454 return NULL;
455 _err = HRGetTitle(_self->ob_itself,
456 title);
457 if (_err != noErr) return PyMac_Error(_err);
458 Py_INCREF(Py_None);
459 _res = Py_None;
460 return _res;
463 static PyObject *HtmlObj_HRGetHTMLFile(_self, _args)
464 HtmlObjectObject *_self;
465 PyObject *_args;
467 PyObject *_res = NULL;
468 OSStatus _err;
469 FSSpec fsspec;
470 if (!PyArg_ParseTuple(_args, ""))
471 return NULL;
472 _err = HRGetHTMLFile(_self->ob_itself,
473 &fsspec);
474 if (_err != noErr) return PyMac_Error(_err);
475 _res = Py_BuildValue("O&",
476 PyMac_BuildFSSpec, fsspec);
477 return _res;
480 static PyObject *HtmlObj_HRUnregisterWasURLVisitedUPP(_self, _args)
481 HtmlObjectObject *_self;
482 PyObject *_args;
484 PyObject *_res = NULL;
485 if (!PyArg_ParseTuple(_args, ""))
486 return NULL;
487 HRUnregisterWasURLVisitedUPP(_self->ob_itself);
488 Py_INCREF(Py_None);
489 _res = Py_None;
490 return _res;
493 static PyObject *HtmlObj_HRUnregisterNewURLUPP(_self, _args)
494 HtmlObjectObject *_self;
495 PyObject *_args;
497 PyObject *_res = NULL;
498 if (!PyArg_ParseTuple(_args, ""))
499 return NULL;
500 HRUnregisterNewURLUPP(_self->ob_itself);
501 Py_INCREF(Py_None);
502 _res = Py_None;
503 return _res;
506 static PyObject *HtmlObj_HRUnregisterURLToFSSpecUPP(_self, _args)
507 HtmlObjectObject *_self;
508 PyObject *_args;
510 PyObject *_res = NULL;
511 if (!PyArg_ParseTuple(_args, ""))
512 return NULL;
513 HRUnregisterURLToFSSpecUPP(_self->ob_itself);
514 Py_INCREF(Py_None);
515 _res = Py_None;
516 return _res;
519 static PyMethodDef HtmlObj_methods[] = {
520 {"HRDisposeReference", (PyCFunction)HtmlObj_HRDisposeReference, 1,
521 "() -> None"},
522 {"HRSetGrafPtr", (PyCFunction)HtmlObj_HRSetGrafPtr, 1,
523 "(GrafPtr grafPtr) -> None"},
524 {"HRActivate", (PyCFunction)HtmlObj_HRActivate, 1,
525 "() -> None"},
526 {"HRDeactivate", (PyCFunction)HtmlObj_HRDeactivate, 1,
527 "() -> None"},
528 {"HRDraw", (PyCFunction)HtmlObj_HRDraw, 1,
529 "(RgnHandle updateRgnH) -> None"},
530 {"HRSetRenderingRect", (PyCFunction)HtmlObj_HRSetRenderingRect, 1,
531 "(Rect renderingRect) -> None"},
532 {"HRGetRenderedImageSize", (PyCFunction)HtmlObj_HRGetRenderedImageSize, 1,
533 "() -> (Point renderingSize)"},
534 {"HRScrollToLocation", (PyCFunction)HtmlObj_HRScrollToLocation, 1,
535 "() -> (Point location)"},
536 {"HRForceQuickdraw", (PyCFunction)HtmlObj_HRForceQuickdraw, 1,
537 "(Boolean forceQuickdraw) -> None"},
538 {"HRSetScrollbarState", (PyCFunction)HtmlObj_HRSetScrollbarState, 1,
539 "(HRScrollbarState hScrollbarState, HRScrollbarState vScrollbarState) -> None"},
540 {"HRSetDrawBorder", (PyCFunction)HtmlObj_HRSetDrawBorder, 1,
541 "(Boolean drawBorder) -> None"},
542 {"HRSetGrowboxCutout", (PyCFunction)HtmlObj_HRSetGrowboxCutout, 1,
543 "(Boolean allowCutout) -> None"},
544 {"HRGoToFile", (PyCFunction)HtmlObj_HRGoToFile, 1,
545 "(FSSpec fsspec, Boolean addToHistory, Boolean forceRefresh) -> None"},
546 {"HRGoToURL", (PyCFunction)HtmlObj_HRGoToURL, 1,
547 "(char * url, Boolean addToHistory, Boolean forceRefresh) -> None"},
548 {"HRGoToAnchor", (PyCFunction)HtmlObj_HRGoToAnchor, 1,
549 "(char * anchorName) -> None"},
550 {"HRGoToPtr", (PyCFunction)HtmlObj_HRGoToPtr, 1,
551 "(Buffer buffer, Boolean addToHistory, Boolean forceRefresh) -> None"},
552 {"HRGetRootURL", (PyCFunction)HtmlObj_HRGetRootURL, 1,
553 "(Handle rootURLH) -> None"},
554 {"HRGetBaseURL", (PyCFunction)HtmlObj_HRGetBaseURL, 1,
555 "(Handle baseURLH) -> None"},
556 {"HRGetHTMLURL", (PyCFunction)HtmlObj_HRGetHTMLURL, 1,
557 "(Handle HTMLURLH) -> None"},
558 {"HRGetTitle", (PyCFunction)HtmlObj_HRGetTitle, 1,
559 "(StringPtr title) -> None"},
560 {"HRGetHTMLFile", (PyCFunction)HtmlObj_HRGetHTMLFile, 1,
561 "() -> (FSSpec fsspec)"},
562 {"HRUnregisterWasURLVisitedUPP", (PyCFunction)HtmlObj_HRUnregisterWasURLVisitedUPP, 1,
563 "() -> None"},
564 {"HRUnregisterNewURLUPP", (PyCFunction)HtmlObj_HRUnregisterNewURLUPP, 1,
565 "() -> None"},
566 {"HRUnregisterURLToFSSpecUPP", (PyCFunction)HtmlObj_HRUnregisterURLToFSSpecUPP, 1,
567 "() -> None"},
568 {NULL, NULL, 0}
571 PyMethodChain HtmlObj_chain = { HtmlObj_methods, NULL };
573 static PyObject *HtmlObj_getattr(self, name)
574 HtmlObjectObject *self;
575 char *name;
577 return Py_FindMethodInChain(&HtmlObj_chain, (PyObject *)self, name);
580 #define HtmlObj_setattr NULL
582 #define HtmlObj_compare NULL
584 #define HtmlObj_repr NULL
586 #define HtmlObj_hash NULL
588 PyTypeObject HtmlObject_Type = {
589 PyObject_HEAD_INIT(&PyType_Type)
590 0, /*ob_size*/
591 "HtmlRender.HtmlObject", /*tp_name*/
592 sizeof(HtmlObjectObject), /*tp_basicsize*/
593 0, /*tp_itemsize*/
594 /* methods */
595 (destructor) HtmlObj_dealloc, /*tp_dealloc*/
596 0, /*tp_print*/
597 (getattrfunc) HtmlObj_getattr, /*tp_getattr*/
598 (setattrfunc) HtmlObj_setattr, /*tp_setattr*/
599 (cmpfunc) HtmlObj_compare, /*tp_compare*/
600 (reprfunc) HtmlObj_repr, /*tp_repr*/
601 (PyNumberMethods *)0, /* tp_as_number */
602 (PySequenceMethods *)0, /* tp_as_sequence */
603 (PyMappingMethods *)0, /* tp_as_mapping */
604 (hashfunc) HtmlObj_hash, /*tp_hash*/
607 /* ------------------- End object type HtmlObject ------------------- */
610 static PyObject *Html_HRGetHTMLRenderingLibVersion(_self, _args)
611 PyObject *_self;
612 PyObject *_args;
614 PyObject *_res = NULL;
615 OSStatus _err;
616 NumVersion returnVers;
617 if (!PyArg_ParseTuple(_args, ""))
618 return NULL;
619 _err = HRGetHTMLRenderingLibVersion(&returnVers);
620 if (_err != noErr) return PyMac_Error(_err);
621 _res = Py_BuildValue("O&",
622 PyMac_BuildNumVersion, returnVers);
623 return _res;
626 static PyObject *Html_HRNewReference(_self, _args)
627 PyObject *_self;
628 PyObject *_args;
630 PyObject *_res = NULL;
631 OSStatus _err;
632 HRReference hrRef;
633 OSType rendererType;
634 GrafPtr grafPtr;
635 if (!PyArg_ParseTuple(_args, "O&O&",
636 PyMac_GetOSType, &rendererType,
637 GrafObj_Convert, &grafPtr))
638 return NULL;
639 _err = HRNewReference(&hrRef,
640 rendererType,
641 grafPtr);
642 if (_err != noErr) return PyMac_Error(_err);
643 _res = Py_BuildValue("O&",
644 HtmlObj_New, hrRef);
645 return _res;
648 static PyObject *Html_HRFreeMemory(_self, _args)
649 PyObject *_self;
650 PyObject *_args;
652 PyObject *_res = NULL;
653 SInt32 _rv;
654 Size inBytesNeeded;
655 if (!PyArg_ParseTuple(_args, "l",
656 &inBytesNeeded))
657 return NULL;
658 _rv = HRFreeMemory(inBytesNeeded);
659 _res = Py_BuildValue("l",
660 _rv);
661 return _res;
664 static PyObject *Html_HRScreenConfigurationChanged(_self, _args)
665 PyObject *_self;
666 PyObject *_args;
668 PyObject *_res = NULL;
669 if (!PyArg_ParseTuple(_args, ""))
670 return NULL;
671 HRScreenConfigurationChanged();
672 Py_INCREF(Py_None);
673 _res = Py_None;
674 return _res;
677 static PyObject *Html_HRIsHREvent(_self, _args)
678 PyObject *_self;
679 PyObject *_args;
681 PyObject *_res = NULL;
682 Boolean _rv;
683 EventRecord eventRecord;
684 if (!PyArg_ParseTuple(_args, "O&",
685 PyMac_GetEventRecord, &eventRecord))
686 return NULL;
687 _rv = HRIsHREvent(&eventRecord);
688 _res = Py_BuildValue("b",
689 _rv);
690 return _res;
693 static PyObject *Html_HRUtilCreateFullURL(_self, _args)
694 PyObject *_self;
695 PyObject *_args;
697 PyObject *_res = NULL;
698 OSStatus _err;
699 char * rootURL;
700 char * linkURL;
701 Handle fullURLH;
702 if (!PyArg_ParseTuple(_args, "ssO&",
703 &rootURL,
704 &linkURL,
705 ResObj_Convert, &fullURLH))
706 return NULL;
707 _err = HRUtilCreateFullURL(rootURL,
708 linkURL,
709 fullURLH);
710 if (_err != noErr) return PyMac_Error(_err);
711 Py_INCREF(Py_None);
712 _res = Py_None;
713 return _res;
716 static PyObject *Html_HRUtilGetFSSpecFromURL(_self, _args)
717 PyObject *_self;
718 PyObject *_args;
720 PyObject *_res = NULL;
721 OSStatus _err;
722 char * rootURL;
723 char * linkURL;
724 FSSpec destSpec;
725 if (!PyArg_ParseTuple(_args, "ss",
726 &rootURL,
727 &linkURL))
728 return NULL;
729 _err = HRUtilGetFSSpecFromURL(rootURL,
730 linkURL,
731 &destSpec);
732 if (_err != noErr) return PyMac_Error(_err);
733 _res = Py_BuildValue("O&",
734 PyMac_BuildFSSpec, destSpec);
735 return _res;
738 static PyObject *Html_HRUtilGetURLFromFSSpec(_self, _args)
739 PyObject *_self;
740 PyObject *_args;
742 PyObject *_res = NULL;
743 OSStatus _err;
744 FSSpec fsspec;
745 Handle urlHandle;
746 if (!PyArg_ParseTuple(_args, "O&O&",
747 PyMac_GetFSSpec, &fsspec,
748 ResObj_Convert, &urlHandle))
749 return NULL;
750 _err = HRUtilGetURLFromFSSpec(&fsspec,
751 urlHandle);
752 if (_err != noErr) return PyMac_Error(_err);
753 Py_INCREF(Py_None);
754 _res = Py_None;
755 return _res;
758 static PyObject *Html_HRHTMLRenderingLibAvailable(_self, _args)
759 PyObject *_self;
760 PyObject *_args;
762 PyObject *_res = NULL;
763 int _rv;
764 if (!PyArg_ParseTuple(_args, ""))
765 return NULL;
766 _rv = HRHTMLRenderingLibAvailable();
767 _res = Py_BuildValue("i",
768 _rv);
769 return _res;
772 static PyMethodDef Html_methods[] = {
773 {"HRGetHTMLRenderingLibVersion", (PyCFunction)Html_HRGetHTMLRenderingLibVersion, 1,
774 "() -> (NumVersion returnVers)"},
775 {"HRNewReference", (PyCFunction)Html_HRNewReference, 1,
776 "(OSType rendererType, GrafPtr grafPtr) -> (HRReference hrRef)"},
777 {"HRFreeMemory", (PyCFunction)Html_HRFreeMemory, 1,
778 "(Size inBytesNeeded) -> (SInt32 _rv)"},
779 {"HRScreenConfigurationChanged", (PyCFunction)Html_HRScreenConfigurationChanged, 1,
780 "() -> None"},
781 {"HRIsHREvent", (PyCFunction)Html_HRIsHREvent, 1,
782 "(EventRecord eventRecord) -> (Boolean _rv)"},
783 {"HRUtilCreateFullURL", (PyCFunction)Html_HRUtilCreateFullURL, 1,
784 "(char * rootURL, char * linkURL, Handle fullURLH) -> None"},
785 {"HRUtilGetFSSpecFromURL", (PyCFunction)Html_HRUtilGetFSSpecFromURL, 1,
786 "(char * rootURL, char * linkURL) -> (FSSpec destSpec)"},
787 {"HRUtilGetURLFromFSSpec", (PyCFunction)Html_HRUtilGetURLFromFSSpec, 1,
788 "(FSSpec fsspec, Handle urlHandle) -> None"},
789 {"HRHTMLRenderingLibAvailable", (PyCFunction)Html_HRHTMLRenderingLibAvailable, 1,
790 "() -> (int _rv)"},
791 {NULL, NULL, 0}
797 void initHtmlRender()
799 PyObject *m;
800 PyObject *d;
805 m = Py_InitModule("HtmlRender", Html_methods);
806 d = PyModule_GetDict(m);
807 Html_Error = PyMac_GetOSErrException();
808 if (Html_Error == NULL ||
809 PyDict_SetItemString(d, "Error", Html_Error) != 0)
810 Py_FatalError("can't initialize HtmlRender.Error");
811 HtmlObject_Type.ob_type = &PyType_Type;
812 Py_INCREF(&HtmlObject_Type);
813 if (PyDict_SetItemString(d, "HtmlObjectType", (PyObject *)&HtmlObject_Type) != 0)
814 Py_FatalError("can't initialize HtmlObjectType");
817 /* ===================== End module HtmlRender ====================== */