##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: Decemeber 2016 # Modified: 2016-12-30/01:47-0500 ##+ # # haru.icn, demonstrate a new C FFI (first fail, double versus float) # $include "natives.inc" $define HPDF_COMP_ALL 15 $define HPDF_PAGE_MODE_USE_OUTLINE 1 $define HPDF_PAGE_SIZE_LETTER 0 $define HPDF_PAGE_PORTRAIT 0 procedure main() local dlHandle, pdf, page1, rc, savefile := "harutest.pdf" # will be RTLD_LAZY | RTLD_GLOBAL (so add to the search path) addLibrary := loadfunc("./uninative.so", "addLibrary") # allow arbitrary C functions, marshalled by a piece of assembler # assume float instead of double, changes the inline assembler # movsd versus movdd native := loadfunc("./uninative.so", "nativeFloat") # add libhpdf to the dlsym search path, the handle is irrelevant dlHandle := addLibrary("libhpdf.so") pdf := native("HPDF_New", TYPESTAR, 0, 0) rc := native("HPDF_SetCompressionMode", TYPEINT, pdf, HPDF_COMP_ALL) rc := native("HPDF_SetPageMode", TYPEINT, pdf, HPDF_PAGE_MODE_USE_OUTLINE) $ifdef PROTECTED rc := native("HPDF_SetPassword", TYPEINT, pdf, "owner", "user") savefile := "harutest-pass.pdf" $endif page1 := native("HPDF_AddPage", TYPESTAR, pdf) rc := native("HPDF_Page_SetHeight", TYPEINT, page1, 220.0) rc := native("HPDF_Page_SetWidth", TYPEINT, page1, 200.0); #/* A part of libharu pie chart sample, Red*/ rc := native("HPDF_Page_SetRGBFill", TYPEINT, page1, 1.0, 0.0, 0.0); rc := native("HPDF_Page_MoveTo", TYPEINT, page1, 100.0, 100.0); rc := native("HPDF_Page_LineTo", TYPEINT, page1, 100.0, 180.0); rc := native("HPDF_Page_Arc", TYPEINT, page1, 100.0, 100.0, 80.0, 0.0, 360 * 0.45); #pos := native("HPDF_Page_GetCurrentPos (page); rc := native("HPDF_Page_LineTo", TYPEINT, page1, 100.0, 100.0); rc := native("HPDF_Page_Fill", TYPEINT, page1); rc := native("HPDF_SaveToFile", TYPEINT, pdf, savefile) native("HPDF_Free", TYPEVOID, pdf) end