gimarshallingtests.c 131 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429
  1. /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  2. *vim: tabstop=4 shiftwidth=4 expandtab
  3. */
  4. /* This file gets installed, so we can't assume config.h is available */
  5. #ifdef HAVE_CONFIG_H
  6. #include "config.h"
  7. #endif
  8. #include "gimarshallingtests.h"
  9. #include <string.h>
  10. static void gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *v);
  11. /* Booleans */
  12. gboolean
  13. gi_marshalling_tests_boolean_return_true (void)
  14. {
  15. return TRUE;
  16. }
  17. gboolean
  18. gi_marshalling_tests_boolean_return_false (void)
  19. {
  20. return FALSE;
  21. }
  22. void
  23. gi_marshalling_tests_boolean_in_true (gboolean v)
  24. {
  25. g_assert (v == TRUE);
  26. }
  27. void
  28. gi_marshalling_tests_boolean_in_false (gboolean v)
  29. {
  30. g_assert (v == FALSE);
  31. }
  32. /**
  33. * gi_marshalling_tests_boolean_out_true:
  34. * @v: (out):
  35. */
  36. void
  37. gi_marshalling_tests_boolean_out_true (gboolean *v)
  38. {
  39. *v = TRUE;
  40. }
  41. /**
  42. * gi_marshalling_tests_boolean_out_false:
  43. * @v: (out):
  44. */
  45. void
  46. gi_marshalling_tests_boolean_out_false (gboolean *v)
  47. {
  48. *v = FALSE;
  49. }
  50. /**
  51. * gi_marshalling_tests_boolean_inout_true_false:
  52. * @v: (inout):
  53. */
  54. void
  55. gi_marshalling_tests_boolean_inout_true_false (gboolean *v)
  56. {
  57. g_assert (*v == TRUE);
  58. *v = FALSE;
  59. }
  60. /**
  61. * gi_marshalling_tests_boolean_inout_false_true:
  62. * @v: (inout):
  63. */
  64. void
  65. gi_marshalling_tests_boolean_inout_false_true (gboolean *v)
  66. {
  67. g_assert (*v == FALSE);
  68. *v = TRUE;
  69. }
  70. /* Integers */
  71. gint8
  72. gi_marshalling_tests_int8_return_max (void)
  73. {
  74. return G_MAXINT8;
  75. }
  76. gint8
  77. gi_marshalling_tests_int8_return_min (void)
  78. {
  79. return G_MININT8;
  80. }
  81. void
  82. gi_marshalling_tests_int8_in_max (gint8 v)
  83. {
  84. g_assert_cmpint (v, ==, G_MAXINT8);
  85. }
  86. void
  87. gi_marshalling_tests_int8_in_min (gint8 v)
  88. {
  89. g_assert_cmpint (v, ==, G_MININT8);
  90. }
  91. /**
  92. * gi_marshalling_tests_int8_out_max:
  93. * @v: (out):
  94. */
  95. void
  96. gi_marshalling_tests_int8_out_max (gint8 *v)
  97. {
  98. *v = G_MAXINT8;
  99. }
  100. /**
  101. * gi_marshalling_tests_int8_out_min:
  102. * @v: (out):
  103. */
  104. void
  105. gi_marshalling_tests_int8_out_min (gint8 *v)
  106. {
  107. *v = G_MININT8;
  108. }
  109. /**
  110. * gi_marshalling_tests_int8_inout_max_min:
  111. * @v: (inout):
  112. */
  113. void
  114. gi_marshalling_tests_int8_inout_max_min (gint8 *v)
  115. {
  116. g_assert_cmpint (*v, ==, G_MAXINT8);
  117. *v = G_MININT8;
  118. }
  119. /**
  120. * gi_marshalling_tests_int8_inout_min_max:
  121. * @v: (inout):
  122. */
  123. void
  124. gi_marshalling_tests_int8_inout_min_max (gint8 *v)
  125. {
  126. g_assert_cmpint (*v, ==, G_MININT8);
  127. *v = G_MAXINT8;
  128. }
  129. guint8
  130. gi_marshalling_tests_uint8_return (void)
  131. {
  132. return G_MAXUINT8;
  133. }
  134. void
  135. gi_marshalling_tests_uint8_in (guint8 v)
  136. {
  137. g_assert_cmpuint (v, ==, G_MAXUINT8);
  138. }
  139. /**
  140. * gi_marshalling_tests_uint8_out:
  141. * @v: (out):
  142. */
  143. void
  144. gi_marshalling_tests_uint8_out (guint8 *v)
  145. {
  146. *v = G_MAXUINT8;
  147. }
  148. /**
  149. * gi_marshalling_tests_uint8_inout:
  150. * @v: (inout):
  151. */
  152. void
  153. gi_marshalling_tests_uint8_inout (guint8 *v)
  154. {
  155. g_assert_cmpuint (*v, ==, G_MAXUINT8);
  156. *v = 0;
  157. }
  158. gint16
  159. gi_marshalling_tests_int16_return_max (void)
  160. {
  161. return G_MAXINT16;
  162. }
  163. gint16
  164. gi_marshalling_tests_int16_return_min (void)
  165. {
  166. return G_MININT16;
  167. }
  168. void
  169. gi_marshalling_tests_int16_in_max (gint16 v)
  170. {
  171. g_assert_cmpint (v, ==, G_MAXINT16);
  172. }
  173. void
  174. gi_marshalling_tests_int16_in_min (gint16 v)
  175. {
  176. g_assert_cmpint (v, ==, G_MININT16);
  177. }
  178. /**
  179. * gi_marshalling_tests_int16_out_max:
  180. * @v: (out):
  181. */
  182. void
  183. gi_marshalling_tests_int16_out_max (gint16 *v)
  184. {
  185. *v = G_MAXINT16;
  186. }
  187. /**
  188. * gi_marshalling_tests_int16_out_min:
  189. * @v: (out):
  190. */
  191. void
  192. gi_marshalling_tests_int16_out_min (gint16 *v)
  193. {
  194. *v = G_MININT16;
  195. }
  196. /**
  197. * gi_marshalling_tests_int16_inout_max_min:
  198. * @v: (inout):
  199. */
  200. void
  201. gi_marshalling_tests_int16_inout_max_min (gint16 *v)
  202. {
  203. g_assert_cmpint (*v, ==, G_MAXINT16);
  204. *v = G_MININT16;
  205. }
  206. /**
  207. * gi_marshalling_tests_int16_inout_min_max:
  208. * @v: (inout):
  209. */
  210. void
  211. gi_marshalling_tests_int16_inout_min_max (gint16 *v)
  212. {
  213. g_assert_cmpint (*v, ==, G_MININT16);
  214. *v = G_MAXINT16;
  215. }
  216. guint16
  217. gi_marshalling_tests_uint16_return (void)
  218. {
  219. return G_MAXUINT16;
  220. }
  221. void
  222. gi_marshalling_tests_uint16_in (guint16 v)
  223. {
  224. g_assert_cmpuint (v, ==, G_MAXUINT16);
  225. }
  226. /**
  227. * gi_marshalling_tests_uint16_out:
  228. * @v: (out):
  229. */
  230. void
  231. gi_marshalling_tests_uint16_out (guint16 *v)
  232. {
  233. *v = G_MAXUINT16;
  234. }
  235. /**
  236. * gi_marshalling_tests_uint16_inout:
  237. * @v: (inout):
  238. */
  239. void
  240. gi_marshalling_tests_uint16_inout (guint16 *v)
  241. {
  242. g_assert_cmpuint (*v, ==, G_MAXUINT16);
  243. *v = 0;
  244. }
  245. gint32
  246. gi_marshalling_tests_int32_return_max (void)
  247. {
  248. return G_MAXINT32;
  249. }
  250. gint32
  251. gi_marshalling_tests_int32_return_min (void)
  252. {
  253. return G_MININT32;
  254. }
  255. void
  256. gi_marshalling_tests_int32_in_max (gint32 v)
  257. {
  258. g_assert_cmpint (v, ==, G_MAXINT32);
  259. }
  260. void
  261. gi_marshalling_tests_int32_in_min (gint32 v)
  262. {
  263. g_assert_cmpint (v, ==, G_MININT32);
  264. }
  265. /**
  266. * gi_marshalling_tests_int32_out_max:
  267. * @v: (out):
  268. */
  269. void
  270. gi_marshalling_tests_int32_out_max (gint32 *v)
  271. {
  272. *v = G_MAXINT32;
  273. }
  274. /**
  275. * gi_marshalling_tests_int32_out_min:
  276. * @v: (out):
  277. */
  278. void
  279. gi_marshalling_tests_int32_out_min (gint32 *v)
  280. {
  281. *v = G_MININT32;
  282. }
  283. /**
  284. * gi_marshalling_tests_int32_inout_max_min:
  285. * @v: (inout):
  286. */
  287. void
  288. gi_marshalling_tests_int32_inout_max_min (gint32 *v)
  289. {
  290. g_assert_cmpint (*v, ==, G_MAXINT32);
  291. *v = G_MININT32;
  292. }
  293. /**
  294. * gi_marshalling_tests_int32_inout_min_max:
  295. * @v: (inout):
  296. */
  297. void
  298. gi_marshalling_tests_int32_inout_min_max (gint32 *v)
  299. {
  300. g_assert_cmpint (*v, ==, G_MININT32);
  301. *v = G_MAXINT32;
  302. }
  303. guint32
  304. gi_marshalling_tests_uint32_return (void)
  305. {
  306. return G_MAXUINT32;
  307. }
  308. void
  309. gi_marshalling_tests_uint32_in (guint32 v)
  310. {
  311. g_assert_cmpuint (v, ==, G_MAXUINT32);
  312. }
  313. /**
  314. * gi_marshalling_tests_uint32_out:
  315. * @v: (out):
  316. */
  317. void
  318. gi_marshalling_tests_uint32_out (guint32 *v)
  319. {
  320. *v = G_MAXUINT32;
  321. }
  322. /**
  323. * gi_marshalling_tests_uint32_inout:
  324. * @v: (inout):
  325. */
  326. void
  327. gi_marshalling_tests_uint32_inout (guint32 *v)
  328. {
  329. g_assert_cmpuint (*v, ==, G_MAXUINT32);
  330. *v = 0;
  331. }
  332. gint64
  333. gi_marshalling_tests_int64_return_max (void)
  334. {
  335. return G_MAXINT64;
  336. }
  337. gint64
  338. gi_marshalling_tests_int64_return_min (void)
  339. {
  340. return G_MININT64;
  341. }
  342. void
  343. gi_marshalling_tests_int64_in_max (gint64 v)
  344. {
  345. g_assert_cmpint (v, ==, G_MAXINT64);
  346. }
  347. void
  348. gi_marshalling_tests_int64_in_min (gint64 v)
  349. {
  350. g_assert_cmpint (v, ==, G_MININT64);
  351. }
  352. /**
  353. * gi_marshalling_tests_int64_out_max:
  354. * @v: (out):
  355. */
  356. void
  357. gi_marshalling_tests_int64_out_max (gint64 *v)
  358. {
  359. *v = G_MAXINT64;
  360. }
  361. /**
  362. * gi_marshalling_tests_int64_out_min:
  363. * @v: (out):
  364. */
  365. void
  366. gi_marshalling_tests_int64_out_min (gint64 *v)
  367. {
  368. *v = G_MININT64;
  369. }
  370. /**
  371. * gi_marshalling_tests_int64_inout_max_min:
  372. * @v: (inout):
  373. */
  374. void
  375. gi_marshalling_tests_int64_inout_max_min (gint64 *v)
  376. {
  377. g_assert_cmpint (*v, ==, G_MAXINT64);
  378. *v = G_MININT64;
  379. }
  380. /**
  381. * gi_marshalling_tests_int64_inout_min_max:
  382. * @v: (inout):
  383. */
  384. void
  385. gi_marshalling_tests_int64_inout_min_max (gint64 *v)
  386. {
  387. g_assert_cmpint (*v, ==, G_MININT64);
  388. *v = G_MAXINT64;
  389. }
  390. guint64
  391. gi_marshalling_tests_uint64_return (void)
  392. {
  393. return G_MAXUINT64;
  394. }
  395. void
  396. gi_marshalling_tests_uint64_in (guint64 v)
  397. {
  398. g_assert_cmpuint (v, ==, G_MAXUINT64);
  399. }
  400. /**
  401. * gi_marshalling_tests_uint64_out:
  402. * @v: (out):
  403. */
  404. void
  405. gi_marshalling_tests_uint64_out (guint64 *v)
  406. {
  407. *v = G_MAXUINT64;
  408. }
  409. /**
  410. * gi_marshalling_tests_uint64_inout:
  411. * @v: (inout):
  412. */
  413. void
  414. gi_marshalling_tests_uint64_inout (guint64 *v)
  415. {
  416. g_assert_cmpuint (*v, ==, G_MAXUINT64);
  417. *v = 0;
  418. }
  419. gshort
  420. gi_marshalling_tests_short_return_max (void)
  421. {
  422. return G_MAXSHORT;
  423. }
  424. gshort
  425. gi_marshalling_tests_short_return_min (void)
  426. {
  427. return G_MINSHORT;
  428. }
  429. void
  430. gi_marshalling_tests_short_in_max (gshort short_)
  431. {
  432. g_assert_cmpint (short_, ==, G_MAXSHORT);
  433. }
  434. void
  435. gi_marshalling_tests_short_in_min (gshort short_)
  436. {
  437. g_assert_cmpint (short_, ==, G_MINSHORT);
  438. }
  439. /**
  440. * gi_marshalling_tests_short_out_max:
  441. * @short_: (out):
  442. */
  443. void
  444. gi_marshalling_tests_short_out_max (gshort *short_)
  445. {
  446. *short_ = G_MAXSHORT;
  447. }
  448. /**
  449. * gi_marshalling_tests_short_out_min:
  450. * @short_: (out):
  451. */
  452. void
  453. gi_marshalling_tests_short_out_min (gshort *short_)
  454. {
  455. *short_ = G_MINSHORT;
  456. }
  457. /**
  458. * gi_marshalling_tests_short_inout_max_min:
  459. * @short_: (inout):
  460. */
  461. void
  462. gi_marshalling_tests_short_inout_max_min (gshort *short_)
  463. {
  464. g_assert_cmpint (*short_, ==, G_MAXSHORT);
  465. *short_ = G_MINSHORT;
  466. }
  467. /**
  468. * gi_marshalling_tests_short_inout_min_max:
  469. * @short_: (inout):
  470. */
  471. void
  472. gi_marshalling_tests_short_inout_min_max (gshort *short_)
  473. {
  474. g_assert_cmpint (*short_, ==, G_MINSHORT);
  475. *short_ = G_MAXSHORT;
  476. }
  477. gushort
  478. gi_marshalling_tests_ushort_return (void)
  479. {
  480. return G_MAXUSHORT;
  481. }
  482. void
  483. gi_marshalling_tests_ushort_in (gushort ushort_)
  484. {
  485. g_assert_cmpuint (ushort_, ==, G_MAXUSHORT);
  486. }
  487. /**
  488. * gi_marshalling_tests_ushort_out:
  489. * @ushort_: (out):
  490. */
  491. void
  492. gi_marshalling_tests_ushort_out (gushort *ushort_)
  493. {
  494. *ushort_ = G_MAXUSHORT;
  495. }
  496. /**
  497. * gi_marshalling_tests_ushort_inout:
  498. * @ushort_: (inout):
  499. */
  500. void
  501. gi_marshalling_tests_ushort_inout (gushort *ushort_)
  502. {
  503. g_assert_cmpuint (*ushort_, ==, G_MAXUSHORT);
  504. *ushort_ = 0;
  505. }
  506. gint
  507. gi_marshalling_tests_int_return_max (void)
  508. {
  509. return G_MAXINT;
  510. }
  511. gint
  512. gi_marshalling_tests_int_return_min (void)
  513. {
  514. return G_MININT;
  515. }
  516. void
  517. gi_marshalling_tests_int_in_max (gint int_)
  518. {
  519. g_assert_cmpint (int_, ==, G_MAXINT);
  520. }
  521. void
  522. gi_marshalling_tests_int_in_min (gint int_)
  523. {
  524. g_assert_cmpint (int_, ==, G_MININT);
  525. }
  526. /**
  527. * gi_marshalling_tests_int_out_max:
  528. * @int_: (out):
  529. */
  530. void
  531. gi_marshalling_tests_int_out_max (gint *int_)
  532. {
  533. *int_ = G_MAXINT;
  534. }
  535. /**
  536. * gi_marshalling_tests_int_out_min:
  537. * @int_: (out):
  538. */
  539. void
  540. gi_marshalling_tests_int_out_min (gint *int_)
  541. {
  542. *int_ = G_MININT;
  543. }
  544. /**
  545. * gi_marshalling_tests_int_inout_max_min:
  546. * @int_: (inout):
  547. */
  548. void
  549. gi_marshalling_tests_int_inout_max_min (gint *int_)
  550. {
  551. g_assert_cmpint (*int_, ==, G_MAXINT);
  552. *int_ = G_MININT;
  553. }
  554. /**
  555. * gi_marshalling_tests_int_inout_min_max:
  556. * @int_: (inout):
  557. */
  558. void
  559. gi_marshalling_tests_int_inout_min_max (gint *int_)
  560. {
  561. g_assert_cmpint (*int_, ==, G_MININT);
  562. *int_ = G_MAXINT;
  563. }
  564. guint
  565. gi_marshalling_tests_uint_return (void)
  566. {
  567. return G_MAXUINT;
  568. }
  569. void
  570. gi_marshalling_tests_uint_in (guint uint_)
  571. {
  572. g_assert_cmpuint (uint_, ==, G_MAXUINT);
  573. }
  574. /**
  575. * gi_marshalling_tests_uint_out:
  576. * @uint_: (out):
  577. */
  578. void
  579. gi_marshalling_tests_uint_out (guint *uint_)
  580. {
  581. *uint_ = G_MAXUINT;
  582. }
  583. /**
  584. * gi_marshalling_tests_uint_inout:
  585. * @uint_: (inout):
  586. */
  587. void
  588. gi_marshalling_tests_uint_inout (guint *uint_)
  589. {
  590. g_assert_cmpuint (*uint_, ==, G_MAXUINT);
  591. *uint_ = 0;
  592. }
  593. glong
  594. gi_marshalling_tests_long_return_max (void)
  595. {
  596. return G_MAXLONG;
  597. }
  598. glong
  599. gi_marshalling_tests_long_return_min (void)
  600. {
  601. return G_MINLONG;
  602. }
  603. void
  604. gi_marshalling_tests_long_in_max (glong long_)
  605. {
  606. g_assert_cmpint (long_, ==, G_MAXLONG);
  607. }
  608. void
  609. gi_marshalling_tests_long_in_min (glong long_)
  610. {
  611. g_assert_cmpint (long_, ==, G_MINLONG);
  612. }
  613. /**
  614. * gi_marshalling_tests_long_out_max:
  615. * @long_: (out):
  616. */
  617. void
  618. gi_marshalling_tests_long_out_max (glong *long_)
  619. {
  620. *long_ = G_MAXLONG;
  621. }
  622. /**
  623. * gi_marshalling_tests_long_out_min:
  624. * @long_: (out):
  625. */
  626. void
  627. gi_marshalling_tests_long_out_min (glong *long_)
  628. {
  629. *long_ = G_MINLONG;
  630. }
  631. /**
  632. * gi_marshalling_tests_long_inout_max_min:
  633. * @long_: (inout):
  634. */
  635. void
  636. gi_marshalling_tests_long_inout_max_min (glong *long_)
  637. {
  638. g_assert_cmpint (*long_, ==, G_MAXLONG);
  639. *long_ = G_MINLONG;
  640. }
  641. /**
  642. * gi_marshalling_tests_long_inout_min_max:
  643. * @long_: (inout):
  644. */
  645. void
  646. gi_marshalling_tests_long_inout_min_max (glong *long_)
  647. {
  648. g_assert_cmpint (*long_, ==, G_MINLONG);
  649. *long_ = G_MAXLONG;
  650. }
  651. gulong
  652. gi_marshalling_tests_ulong_return (void)
  653. {
  654. return G_MAXULONG;
  655. }
  656. void
  657. gi_marshalling_tests_ulong_in (gulong ulong_)
  658. {
  659. g_assert_cmpuint (ulong_, ==, G_MAXULONG);
  660. }
  661. /**
  662. * gi_marshalling_tests_ulong_out:
  663. * @ulong_: (out):
  664. */
  665. void
  666. gi_marshalling_tests_ulong_out (gulong *ulong_)
  667. {
  668. *ulong_ = G_MAXULONG;
  669. }
  670. /**
  671. * gi_marshalling_tests_ulong_inout:
  672. * @ulong_: (inout):
  673. */
  674. void
  675. gi_marshalling_tests_ulong_inout (gulong *ulong_)
  676. {
  677. g_assert_cmpuint (*ulong_, ==, G_MAXULONG);
  678. *ulong_ = 0;
  679. }
  680. gssize
  681. gi_marshalling_tests_ssize_return_max (void)
  682. {
  683. return G_MAXSSIZE;
  684. }
  685. gssize
  686. gi_marshalling_tests_ssize_return_min (void)
  687. {
  688. return G_MINSSIZE;
  689. }
  690. void
  691. gi_marshalling_tests_ssize_in_max (gssize ssize)
  692. {
  693. g_assert_cmpint (ssize, ==, G_MAXSSIZE);
  694. }
  695. void
  696. gi_marshalling_tests_ssize_in_min (gssize ssize)
  697. {
  698. g_assert_cmpint (ssize, ==, G_MINSSIZE);
  699. }
  700. /**
  701. * gi_marshalling_tests_ssize_out_max:
  702. * @ssize: (out):
  703. */
  704. void
  705. gi_marshalling_tests_ssize_out_max (gssize *ssize)
  706. {
  707. *ssize = G_MAXSSIZE;
  708. }
  709. /**
  710. * gi_marshalling_tests_ssize_out_min:
  711. * @ssize: (out):
  712. */
  713. void
  714. gi_marshalling_tests_ssize_out_min (gssize *ssize)
  715. {
  716. *ssize = G_MINSSIZE;
  717. }
  718. /**
  719. * gi_marshalling_tests_ssize_inout_max_min:
  720. * @ssize: (inout):
  721. */
  722. void
  723. gi_marshalling_tests_ssize_inout_max_min (gssize *ssize)
  724. {
  725. g_assert_cmpint (*ssize, ==, G_MAXSSIZE);
  726. *ssize = G_MINSSIZE;
  727. }
  728. /**
  729. * gi_marshalling_tests_ssize_inout_min_max:
  730. * @ssize: (inout):
  731. */
  732. void
  733. gi_marshalling_tests_ssize_inout_min_max (gssize *ssize)
  734. {
  735. g_assert_cmpint (*ssize, ==, G_MINSSIZE);
  736. *ssize = G_MAXSSIZE;
  737. }
  738. gsize
  739. gi_marshalling_tests_size_return (void)
  740. {
  741. return G_MAXSIZE;
  742. }
  743. void
  744. gi_marshalling_tests_size_in (gsize size)
  745. {
  746. g_assert_cmpuint (size, ==, G_MAXSIZE);
  747. }
  748. /**
  749. * gi_marshalling_tests_size_out:
  750. * @size: (out):
  751. */
  752. void
  753. gi_marshalling_tests_size_out (gsize *size)
  754. {
  755. *size = G_MAXSIZE;
  756. }
  757. /**
  758. * gi_marshalling_tests_size_inout:
  759. * @size: (inout):
  760. */
  761. void
  762. gi_marshalling_tests_size_inout (gsize *size)
  763. {
  764. g_assert_cmpuint (*size, ==, G_MAXSIZE);
  765. *size = 0;
  766. }
  767. gfloat
  768. gi_marshalling_tests_float_return (void)
  769. {
  770. return G_MAXFLOAT;
  771. }
  772. void
  773. gi_marshalling_tests_float_in (gfloat v)
  774. {
  775. g_assert_cmpfloat (v, ==, G_MAXFLOAT);
  776. }
  777. /**
  778. * gi_marshalling_tests_float_out:
  779. * @v: (out):
  780. */
  781. void
  782. gi_marshalling_tests_float_out (gfloat *v)
  783. {
  784. *v = G_MAXFLOAT;
  785. }
  786. /**
  787. * gi_marshalling_tests_float_inout:
  788. * @v: (inout):
  789. */
  790. void
  791. gi_marshalling_tests_float_inout (gfloat *v)
  792. {
  793. g_assert_cmpfloat (*v, ==, G_MAXFLOAT);
  794. *v = G_MINFLOAT;
  795. }
  796. gdouble
  797. gi_marshalling_tests_double_return (void)
  798. {
  799. return G_MAXDOUBLE;
  800. }
  801. void
  802. gi_marshalling_tests_double_in (gdouble v)
  803. {
  804. g_assert_cmpfloat (v, ==, G_MAXDOUBLE);
  805. }
  806. /**
  807. * gi_marshalling_tests_double_out:
  808. * @v: (out):
  809. */
  810. void
  811. gi_marshalling_tests_double_out (gdouble *v)
  812. {
  813. *v = G_MAXDOUBLE;
  814. }
  815. /**
  816. * gi_marshalling_tests_double_inout:
  817. * @v: (inout):
  818. */
  819. void
  820. gi_marshalling_tests_double_inout (gdouble *v)
  821. {
  822. g_assert_cmpfloat (*v, ==, G_MAXDOUBLE);
  823. *v = G_MINDOUBLE;
  824. }
  825. time_t
  826. gi_marshalling_tests_time_t_return (void)
  827. {
  828. return 1234567890;
  829. }
  830. void
  831. gi_marshalling_tests_time_t_in (time_t v)
  832. {
  833. g_assert_cmpuint (v, ==, 1234567890);
  834. }
  835. /**
  836. * gi_marshalling_tests_time_t_out:
  837. * @v: (out):
  838. */
  839. void
  840. gi_marshalling_tests_time_t_out (time_t *v)
  841. {
  842. *v = 1234567890;
  843. }
  844. /**
  845. * gi_marshalling_tests_time_t_inout:
  846. * @v: (inout):
  847. */
  848. void
  849. gi_marshalling_tests_time_t_inout (time_t *v)
  850. {
  851. g_assert_cmpuint (*v, ==, 1234567890);
  852. *v = 0;
  853. }
  854. GType
  855. gi_marshalling_tests_gtype_return (void)
  856. {
  857. return G_TYPE_NONE;
  858. }
  859. GType
  860. gi_marshalling_tests_gtype_string_return (void)
  861. {
  862. return G_TYPE_STRING;
  863. }
  864. void
  865. gi_marshalling_tests_gtype_in (GType gtype)
  866. {
  867. g_assert (gtype == G_TYPE_NONE);
  868. }
  869. void
  870. gi_marshalling_tests_gtype_string_in (GType gtype)
  871. {
  872. g_assert (gtype == G_TYPE_STRING);
  873. }
  874. /**
  875. * gi_marshalling_tests_gtype_out:
  876. * @gtype: (out):
  877. */
  878. void
  879. gi_marshalling_tests_gtype_out (GType *gtype)
  880. {
  881. *gtype = G_TYPE_NONE;
  882. }
  883. /**
  884. * gi_marshalling_tests_gtype_string_out:
  885. * @gtype: (out):
  886. */
  887. void
  888. gi_marshalling_tests_gtype_string_out (GType *gtype)
  889. {
  890. *gtype = G_TYPE_STRING;
  891. }
  892. /**
  893. * gi_marshalling_tests_gtype_inout:
  894. * @gtype: (inout):
  895. */
  896. void
  897. gi_marshalling_tests_gtype_inout (GType *gtype)
  898. {
  899. g_assert (*gtype == G_TYPE_NONE);
  900. *gtype = G_TYPE_INT;
  901. }
  902. const gchar *
  903. gi_marshalling_tests_utf8_none_return (void)
  904. {
  905. return GI_MARSHALLING_TESTS_CONSTANT_UTF8;
  906. }
  907. gchar *
  908. gi_marshalling_tests_utf8_full_return (void)
  909. {
  910. return g_strdup (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
  911. }
  912. void
  913. gi_marshalling_tests_utf8_none_in (const gchar *utf8)
  914. {
  915. g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, utf8);
  916. }
  917. /**
  918. * gi_marshalling_tests_utf8_as_uint8array_in:
  919. * @array: (array length=len) (element-type guint8): Byte data that happens to be UTF-8
  920. * @len: Length
  921. *
  922. * Takes data that happens to be UTF-8 as a byte array, to test
  923. * binding conversion from their string type (e.g. JavaScript's
  924. * UTF-16) to UTF-8.
  925. */
  926. void
  927. gi_marshalling_tests_utf8_as_uint8array_in (const guint8 *array, gsize len)
  928. {
  929. gsize orig_len = strlen (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
  930. g_assert_cmpint (orig_len, ==, len);
  931. g_assert (memcmp (GI_MARSHALLING_TESTS_CONSTANT_UTF8, array, len) == 0);
  932. }
  933. /**
  934. * gi_marshalling_tests_utf8_none_out:
  935. * @utf8: (out) (transfer none):
  936. */
  937. void
  938. gi_marshalling_tests_utf8_none_out (gchar **utf8)
  939. {
  940. *utf8 = GI_MARSHALLING_TESTS_CONSTANT_UTF8;
  941. }
  942. /**
  943. * gi_marshalling_tests_utf8_full_out:
  944. * @utf8: (out) (transfer full):
  945. */
  946. void
  947. gi_marshalling_tests_utf8_full_out (gchar **utf8)
  948. {
  949. *utf8 = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_UTF8);
  950. }
  951. /**
  952. * gi_marshalling_tests_utf8_dangling_out:
  953. * @utf8: (out) (transfer full):
  954. */
  955. void
  956. gi_marshalling_tests_utf8_dangling_out (gchar **utf8)
  957. {
  958. /* Intentionally don't touch the pointer to see how
  959. the bindings handle this case. Bindings should be
  960. robust against broken C functions and can initialize
  961. even OUT vlues to NULL.
  962. */
  963. }
  964. /**
  965. * gi_marshalling_tests_utf8_none_inout:
  966. * @utf8: (inout) (transfer none):
  967. */
  968. void
  969. gi_marshalling_tests_utf8_none_inout (gchar **utf8)
  970. {
  971. g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
  972. *utf8 = "";
  973. }
  974. /**
  975. * gi_marshalling_tests_utf8_full_inout:
  976. * @utf8: (inout) (transfer full):
  977. */
  978. void
  979. gi_marshalling_tests_utf8_full_inout (gchar **utf8)
  980. {
  981. g_assert_cmpstr (GI_MARSHALLING_TESTS_CONSTANT_UTF8, ==, *utf8);
  982. g_free (*utf8);
  983. *utf8 = g_strdup ("");
  984. }
  985. /**
  986. * gi_marshalling_tests_init_function:
  987. * @n_args: (inout) (allow-none): number of args
  988. * @argv: (inout) (array length=n_args) (allow-none): args
  989. *
  990. * This is like gtk_init().
  991. */
  992. gboolean
  993. gi_marshalling_tests_init_function (gint *n_args, char ***argv)
  994. {
  995. if (n_args == NULL)
  996. return TRUE;
  997. if (*n_args == 0)
  998. return TRUE;
  999. (*n_args)--;
  1000. g_assert (argv != NULL);
  1001. /* we have transfer ownership full, so we need to free the element ourself */
  1002. g_free ((*argv)[*n_args]);
  1003. (*argv)[*n_args] = NULL;
  1004. return TRUE;
  1005. }
  1006. /**
  1007. * gi_marshalling_tests_array_fixed_int_return:
  1008. *
  1009. * Returns: (array fixed-size=4):
  1010. */
  1011. const gint *
  1012. gi_marshalling_tests_array_fixed_int_return (void)
  1013. {
  1014. static gint ints[] = { -1, 0, 1, 2 };
  1015. return ints;
  1016. }
  1017. /**
  1018. * gi_marshalling_tests_array_fixed_short_return:
  1019. *
  1020. * Returns: (array fixed-size=4):
  1021. */
  1022. const gshort *
  1023. gi_marshalling_tests_array_fixed_short_return (void)
  1024. {
  1025. static gshort shorts[] = { -1, 0, 1, 2 };
  1026. return shorts;
  1027. }
  1028. /**
  1029. * gi_marshalling_tests_array_fixed_int_in:
  1030. * @ints: (array fixed-size=4):
  1031. */
  1032. void
  1033. gi_marshalling_tests_array_fixed_int_in (const gint *ints)
  1034. {
  1035. g_assert_cmpint (ints[0], ==, -1);
  1036. g_assert_cmpint (ints[1], ==, 0);
  1037. g_assert_cmpint (ints[2], ==, 1);
  1038. g_assert_cmpint (ints[3], ==, 2);
  1039. }
  1040. /**
  1041. * gi_marshalling_tests_array_fixed_short_in:
  1042. * @shorts: (array fixed-size=4):
  1043. */
  1044. void
  1045. gi_marshalling_tests_array_fixed_short_in (const gshort *shorts)
  1046. {
  1047. g_assert_cmpint (shorts[0], ==, -1);
  1048. g_assert_cmpint (shorts[1], ==, 0);
  1049. g_assert_cmpint (shorts[2], ==, 1);
  1050. g_assert_cmpint (shorts[3], ==, 2);
  1051. }
  1052. /**
  1053. * gi_marshalling_tests_array_fixed_out:
  1054. * @ints: (out) (array fixed-size=4) (transfer none):
  1055. */
  1056. void
  1057. gi_marshalling_tests_array_fixed_out (gint **ints)
  1058. {
  1059. static gint values[] = { -1, 0, 1, 2 };
  1060. *ints = values;
  1061. }
  1062. /**
  1063. * gi_marshalling_tests_array_fixed_out_struct:
  1064. * @structs: (out) (array fixed-size=2) (transfer none):
  1065. */
  1066. void
  1067. gi_marshalling_tests_array_fixed_out_struct (GIMarshallingTestsSimpleStruct **structs)
  1068. {
  1069. static GIMarshallingTestsSimpleStruct *values;
  1070. if (values == NULL)
  1071. {
  1072. values = g_new (GIMarshallingTestsSimpleStruct, 2);
  1073. values[0].long_ = 7;
  1074. values[0].int8 = 6;
  1075. values[1].long_ = 6;
  1076. values[1].int8 = 7;
  1077. }
  1078. *structs = values;
  1079. }
  1080. /**
  1081. * gi_marshalling_tests_array_fixed_inout:
  1082. * @ints: (inout) (array fixed-size=4) (transfer none):
  1083. */
  1084. void
  1085. gi_marshalling_tests_array_fixed_inout (gint **ints)
  1086. {
  1087. static gint values[] = { 2, 1, 0, -1 };
  1088. g_assert_cmpint ((*ints)[0], ==, -1);
  1089. g_assert_cmpint ((*ints)[1], ==, 0);
  1090. g_assert_cmpint ((*ints)[2], ==, 1);
  1091. g_assert_cmpint ((*ints)[3], ==, 2);
  1092. *ints = values;
  1093. }
  1094. /**
  1095. * gi_marshalling_tests_array_return:
  1096. *
  1097. * Returns: (array length=length):
  1098. */
  1099. const gint *
  1100. gi_marshalling_tests_array_return (gint *length)
  1101. {
  1102. static gint ints[] = { -1, 0, 1, 2 };
  1103. *length = 4;
  1104. return ints;
  1105. }
  1106. /**
  1107. * gi_marshalling_tests_array_return_etc:
  1108. * @first:
  1109. * @length: (out):
  1110. * @last:
  1111. * @sum: (out):
  1112. *
  1113. * Returns: (array length=length):
  1114. */
  1115. const gint *
  1116. gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum)
  1117. {
  1118. static gint ints[] = { -1, 0, 1, 2 };
  1119. ints[0] = first;
  1120. ints[3] = last;
  1121. *sum = first + last;
  1122. *length = 4;
  1123. return ints;
  1124. }
  1125. /**
  1126. * gi_marshalling_tests_array_in:
  1127. * @ints: (array length=length):
  1128. * @length:
  1129. */
  1130. void
  1131. gi_marshalling_tests_array_in (const gint *ints, gint length)
  1132. {
  1133. g_assert_cmpint (length, ==, 4);
  1134. g_assert_cmpint (ints[0], ==, -1);
  1135. g_assert_cmpint (ints[1], ==, 0);
  1136. g_assert_cmpint (ints[2], ==, 1);
  1137. g_assert_cmpint (ints[3], ==, 2);
  1138. }
  1139. /**
  1140. * gi_marshalling_tests_array_in_len_before:
  1141. * @length:
  1142. * @ints: (array length=length):
  1143. */
  1144. void
  1145. gi_marshalling_tests_array_in_len_before (gint length, const gint *ints)
  1146. {
  1147. gi_marshalling_tests_array_in (ints, length);
  1148. }
  1149. /**
  1150. * gi_marshalling_tests_array_in_len_zero_terminated:
  1151. * @ints: (array length=length zero-terminated):
  1152. * @length:
  1153. */
  1154. void
  1155. gi_marshalling_tests_array_in_len_zero_terminated (const gint *ints, gint length)
  1156. {
  1157. g_assert_cmpint (length, ==, 4);
  1158. g_assert_cmpint (ints[0], ==, -1);
  1159. g_assert_cmpint (ints[1], ==, 0);
  1160. g_assert_cmpint (ints[2], ==, 1);
  1161. g_assert_cmpint (ints[3], ==, 2);
  1162. /* One past the end, null terminator */
  1163. g_assert_cmpint (ints[4], ==, 0);
  1164. }
  1165. /**
  1166. * gi_marshalling_tests_array_string_in:
  1167. * @strings: (array length=length):
  1168. */
  1169. void
  1170. gi_marshalling_tests_array_string_in (const gchar **strings, gint length)
  1171. {
  1172. g_assert_cmpint (length, ==, 2);
  1173. g_assert_cmpstr (strings[0], ==, "foo");
  1174. g_assert_cmpstr (strings[1], ==, "bar");
  1175. }
  1176. /**
  1177. * gi_marshalling_tests_array_uint8_in:
  1178. * @chars: (array length=length):
  1179. */
  1180. void
  1181. gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
  1182. {
  1183. g_assert_cmpint (length, ==, 4);
  1184. g_assert (chars[0] == 'a');
  1185. g_assert (chars[1] == 'b');
  1186. g_assert (chars[2] == 'c');
  1187. g_assert (chars[3] == 'd');
  1188. }
  1189. /**
  1190. * gi_marshalling_tests_array_struct_in:
  1191. * @structs: (array length=length):
  1192. */
  1193. void
  1194. gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length)
  1195. {
  1196. g_assert_cmpint (length, ==, 3);
  1197. g_assert_cmpint (structs[0]->long_, ==, 1);
  1198. g_assert_cmpint (structs[1]->long_, ==, 2);
  1199. g_assert_cmpint (structs[2]->long_, ==, 3);
  1200. }
  1201. /**
  1202. * gi_marshalling_tests_array_struct_value_in:
  1203. * @structs: (array length=length):
  1204. */
  1205. void
  1206. gi_marshalling_tests_array_struct_value_in (GIMarshallingTestsBoxedStruct *structs, gint length)
  1207. {
  1208. g_assert_cmpint (length, ==, 3);
  1209. g_assert_cmpint (structs[0].long_, ==, 1);
  1210. g_assert_cmpint (structs[1].long_, ==, 2);
  1211. g_assert_cmpint (structs[2].long_, ==, 3);
  1212. }
  1213. /**
  1214. * gi_marshalling_tests_array_simple_struct_in:
  1215. * @structs: (array length=length):
  1216. */
  1217. void
  1218. gi_marshalling_tests_array_simple_struct_in (GIMarshallingTestsSimpleStruct *structs, gint length)
  1219. {
  1220. g_assert_cmpint (length, ==, 3);
  1221. g_assert_cmpint (structs[0].long_, ==, 1);
  1222. g_assert_cmpint (structs[1].long_, ==, 2);
  1223. g_assert_cmpint (structs[2].long_, ==, 3);
  1224. }
  1225. /**
  1226. * gi_marshalling_tests_multi_array_key_value_in:
  1227. * @keys: (array length=length):
  1228. * @values: (array length=length):
  1229. */
  1230. void
  1231. gi_marshalling_tests_multi_array_key_value_in (gint length, const gchar **keys, const GValue *values)
  1232. {
  1233. g_assert_cmpint (length, ==, 3);
  1234. g_assert_cmpstr ("one", ==, keys[0]);
  1235. g_assert_cmpint (g_value_get_int (&values[0]), ==, 1);
  1236. g_assert_cmpstr ("two", ==, keys[1]);
  1237. g_assert_cmpint (g_value_get_int (&values[1]), ==, 2);
  1238. g_assert_cmpstr ("three", ==, keys[2]);
  1239. g_assert_cmpint (g_value_get_int (&values[2]), ==, 3);
  1240. }
  1241. /**
  1242. * gi_marshalling_tests_array_struct_take_in:
  1243. * @structs: (array length=length) (transfer full):
  1244. */
  1245. void
  1246. gi_marshalling_tests_array_struct_take_in (GIMarshallingTestsBoxedStruct **structs, gint length)
  1247. {
  1248. gi_marshalling_tests_array_struct_in (structs, length);
  1249. /* only really useful if run in valgrind actually */
  1250. gi_marshalling_tests_boxed_struct_free (structs[0]);
  1251. gi_marshalling_tests_boxed_struct_free (structs[1]);
  1252. gi_marshalling_tests_boxed_struct_free (structs[2]);
  1253. g_free (structs);
  1254. }
  1255. /**
  1256. * gi_marshalling_tests_array_enum_in:
  1257. * @_enum: (array length=length) (transfer none):
  1258. * @length:
  1259. */
  1260. void
  1261. gi_marshalling_tests_array_enum_in (GIMarshallingTestsEnum *v, gint length)
  1262. {
  1263. g_assert_cmpint (length, ==, 3);
  1264. g_assert_cmpint (v[0], ==, GI_MARSHALLING_TESTS_ENUM_VALUE1);
  1265. g_assert_cmpint (v[1], ==, GI_MARSHALLING_TESTS_ENUM_VALUE2);
  1266. g_assert_cmpint (v[2], ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
  1267. }
  1268. /**
  1269. * gi_marshalling_tests_array_in_guint64_len:
  1270. * @ints: (array length=length) (transfer none):
  1271. * @length:
  1272. */
  1273. void
  1274. gi_marshalling_tests_array_in_guint64_len (const gint *ints, guint64 length)
  1275. {
  1276. g_assert_cmpint (length, ==, 4);
  1277. gi_marshalling_tests_array_in (ints, length);
  1278. }
  1279. /**
  1280. * gi_marshalling_tests_array_in_guint8_len:
  1281. * @ints: (array length=length) (transfer none):
  1282. * @length:
  1283. */
  1284. void
  1285. gi_marshalling_tests_array_in_guint8_len (const gint *ints, guint8 length)
  1286. {
  1287. g_assert_cmpint (length, ==, 4);
  1288. gi_marshalling_tests_array_in (ints, length);
  1289. }
  1290. /**
  1291. * gi_marshalling_tests_array_out:
  1292. * @ints: (out) (array length=length) (transfer none):
  1293. */
  1294. void
  1295. gi_marshalling_tests_array_out (gint **ints, gint *length)
  1296. {
  1297. static gint values[] = { -1, 0, 1, 2 };
  1298. *length = 4;
  1299. *ints = values;
  1300. }
  1301. /**
  1302. * gi_marshalling_tests_array_out_etc:
  1303. * @first:
  1304. * @ints: (out) (array length=length) (transfer none):
  1305. * @length: (out):
  1306. * @last:
  1307. * @sum: (out):
  1308. */
  1309. void
  1310. gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
  1311. {
  1312. static gint values[] = { -1, 0, 1, 2 };
  1313. values[0] = first;
  1314. values[3] = last;
  1315. *sum = first + last;
  1316. *length = 4;
  1317. *ints = values;
  1318. }
  1319. /**
  1320. * gi_marshalling_tests_array_inout:
  1321. * @ints: (inout) (array length=length) (transfer none):
  1322. * @length: (inout):
  1323. */
  1324. void
  1325. gi_marshalling_tests_array_inout (gint **ints, gint *length)
  1326. {
  1327. static gint values[] = { -2, -1, 0, 1, 2 };
  1328. g_assert_cmpint (*length, ==, 4);
  1329. g_assert_cmpint ((*ints)[0], ==, -1);
  1330. g_assert_cmpint ((*ints)[1], ==, 0);
  1331. g_assert_cmpint ((*ints)[2], ==, 1);
  1332. g_assert_cmpint ((*ints)[3], ==, 2);
  1333. *length = 5;
  1334. *ints = values;
  1335. }
  1336. /**
  1337. * gi_marshalling_tests_array_inout_etc:
  1338. * @first:
  1339. * @ints: (inout) (array length=length) (transfer none):
  1340. * @length: (inout):
  1341. * @last:
  1342. * @sum: (out):
  1343. */
  1344. void
  1345. gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum)
  1346. {
  1347. static gint values[] = { -2, -1, 0, 1, 2 };
  1348. g_assert_cmpint (*length, ==, 4);
  1349. g_assert_cmpint ((*ints)[0], ==, -1);
  1350. g_assert_cmpint ((*ints)[1], ==, 0);
  1351. g_assert_cmpint ((*ints)[2], ==, 1);
  1352. g_assert_cmpint ((*ints)[3], ==, 2);
  1353. values[0] = first;
  1354. values[4] = last;
  1355. *sum = first + last;
  1356. *length = 5;
  1357. *ints = values;
  1358. }
  1359. /**
  1360. * gi_marshalling_tests_array_in_nonzero_nonlen:
  1361. * @first:
  1362. * @chars: (array):
  1363. */
  1364. void
  1365. gi_marshalling_tests_array_in_nonzero_nonlen (gint first, const guint8 *chars)
  1366. {
  1367. g_assert (chars[0] == 'a');
  1368. g_assert (chars[1] == 'b');
  1369. g_assert (chars[2] == 'c');
  1370. g_assert (chars[3] == 'd');
  1371. }
  1372. /**
  1373. * gi_marshalling_tests_array_zero_terminated_return:
  1374. *
  1375. * Returns: (array zero-terminated) (transfer none):
  1376. */
  1377. gchar **
  1378. gi_marshalling_tests_array_zero_terminated_return (void)
  1379. {
  1380. static gchar *values[] = { "0", "1", "2", NULL };
  1381. return values;
  1382. }
  1383. /**
  1384. * gi_marshalling_tests_array_zero_terminated_return_null:
  1385. *
  1386. * Returns: (array zero-terminated) (transfer none):
  1387. */
  1388. gchar **
  1389. gi_marshalling_tests_array_zero_terminated_return_null (void)
  1390. {
  1391. return NULL;
  1392. }
  1393. /**
  1394. * gi_marshalling_tests_array_zero_terminated_return_struct:
  1395. *
  1396. * Returns: (array zero-terminated) (transfer full):
  1397. */
  1398. GIMarshallingTestsBoxedStruct **
  1399. gi_marshalling_tests_array_zero_terminated_return_struct (void)
  1400. {
  1401. GIMarshallingTestsBoxedStruct **ret = (GIMarshallingTestsBoxedStruct **) g_new (gpointer, 4);
  1402. ret[0] = gi_marshalling_tests_boxed_struct_new ();
  1403. ret[0]->long_ = 42;
  1404. ret[1] = gi_marshalling_tests_boxed_struct_new ();
  1405. ret[1]->long_ = 43;
  1406. ret[2] = gi_marshalling_tests_boxed_struct_new ();
  1407. ret[2]->long_ = 44;
  1408. ret[3] = NULL;
  1409. return ret;
  1410. }
  1411. /**
  1412. * gi_marshalling_tests_array_zero_terminated_in:
  1413. * @utf8s: (array zero-terminated) (transfer none):
  1414. */
  1415. void
  1416. gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s)
  1417. {
  1418. g_assert (g_strv_length (utf8s));
  1419. g_assert_cmpstr (utf8s[0], ==, "0");
  1420. g_assert_cmpstr (utf8s[1], ==, "1");
  1421. g_assert_cmpstr (utf8s[2], ==, "2");
  1422. }
  1423. /**
  1424. * gi_marshalling_tests_array_zero_terminated_out:
  1425. * @utf8s: (out) (array zero-terminated) (transfer none):
  1426. */
  1427. void
  1428. gi_marshalling_tests_array_zero_terminated_out (gchar *** utf8s)
  1429. {
  1430. static gchar *values[] = { "0", "1", "2", NULL };
  1431. *utf8s = values;
  1432. }
  1433. /**
  1434. * gi_marshalling_tests_array_zero_terminated_inout:
  1435. * @utf8s: (inout) (array zero-terminated) (transfer none):
  1436. */
  1437. void
  1438. gi_marshalling_tests_array_zero_terminated_inout (gchar *** utf8s)
  1439. {
  1440. static gchar *values[] = { "-1", "0", "1", "2", NULL };
  1441. g_assert (g_strv_length (*utf8s));
  1442. g_assert_cmpstr ((*utf8s)[0], ==, "0");
  1443. g_assert_cmpstr ((*utf8s)[1], ==, "1");
  1444. g_assert_cmpstr ((*utf8s)[2], ==, "2");
  1445. *utf8s = values;
  1446. }
  1447. /**
  1448. * gi_marshalling_tests_array_gvariant_none_in:
  1449. * @variants: (array zero-terminated) (transfer none):
  1450. *
  1451. * Returns: (array zero-terminated) (transfer none):
  1452. */
  1453. GVariant **
  1454. gi_marshalling_tests_array_gvariant_none_in (GVariant **variants)
  1455. {
  1456. /* Use a static container to detect if someone tries to free it */
  1457. static GVariant *private_container[3] = { NULL, NULL, NULL };
  1458. if (private_container[0] == NULL)
  1459. {
  1460. private_container[0] = g_variant_new_int32 (27);
  1461. private_container[1] = g_variant_new_string ("Hello");
  1462. }
  1463. g_assert (variants != NULL);
  1464. g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
  1465. g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
  1466. g_assert (variants[2] == NULL);
  1467. return private_container;
  1468. }
  1469. /**
  1470. * gi_marshalling_tests_array_gvariant_container_in:
  1471. * @variants: (array zero-terminated) (transfer container):
  1472. *
  1473. * Returns: (array zero-terminated) (transfer container):
  1474. */
  1475. GVariant **
  1476. gi_marshalling_tests_array_gvariant_container_in (GVariant **variants)
  1477. {
  1478. GVariant **container;
  1479. g_assert (variants != NULL);
  1480. g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
  1481. g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
  1482. g_assert (variants[2] == NULL);
  1483. container = g_new0 (GVariant *, 3);
  1484. container[0] = variants[0];
  1485. container[1] = variants[1];
  1486. g_free (variants);
  1487. return container;
  1488. }
  1489. /**
  1490. * gi_marshalling_tests_array_gvariant_full_in:
  1491. * @variants: (array zero-terminated) (transfer full):
  1492. *
  1493. * Returns: (array zero-terminated) (transfer full):
  1494. */
  1495. GVariant **
  1496. gi_marshalling_tests_array_gvariant_full_in (GVariant **variants)
  1497. {
  1498. GVariant **container;
  1499. g_assert (variants != NULL);
  1500. g_assert_cmpint (g_variant_get_int32 (variants[0]), ==, 27);
  1501. g_assert_cmpstr (g_variant_get_string (variants[1], NULL), ==, "Hello");
  1502. g_assert (variants[2] == NULL);
  1503. /* To catch different behaviors we reconstruct one variant from scratch,
  1504. * while leaving the other untouched. Both approaches are legal with full
  1505. * transfer in and out */
  1506. container = g_new0 (GVariant *, 3);
  1507. container[0] = g_variant_new_int32 (g_variant_get_int32 (variants[0]));
  1508. g_variant_unref (variants[0]);
  1509. container[1] = variants[1];
  1510. g_free (variants);
  1511. return container;
  1512. }
  1513. /**
  1514. * gi_marshalling_tests_garray_int_none_return:
  1515. *
  1516. * Returns: (element-type gint) (transfer none):
  1517. */
  1518. GArray *
  1519. gi_marshalling_tests_garray_int_none_return (void)
  1520. {
  1521. static GArray *v = NULL;
  1522. gint i;
  1523. if (v == NULL)
  1524. {
  1525. v = g_array_new (TRUE, TRUE, sizeof (gint));
  1526. for (i = -1; i < 3; i++)
  1527. g_array_append_val (v, i);
  1528. }
  1529. return v;
  1530. }
  1531. /**
  1532. * gi_marshalling_tests_garray_uint64_none_return:
  1533. *
  1534. * Returns: (element-type guint64) (transfer none):
  1535. */
  1536. GArray *
  1537. gi_marshalling_tests_garray_uint64_none_return (void)
  1538. {
  1539. static GArray *array = NULL;
  1540. guint64 i;
  1541. if (array == NULL)
  1542. {
  1543. array = g_array_new (TRUE, TRUE, sizeof (guint64));
  1544. i = 0;
  1545. g_array_append_val (array, i);
  1546. i = G_MAXUINT64;
  1547. g_array_append_val (array, i);
  1548. }
  1549. return array;
  1550. }
  1551. /**
  1552. * gi_marshalling_tests_garray_utf8_none_return:
  1553. *
  1554. * Returns: (element-type utf8) (transfer none):
  1555. */
  1556. GArray *
  1557. gi_marshalling_tests_garray_utf8_none_return (void)
  1558. {
  1559. static GArray *array = NULL;
  1560. static gchar *values[] = { "0", "1", "2", NULL };
  1561. gint i;
  1562. if (array == NULL)
  1563. {
  1564. array = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1565. for (i = 0; values[i]; i++)
  1566. g_array_append_val (array, values[i]);
  1567. }
  1568. return array;
  1569. }
  1570. /**
  1571. * gi_marshalling_tests_garray_utf8_container_return:
  1572. *
  1573. * Returns: (element-type utf8) (transfer container):
  1574. */
  1575. GArray *
  1576. gi_marshalling_tests_garray_utf8_container_return (void)
  1577. {
  1578. GArray *array = NULL;
  1579. static gchar *values[] = { "0", "1", "2", NULL };
  1580. gint i;
  1581. array = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1582. for (i = 0; values[i]; i++)
  1583. g_array_append_val (array, values[i]);
  1584. return array;
  1585. }
  1586. /**
  1587. * gi_marshalling_tests_garray_utf8_full_return:
  1588. *
  1589. * Returns: (element-type utf8) (transfer full):
  1590. */
  1591. GArray *
  1592. gi_marshalling_tests_garray_utf8_full_return (void)
  1593. {
  1594. GArray *array = NULL;
  1595. static gchar *values[] = { "0", "1", "2", NULL };
  1596. gint i;
  1597. array = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1598. for (i = 0; values[i]; i++)
  1599. {
  1600. gchar *str = g_strdup (values[i]);
  1601. g_array_append_val (array, str);
  1602. }
  1603. return array;
  1604. }
  1605. /**
  1606. * gi_marshalling_tests_garray_int_none_in:
  1607. * @array_: (element-type gint) (transfer none):
  1608. */
  1609. void
  1610. gi_marshalling_tests_garray_int_none_in (GArray *array_)
  1611. {
  1612. g_assert_cmpint (array_->len, ==, 4);
  1613. g_assert_cmpint (g_array_index (array_, gint, 0), ==, -1);
  1614. g_assert_cmpint (g_array_index (array_, gint, 1), ==, 0);
  1615. g_assert_cmpint (g_array_index (array_, gint, 2), ==, 1);
  1616. g_assert_cmpint (g_array_index (array_, gint, 3), ==, 2);
  1617. }
  1618. /**
  1619. * gi_marshalling_tests_garray_uint64_none_in:
  1620. * @array_: (element-type guint64) (transfer none):
  1621. */
  1622. void
  1623. gi_marshalling_tests_garray_uint64_none_in (GArray *array_)
  1624. {
  1625. g_assert_cmpint (array_->len, ==, 2);
  1626. g_assert_cmpint (g_array_index (array_, guint64, 0), ==, 0);
  1627. g_assert_cmpint (g_array_index (array_, guint64, 1), ==, G_MAXUINT64);
  1628. }
  1629. /**
  1630. * gi_marshalling_tests_garray_utf8_none_in:
  1631. * @array_: (element-type utf8) (transfer none):
  1632. */
  1633. void
  1634. gi_marshalling_tests_garray_utf8_none_in (GArray *array_)
  1635. {
  1636. g_assert_cmpint (array_->len, ==, 3);
  1637. g_assert_cmpstr (g_array_index (array_, gchar *, 0), ==, "0");
  1638. g_assert_cmpstr (g_array_index (array_, gchar *, 1), ==, "1");
  1639. g_assert_cmpstr (g_array_index (array_, gchar *, 2), ==, "2");
  1640. }
  1641. /**
  1642. * gi_marshalling_tests_garray_utf8_none_out:
  1643. * @array_: (out) (element-type utf8) (transfer none):
  1644. */
  1645. void
  1646. gi_marshalling_tests_garray_utf8_none_out (GArray **array_)
  1647. {
  1648. static GArray *internal = NULL;
  1649. static gchar *values[] = { "0", "1", "2", NULL };
  1650. gint i;
  1651. if (internal == NULL)
  1652. {
  1653. internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1654. for (i = 0; values[i]; i++)
  1655. g_array_append_val (internal, values[i]);
  1656. }
  1657. *array_ = internal;
  1658. }
  1659. /**
  1660. * gi_marshalling_tests_garray_utf8_container_out:
  1661. * @array_: (out) (element-type utf8) (transfer container):
  1662. */
  1663. void
  1664. gi_marshalling_tests_garray_utf8_container_out (GArray **array_)
  1665. {
  1666. static gchar *values[] = { "0", "1", "2", NULL };
  1667. gint i;
  1668. *array_ = NULL;
  1669. *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1670. for (i = 0; values[i]; i++)
  1671. g_array_append_val (*array_, values[i]);
  1672. }
  1673. /**
  1674. * gi_marshalling_tests_garray_utf8_full_out:
  1675. * @array_: (out) (element-type utf8) (transfer full):
  1676. */
  1677. void
  1678. gi_marshalling_tests_garray_utf8_full_out (GArray **array_)
  1679. {
  1680. static gchar *values[] = { "0", "1", "2", NULL };
  1681. gint i;
  1682. *array_ = NULL;
  1683. *array_ = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1684. for (i = 0; values[i]; i++)
  1685. {
  1686. gchar *str = g_strdup (values[i]);
  1687. g_array_append_val (*array_, str);
  1688. }
  1689. }
  1690. /**
  1691. * gi_marshalling_tests_garray_utf8_full_out_caller_allocated:
  1692. * @array_: (out caller-allocates) (array) (element-type utf8) (transfer full):
  1693. */
  1694. void
  1695. gi_marshalling_tests_garray_utf8_full_out_caller_allocated (GArray *array_)
  1696. {
  1697. static gchar *values[] = { "0", "1", "2", NULL };
  1698. gint i;
  1699. g_array_set_size (array_, 0);
  1700. for (i = 0; values[i]; i++)
  1701. {
  1702. gchar *str = g_strdup (values[i]);
  1703. g_array_append_val (array_, str);
  1704. }
  1705. }
  1706. /**
  1707. * gi_marshalling_tests_garray_utf8_none_inout:
  1708. * @array_: (inout) (element-type utf8) (transfer none):
  1709. */
  1710. void
  1711. gi_marshalling_tests_garray_utf8_none_inout (GArray **array_)
  1712. {
  1713. static GArray *internal = NULL;
  1714. static gchar *values[] = { "-2", "-1", "0", "1", NULL };
  1715. gint i;
  1716. g_assert_cmpint ((*array_)->len, ==, 3);
  1717. g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
  1718. g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
  1719. g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
  1720. if (internal == NULL)
  1721. {
  1722. internal = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1723. for (i = 0; values[i]; i++)
  1724. g_array_append_val (internal, values[i]);
  1725. }
  1726. *array_ = internal;
  1727. }
  1728. /**
  1729. * gi_marshalling_tests_garray_utf8_container_inout:
  1730. * @array_: (inout) (element-type utf8) (transfer container):
  1731. */
  1732. void
  1733. gi_marshalling_tests_garray_utf8_container_inout (GArray **array_)
  1734. {
  1735. static gchar *val1 = "-2";
  1736. static gchar *val2 = "-1";
  1737. static gchar *val3 = "0";
  1738. static gchar *val4 = "1";
  1739. GArray *result;
  1740. g_assert_cmpint ((*array_)->len, ==, 3);
  1741. g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
  1742. g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
  1743. g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
  1744. result = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1745. g_array_append_val (result, val1);
  1746. g_array_append_val (result, val2);
  1747. g_array_append_val (result, val3);
  1748. g_array_append_val (result, val4);
  1749. g_array_unref (*array_);
  1750. *array_ = result;
  1751. }
  1752. /**
  1753. * gi_marshalling_tests_garray_utf8_full_inout:
  1754. * @array_: (inout) (element-type utf8) (transfer full):
  1755. */
  1756. void
  1757. gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
  1758. {
  1759. static gchar *val1 = "-1";
  1760. static gchar *val2 = "-2";
  1761. gchar *val;
  1762. GArray *result;
  1763. g_assert_cmpint ((*array_)->len, ==, 3);
  1764. g_assert_cmpstr (g_array_index (*array_, gchar *, 0), ==, "0");
  1765. g_assert_cmpstr (g_array_index (*array_, gchar *, 1), ==, "1");
  1766. g_assert_cmpstr (g_array_index (*array_, gchar *, 2), ==, "2");
  1767. result = g_array_new (TRUE, TRUE, sizeof (gchar *));
  1768. val = g_strdup (val2);
  1769. g_array_append_val (result, val);
  1770. val = g_strdup (val1);
  1771. g_array_append_val (result, val);
  1772. val = g_strdup ("0");
  1773. g_array_append_val (result, val);
  1774. val = g_strdup ("1");
  1775. g_array_append_val (result, val);
  1776. g_array_unref (*array_);
  1777. *array_ = result;
  1778. }
  1779. /**
  1780. * gi_marshalling_tests_gptrarray_utf8_none_return:
  1781. *
  1782. * Returns: (element-type utf8) (transfer none):
  1783. */
  1784. GPtrArray *
  1785. gi_marshalling_tests_gptrarray_utf8_none_return (void)
  1786. {
  1787. static GPtrArray *parray = NULL;
  1788. static gchar *values[] = { "0", "1", "2" };
  1789. gint i;
  1790. if (parray == NULL)
  1791. {
  1792. parray = g_ptr_array_new ();
  1793. for (i = 0; i < 3; i++)
  1794. g_ptr_array_add (parray, (gpointer) values[i]);
  1795. }
  1796. return parray;
  1797. }
  1798. /**
  1799. * gi_marshalling_tests_gptrarray_utf8_container_return:
  1800. *
  1801. * Returns: (element-type utf8) (transfer container):
  1802. */
  1803. GPtrArray *
  1804. gi_marshalling_tests_gptrarray_utf8_container_return (void)
  1805. {
  1806. GPtrArray *parray = NULL;
  1807. static gchar *values[] = { "0", "1", "2", NULL };
  1808. gint i;
  1809. parray = g_ptr_array_new ();
  1810. for (i = 0; values[i]; i++)
  1811. g_ptr_array_add (parray, (gpointer) values[i]);
  1812. return parray;
  1813. }
  1814. /**
  1815. * gi_marshalling_tests_gptrarray_utf8_full_return:
  1816. *
  1817. * Returns: (element-type utf8) (transfer full):
  1818. */
  1819. GPtrArray *
  1820. gi_marshalling_tests_gptrarray_utf8_full_return (void)
  1821. {
  1822. GPtrArray *parray = NULL;
  1823. static gchar *values[] = { "0", "1", "2", NULL };
  1824. gint i;
  1825. parray = g_ptr_array_new ();
  1826. for (i = 0; values[i]; i++)
  1827. {
  1828. gchar *str = g_strdup (values[i]);
  1829. g_ptr_array_add (parray, (gpointer) str);
  1830. }
  1831. return parray;
  1832. }
  1833. /**
  1834. * gi_marshalling_tests_gptrarray_utf8_none_in:
  1835. * @parray_: (element-type utf8) (transfer none):
  1836. */
  1837. void
  1838. gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
  1839. {
  1840. g_assert_cmpint (parray_->len, ==, 3);
  1841. g_assert_cmpstr (g_ptr_array_index (parray_, 0), ==, "0");
  1842. g_assert_cmpstr (g_ptr_array_index (parray_, 1), ==, "1");
  1843. g_assert_cmpstr (g_ptr_array_index (parray_, 2), ==, "2");
  1844. }
  1845. /**
  1846. * gi_marshalling_tests_gptrarray_utf8_none_out:
  1847. * @parray_: (out) (element-type utf8) (transfer none):
  1848. */
  1849. void
  1850. gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
  1851. {
  1852. static GPtrArray *internal = NULL;
  1853. static gchar *values[] = { "0", "1", "2", NULL };
  1854. gint i;
  1855. if (internal == NULL)
  1856. {
  1857. internal = g_ptr_array_new ();
  1858. for (i = 0; values[i]; i++)
  1859. g_ptr_array_add (internal, (gpointer) values[i]);
  1860. }
  1861. *parray_ = internal;
  1862. }
  1863. /**
  1864. * gi_marshalling_tests_gptrarray_utf8_container_out:
  1865. * @parray_: (out) (element-type utf8) (transfer container):
  1866. */
  1867. void
  1868. gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
  1869. {
  1870. static gchar *values[] = { "0", "1", "2", NULL };
  1871. gint i;
  1872. *parray_ = NULL;
  1873. *parray_ = g_ptr_array_new ();
  1874. for (i = 0; values[i]; i++)
  1875. g_ptr_array_add (*parray_, (gpointer) values[i]);
  1876. }
  1877. /**
  1878. * gi_marshalling_tests_gptrarray_utf8_full_out:
  1879. * @parray_: (out) (element-type utf8) (transfer full):
  1880. */
  1881. void
  1882. gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
  1883. {
  1884. static gchar *values[] = { "0", "1", "2", NULL };
  1885. gint i;
  1886. *parray_ = NULL;
  1887. *parray_ = g_ptr_array_new ();
  1888. for (i = 0; values[i]; i++)
  1889. {
  1890. gchar *str = g_strdup (values[i]);
  1891. g_ptr_array_add (*parray_, (gpointer) str);
  1892. }
  1893. }
  1894. /**
  1895. * gi_marshalling_tests_gptrarray_utf8_none_inout:
  1896. * @parray_: (inout) (element-type utf8) (transfer none):
  1897. */
  1898. void
  1899. gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
  1900. {
  1901. static GPtrArray *internal = NULL;
  1902. static gchar *values[] = { "-2", "-1", "0", "1", NULL };
  1903. gint i;
  1904. g_assert_cmpint ((*parray_)->len, ==, 3);
  1905. g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
  1906. g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
  1907. g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
  1908. if (internal == NULL)
  1909. {
  1910. internal = g_ptr_array_new ();
  1911. for (i = 0; values[i]; i++)
  1912. g_ptr_array_add (internal, (gpointer) values[i]);
  1913. }
  1914. *parray_ = internal;
  1915. }
  1916. /**
  1917. * gi_marshalling_tests_gptrarray_utf8_container_inout:
  1918. * @parray_: (inout) (element-type utf8) (transfer container):
  1919. */
  1920. void
  1921. gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
  1922. {
  1923. static gchar *val1 = "-2";
  1924. static gchar *val2 = "-1";
  1925. static gchar *val3 = "0";
  1926. static gchar *val4 = "1";
  1927. GPtrArray *result;
  1928. g_assert_cmpint ((*parray_)->len, ==, 3);
  1929. g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
  1930. g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
  1931. g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
  1932. result = g_ptr_array_new ();
  1933. g_ptr_array_add (result, (gpointer) val1);
  1934. g_ptr_array_add (result, (gpointer) val2);
  1935. g_ptr_array_add (result, (gpointer) val3);
  1936. g_ptr_array_add (result, (gpointer) val4);
  1937. g_ptr_array_unref (*parray_);
  1938. *parray_ = result;
  1939. }
  1940. /**
  1941. * gi_marshalling_tests_gptrarray_utf8_full_inout:
  1942. * @parray_: (inout) (element-type utf8) (transfer full):
  1943. */
  1944. void
  1945. gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
  1946. {
  1947. static gchar *val1 = "-1";
  1948. static gchar *val2 = "-2";
  1949. gchar *val;
  1950. GPtrArray *result;
  1951. g_assert_cmpint ((*parray_)->len, ==, 3);
  1952. g_assert_cmpstr (g_ptr_array_index (*parray_, 0), ==, "0");
  1953. g_assert_cmpstr (g_ptr_array_index (*parray_, 1), ==, "1");
  1954. g_assert_cmpstr (g_ptr_array_index (*parray_, 2), ==, "2");
  1955. result = g_ptr_array_new ();
  1956. val = g_strdup (val2);
  1957. g_ptr_array_add (result, (gpointer) val);
  1958. val = g_strdup (val1);
  1959. g_ptr_array_add (result, (gpointer) val);
  1960. val = g_strdup ("0");
  1961. g_ptr_array_add (result, (gpointer) val);
  1962. val = g_strdup ("1");
  1963. g_ptr_array_add (result, (gpointer) val);
  1964. g_ptr_array_unref (*parray_);
  1965. *parray_ = result;
  1966. }
  1967. /**
  1968. * gi_marshalling_tests_bytearray_full_return:
  1969. *
  1970. * Returns: (transfer full):
  1971. */
  1972. GByteArray *
  1973. gi_marshalling_tests_bytearray_full_return (void)
  1974. {
  1975. GByteArray *array = NULL;
  1976. guint8 data[] = { '\0', '1', '\xFF', '3' };
  1977. array = g_byte_array_new ();
  1978. g_byte_array_append (array, (const guint8 *) data, G_N_ELEMENTS (data));
  1979. return array;
  1980. }
  1981. /**
  1982. * gi_marshalling_tests_bytearray_none_in:
  1983. * @v: (element-type gint8) (transfer none):
  1984. */
  1985. void
  1986. gi_marshalling_tests_bytearray_none_in (GByteArray *v)
  1987. {
  1988. g_assert_cmpuint (v->len, ==, 4);
  1989. g_assert_cmpuint (g_array_index (v, unsigned char, 0), ==, 0);
  1990. g_assert_cmpuint (g_array_index (v, unsigned char, 1), ==, 49);
  1991. g_assert_cmpuint (g_array_index (v, unsigned char, 2), ==, 0xFF);
  1992. g_assert_cmpuint (g_array_index (v, unsigned char, 3), ==, 51);
  1993. }
  1994. /**
  1995. * gi_marshalling_tests_gbytes_full_return:
  1996. *
  1997. * Returns: (transfer full):
  1998. */
  1999. GBytes *
  2000. gi_marshalling_tests_gbytes_full_return (void)
  2001. {
  2002. static guint8 data[] = { 0, 49, 0xFF, 51 };
  2003. return g_bytes_new_static (data, G_N_ELEMENTS (data));
  2004. }
  2005. /**
  2006. * gi_marshalling_tests_gbytes_none_in:
  2007. */
  2008. void
  2009. gi_marshalling_tests_gbytes_none_in (GBytes *v)
  2010. {
  2011. const guint8 *data;
  2012. gsize len;
  2013. data = g_bytes_get_data (v, &len);
  2014. g_assert_cmpuint (len, ==, 4);
  2015. g_assert_cmpuint (data[0], ==, 0);
  2016. g_assert_cmpuint (data[1], ==, 49);
  2017. g_assert_cmpuint (data[2], ==, 0xFF);
  2018. g_assert_cmpuint (data[3], ==, 51);
  2019. }
  2020. /**
  2021. * gi_marshalling_tests_gstrv_return:
  2022. *
  2023. * Returns: (transfer full): an array of strings
  2024. */
  2025. GStrv
  2026. gi_marshalling_tests_gstrv_return (void)
  2027. {
  2028. GStrv values = g_new0 (gchar *, 4);
  2029. values[0] = g_strdup ("0");
  2030. values[1] = g_strdup ("1");
  2031. values[2] = g_strdup ("2");
  2032. values[3] = NULL;
  2033. return values;
  2034. }
  2035. /**
  2036. * gi_marshalling_tests_gstrv_in:
  2037. * @g_strv:
  2038. */
  2039. void
  2040. gi_marshalling_tests_gstrv_in (GStrv g_strv)
  2041. {
  2042. g_assert_cmpint (g_strv_length (g_strv), ==, 3);
  2043. g_assert_cmpstr (g_strv[0], ==, "0");
  2044. g_assert_cmpstr (g_strv[1], ==, "1");
  2045. g_assert_cmpstr (g_strv[2], ==, "2");
  2046. }
  2047. /**
  2048. * gi_marshalling_tests_gstrv_out:
  2049. * @g_strv: (out) (transfer none):
  2050. */
  2051. void
  2052. gi_marshalling_tests_gstrv_out (GStrv *g_strv)
  2053. {
  2054. static gchar *values[] = { "0", "1", "2", NULL };
  2055. *g_strv = values;
  2056. }
  2057. /**
  2058. * gi_marshalling_tests_gstrv_inout:
  2059. * @g_strv: (inout) (transfer none):
  2060. */
  2061. void
  2062. gi_marshalling_tests_gstrv_inout (GStrv *g_strv)
  2063. {
  2064. static gchar *values[] = { "-1", "0", "1", "2", NULL };
  2065. g_assert (g_strv_length (*g_strv) == 3);
  2066. g_assert (strcmp ((*g_strv)[0], "0") == 0);
  2067. g_assert (strcmp ((*g_strv)[1], "1") == 0);
  2068. g_assert (strcmp ((*g_strv)[2], "2") == 0);
  2069. *g_strv = values;
  2070. }
  2071. /**
  2072. * gi_marshalling_tests_glist_int_none_return:
  2073. *
  2074. * Returns: (element-type gint) (transfer none):
  2075. */
  2076. GList *
  2077. gi_marshalling_tests_glist_int_none_return (void)
  2078. {
  2079. static GList *list = NULL;
  2080. if (list == NULL)
  2081. {
  2082. list = g_list_append (list, GINT_TO_POINTER (-1));
  2083. list = g_list_append (list, GINT_TO_POINTER (0));
  2084. list = g_list_append (list, GINT_TO_POINTER (1));
  2085. list = g_list_append (list, GINT_TO_POINTER (2));
  2086. }
  2087. return list;
  2088. }
  2089. /**
  2090. * gi_marshalling_tests_glist_uint32_none_return:
  2091. *
  2092. * Returns: (element-type guint32) (transfer none):
  2093. */
  2094. GList *
  2095. gi_marshalling_tests_glist_uint32_none_return (void)
  2096. {
  2097. static GList *list = NULL;
  2098. if (list == NULL)
  2099. {
  2100. list = g_list_append (list, GUINT_TO_POINTER (0));
  2101. list = g_list_append (list, GUINT_TO_POINTER (G_MAXUINT32));
  2102. }
  2103. return list;
  2104. }
  2105. /**
  2106. * gi_marshalling_tests_glist_utf8_none_return:
  2107. *
  2108. * Returns: (element-type utf8) (transfer none):
  2109. */
  2110. GList *
  2111. gi_marshalling_tests_glist_utf8_none_return (void)
  2112. {
  2113. static GList *list = NULL;
  2114. if (list == NULL)
  2115. {
  2116. list = g_list_append (list, "0");
  2117. list = g_list_append (list, "1");
  2118. list = g_list_append (list, "2");
  2119. }
  2120. return list;
  2121. }
  2122. /**
  2123. * gi_marshalling_tests_glist_utf8_container_return:
  2124. *
  2125. * Returns: (element-type utf8) (transfer container):
  2126. */
  2127. GList *
  2128. gi_marshalling_tests_glist_utf8_container_return (void)
  2129. {
  2130. GList *list = NULL;
  2131. list = g_list_append (list, "0");
  2132. list = g_list_append (list, "1");
  2133. list = g_list_append (list, "2");
  2134. return list;
  2135. }
  2136. /**
  2137. * gi_marshalling_tests_glist_utf8_full_return:
  2138. *
  2139. * Returns: (element-type utf8) (transfer full):
  2140. */
  2141. GList *
  2142. gi_marshalling_tests_glist_utf8_full_return (void)
  2143. {
  2144. GList *list = NULL;
  2145. list = g_list_append (list, g_strdup ("0"));
  2146. list = g_list_append (list, g_strdup ("1"));
  2147. list = g_list_append (list, g_strdup ("2"));
  2148. return list;
  2149. }
  2150. /**
  2151. * gi_marshalling_tests_glist_int_none_in:
  2152. * @list: (element-type gint) (transfer none):
  2153. */
  2154. void
  2155. gi_marshalling_tests_glist_int_none_in (GList *list)
  2156. {
  2157. g_assert_cmpint (g_list_length (list), ==, 4);
  2158. g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 0)), ==, -1);
  2159. g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 1)), ==, 0);
  2160. g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 2)), ==, 1);
  2161. g_assert_cmpint (GPOINTER_TO_INT (g_list_nth_data (list, 3)), ==, 2);
  2162. }
  2163. /**
  2164. * gi_marshalling_tests_glist_uint32_none_in:
  2165. * @list: (element-type guint32) (transfer none):
  2166. */
  2167. void
  2168. gi_marshalling_tests_glist_uint32_none_in (GList *list)
  2169. {
  2170. g_assert_cmpint (g_list_length (list), ==, 2);
  2171. g_assert_cmpint (GPOINTER_TO_UINT (g_list_nth_data (list, 0)), ==, 0);
  2172. g_assert_cmpint (GPOINTER_TO_UINT (g_list_nth_data (list, 1)), ==, G_MAXUINT32);
  2173. }
  2174. /**
  2175. * gi_marshalling_tests_glist_utf8_none_in:
  2176. * @list: (element-type utf8) (transfer none):
  2177. */
  2178. void
  2179. gi_marshalling_tests_glist_utf8_none_in (GList *list)
  2180. {
  2181. g_assert_cmpint (g_list_length (list), ==, 3);
  2182. g_assert_cmpint (strcmp (g_list_nth_data (list, 0), "0"), ==, 0);
  2183. g_assert_cmpint (strcmp (g_list_nth_data (list, 1), "1"), ==, 0);
  2184. g_assert_cmpint (strcmp (g_list_nth_data (list, 2), "2"), ==, 0);
  2185. }
  2186. /**
  2187. * gi_marshalling_tests_glist_utf8_none_out:
  2188. * @list: (out) (element-type utf8) (transfer none):
  2189. */
  2190. void
  2191. gi_marshalling_tests_glist_utf8_none_out (GList **list)
  2192. {
  2193. static GList *values = NULL;
  2194. if (values == NULL)
  2195. {
  2196. values = g_list_append (values, "0");
  2197. values = g_list_append (values, "1");
  2198. values = g_list_append (values, "2");
  2199. }
  2200. *list = values;
  2201. }
  2202. /**
  2203. * gi_marshalling_tests_glist_utf8_container_out:
  2204. * @list: (out) (element-type utf8) (transfer container):
  2205. */
  2206. void
  2207. gi_marshalling_tests_glist_utf8_container_out (GList **list)
  2208. {
  2209. *list = NULL;
  2210. *list = g_list_append (*list, "0");
  2211. *list = g_list_append (*list, "1");
  2212. *list = g_list_append (*list, "2");
  2213. }
  2214. /**
  2215. * gi_marshalling_tests_glist_utf8_full_out:
  2216. * @list: (out) (element-type utf8) (transfer full):
  2217. */
  2218. void
  2219. gi_marshalling_tests_glist_utf8_full_out (GList **list)
  2220. {
  2221. *list = NULL;
  2222. *list = g_list_append (*list, g_strdup ("0"));
  2223. *list = g_list_append (*list, g_strdup ("1"));
  2224. *list = g_list_append (*list, g_strdup ("2"));
  2225. }
  2226. /**
  2227. * gi_marshalling_tests_glist_utf8_none_inout:
  2228. * @list: (inout) (element-type utf8) (transfer none):
  2229. */
  2230. void
  2231. gi_marshalling_tests_glist_utf8_none_inout (GList **list)
  2232. {
  2233. static GList *values = NULL;
  2234. g_assert_cmpint (g_list_length (*list), ==, 3);
  2235. g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
  2236. g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
  2237. g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
  2238. if (values == NULL)
  2239. {
  2240. values = g_list_append (values, "-2");
  2241. values = g_list_append (values, "-1");
  2242. values = g_list_append (values, "0");
  2243. values = g_list_append (values, "1");
  2244. }
  2245. *list = values;
  2246. }
  2247. /**
  2248. * gi_marshalling_tests_glist_utf8_container_inout:
  2249. * @list: (inout) (element-type utf8) (transfer container):
  2250. */
  2251. void
  2252. gi_marshalling_tests_glist_utf8_container_inout (GList **list)
  2253. {
  2254. GList *result = NULL;
  2255. g_assert_cmpint (g_list_length (*list), ==, 3);
  2256. g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
  2257. g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
  2258. g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
  2259. result = g_list_prepend (result, "1");
  2260. result = g_list_prepend (result, "0");
  2261. result = g_list_prepend (result, "-1");
  2262. result = g_list_prepend (result, "-2");
  2263. g_list_free (*list);
  2264. *list = result;
  2265. }
  2266. /**
  2267. * gi_marshalling_tests_glist_utf8_full_inout:
  2268. * @list: (inout) (element-type utf8) (transfer full):
  2269. */
  2270. void
  2271. gi_marshalling_tests_glist_utf8_full_inout (GList **list)
  2272. {
  2273. GList *result = NULL;
  2274. g_assert_cmpint (g_list_length (*list), ==, 3);
  2275. g_assert_cmpstr (g_list_nth_data (*list, 0), ==, "0");
  2276. g_assert_cmpstr (g_list_nth_data (*list, 1), ==, "1");
  2277. g_assert_cmpstr (g_list_nth_data (*list, 2), ==, "2");
  2278. result = g_list_prepend (result, g_strdup ("1"));
  2279. result = g_list_prepend (result, g_strdup ("0"));
  2280. result = g_list_prepend (result, g_strdup ("-1"));
  2281. result = g_list_prepend (result, g_strdup ("-2"));
  2282. g_list_free_full (*list, g_free);
  2283. *list = result;
  2284. }
  2285. /**
  2286. * gi_marshalling_tests_gslist_int_none_return:
  2287. *
  2288. * Returns: (element-type gint) (transfer none):
  2289. */
  2290. GSList *
  2291. gi_marshalling_tests_gslist_int_none_return (void)
  2292. {
  2293. static GSList *list = NULL;
  2294. if (list == NULL)
  2295. {
  2296. list = g_slist_prepend (list, GINT_TO_POINTER (-1));
  2297. list = g_slist_prepend (list, GINT_TO_POINTER (0));
  2298. list = g_slist_prepend (list, GINT_TO_POINTER (1));
  2299. list = g_slist_prepend (list, GINT_TO_POINTER (2));
  2300. list = g_slist_reverse (list);
  2301. }
  2302. return list;
  2303. }
  2304. /**
  2305. * gi_marshalling_tests_gslist_utf8_none_return:
  2306. *
  2307. * Returns: (element-type utf8) (transfer none):
  2308. */
  2309. GSList *
  2310. gi_marshalling_tests_gslist_utf8_none_return (void)
  2311. {
  2312. static GSList *list = NULL;
  2313. if (list == NULL)
  2314. {
  2315. list = g_slist_prepend (list, "0");
  2316. list = g_slist_prepend (list, "1");
  2317. list = g_slist_prepend (list, "2");
  2318. list = g_slist_reverse (list);
  2319. }
  2320. return list;
  2321. }
  2322. /**
  2323. * gi_marshalling_tests_gslist_utf8_container_return:
  2324. *
  2325. * Returns: (element-type utf8) (transfer container):
  2326. */
  2327. GSList *
  2328. gi_marshalling_tests_gslist_utf8_container_return (void)
  2329. {
  2330. GSList *list = NULL;
  2331. list = g_slist_prepend (list, "0");
  2332. list = g_slist_prepend (list, "1");
  2333. list = g_slist_prepend (list, "2");
  2334. list = g_slist_reverse (list);
  2335. return list;
  2336. }
  2337. /**
  2338. * gi_marshalling_tests_gslist_utf8_full_return:
  2339. *
  2340. * Returns: (element-type utf8) (transfer full):
  2341. */
  2342. GSList *
  2343. gi_marshalling_tests_gslist_utf8_full_return (void)
  2344. {
  2345. GSList *list = NULL;
  2346. list = g_slist_prepend (list, g_strdup ("0"));
  2347. list = g_slist_prepend (list, g_strdup ("1"));
  2348. list = g_slist_prepend (list, g_strdup ("2"));
  2349. list = g_slist_reverse (list);
  2350. return list;
  2351. }
  2352. /**
  2353. * gi_marshalling_tests_gslist_int_none_in:
  2354. * @list: (element-type gint) (transfer none):
  2355. */
  2356. void
  2357. gi_marshalling_tests_gslist_int_none_in (GSList *list)
  2358. {
  2359. g_assert_cmpint (g_slist_length (list), ==, 4);
  2360. g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 0)), ==, -1);
  2361. g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 1)), ==, 0);
  2362. g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 2)), ==, 1);
  2363. g_assert_cmpint (GPOINTER_TO_INT (g_slist_nth_data (list, 3)), ==, 2);
  2364. }
  2365. /**
  2366. * gi_marshalling_tests_gslist_utf8_none_in:
  2367. * @list: (element-type utf8) (transfer none):
  2368. */
  2369. void
  2370. gi_marshalling_tests_gslist_utf8_none_in (GSList *list)
  2371. {
  2372. g_assert_cmpint (g_slist_length (list), ==, 3);
  2373. g_assert_cmpstr (g_slist_nth_data (list, 0), ==, "0");
  2374. g_assert_cmpstr (g_slist_nth_data (list, 1), ==, "1");
  2375. g_assert_cmpstr (g_slist_nth_data (list, 2), ==, "2");
  2376. }
  2377. /**
  2378. * gi_marshalling_tests_gslist_utf8_none_out:
  2379. * @list: (out) (element-type utf8) (transfer none):
  2380. */
  2381. void
  2382. gi_marshalling_tests_gslist_utf8_none_out (GSList **list)
  2383. {
  2384. static GSList *values = NULL;
  2385. if (values == NULL)
  2386. {
  2387. values = g_slist_prepend (values, "0");
  2388. values = g_slist_prepend (values, "1");
  2389. values = g_slist_prepend (values, "2");
  2390. values = g_slist_reverse (values);
  2391. }
  2392. *list = values;
  2393. }
  2394. /**
  2395. * gi_marshalling_tests_gslist_utf8_container_out:
  2396. * @list: (out) (element-type utf8) (transfer container):
  2397. */
  2398. void
  2399. gi_marshalling_tests_gslist_utf8_container_out (GSList **list)
  2400. {
  2401. *list = NULL;
  2402. *list = g_slist_prepend (*list, "0");
  2403. *list = g_slist_prepend (*list, "1");
  2404. *list = g_slist_prepend (*list, "2");
  2405. *list = g_slist_reverse (*list);
  2406. }
  2407. /**
  2408. * gi_marshalling_tests_gslist_utf8_full_out:
  2409. * @list: (out) (element-type utf8) (transfer full):
  2410. */
  2411. void
  2412. gi_marshalling_tests_gslist_utf8_full_out (GSList **list)
  2413. {
  2414. *list = NULL;
  2415. *list = g_slist_prepend (*list, g_strdup ("0"));
  2416. *list = g_slist_prepend (*list, g_strdup ("1"));
  2417. *list = g_slist_prepend (*list, g_strdup ("2"));
  2418. *list = g_slist_reverse (*list);
  2419. }
  2420. /**
  2421. * gi_marshalling_tests_gslist_utf8_none_inout:
  2422. * @list: (inout) (element-type utf8) (transfer none):
  2423. */
  2424. void
  2425. gi_marshalling_tests_gslist_utf8_none_inout (GSList **list)
  2426. {
  2427. static GSList *values = NULL;
  2428. g_assert_cmpint (g_slist_length (*list), ==, 3);
  2429. g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
  2430. g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
  2431. g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
  2432. if (values == NULL)
  2433. {
  2434. values = g_slist_prepend (values, "-2");
  2435. values = g_slist_prepend (values, "-1");
  2436. values = g_slist_prepend (values, "0");
  2437. values = g_slist_prepend (values, "1");
  2438. values = g_slist_reverse (values);
  2439. }
  2440. *list = values;
  2441. }
  2442. /**
  2443. * gi_marshalling_tests_gslist_utf8_container_inout:
  2444. * @list: (inout) (element-type utf8) (transfer container):
  2445. */
  2446. void
  2447. gi_marshalling_tests_gslist_utf8_container_inout (GSList **list)
  2448. {
  2449. GSList *result = NULL;
  2450. g_assert_cmpint (g_slist_length (*list), ==, 3);
  2451. g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
  2452. g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
  2453. g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
  2454. result = g_slist_prepend (result, "1");
  2455. result = g_slist_prepend (result, "0");
  2456. result = g_slist_prepend (result, "-1");
  2457. result = g_slist_prepend (result, "-2");
  2458. g_slist_free (*list);
  2459. *list = result;
  2460. }
  2461. /**
  2462. * gi_marshalling_tests_gslist_utf8_full_inout:
  2463. * @list: (inout) (element-type utf8) (transfer full):
  2464. */
  2465. void
  2466. gi_marshalling_tests_gslist_utf8_full_inout (GSList **list)
  2467. {
  2468. GSList *result = NULL;
  2469. g_assert_cmpint (g_slist_length (*list), ==, 3);
  2470. g_assert_cmpstr (g_slist_nth_data (*list, 0), ==, "0");
  2471. g_assert_cmpstr (g_slist_nth_data (*list, 1), ==, "1");
  2472. g_assert_cmpstr (g_slist_nth_data (*list, 2), ==, "2");
  2473. result = g_slist_prepend (result, g_strdup ("1"));
  2474. result = g_slist_prepend (result, g_strdup ("0"));
  2475. result = g_slist_prepend (result, g_strdup ("-1"));
  2476. result = g_slist_prepend (result, g_strdup ("-2"));
  2477. g_slist_free_full (*list, g_free);
  2478. *list = result;
  2479. }
  2480. /**
  2481. * gi_marshalling_tests_ghashtable_int_none_return:
  2482. *
  2483. * Returns: (element-type gint gint) (transfer none):
  2484. */
  2485. GHashTable *
  2486. gi_marshalling_tests_ghashtable_int_none_return (void)
  2487. {
  2488. static GHashTable *hash_table = NULL;
  2489. if (hash_table == NULL)
  2490. {
  2491. hash_table = g_hash_table_new (NULL, NULL);
  2492. g_hash_table_insert (hash_table, GINT_TO_POINTER (-1), GINT_TO_POINTER (1));
  2493. g_hash_table_insert (hash_table, GINT_TO_POINTER (0), GINT_TO_POINTER (0));
  2494. g_hash_table_insert (hash_table, GINT_TO_POINTER (1), GINT_TO_POINTER (-1));
  2495. g_hash_table_insert (hash_table, GINT_TO_POINTER (2), GINT_TO_POINTER (-2));
  2496. }
  2497. return hash_table;
  2498. }
  2499. /**
  2500. * gi_marshalling_tests_ghashtable_utf8_none_return:
  2501. *
  2502. * Returns: (element-type utf8 utf8) (transfer none):
  2503. */
  2504. GHashTable *
  2505. gi_marshalling_tests_ghashtable_utf8_none_return (void)
  2506. {
  2507. static GHashTable *hash_table = NULL;
  2508. if (hash_table == NULL)
  2509. {
  2510. hash_table = g_hash_table_new (g_str_hash, g_str_equal);
  2511. g_hash_table_insert (hash_table, "-1", "1");
  2512. g_hash_table_insert (hash_table, "0", "0");
  2513. g_hash_table_insert (hash_table, "1", "-1");
  2514. g_hash_table_insert (hash_table, "2", "-2");
  2515. }
  2516. return hash_table;
  2517. }
  2518. /**
  2519. * gi_marshalling_tests_ghashtable_utf8_container_return:
  2520. *
  2521. * Returns: (element-type utf8 utf8) (transfer container):
  2522. */
  2523. GHashTable *
  2524. gi_marshalling_tests_ghashtable_utf8_container_return (void)
  2525. {
  2526. GHashTable *hash_table = NULL;
  2527. hash_table = g_hash_table_new (g_str_hash, g_str_equal);
  2528. g_hash_table_insert (hash_table, "-1", "1");
  2529. g_hash_table_insert (hash_table, "0", "0");
  2530. g_hash_table_insert (hash_table, "1", "-1");
  2531. g_hash_table_insert (hash_table, "2", "-2");
  2532. return hash_table;
  2533. }
  2534. /**
  2535. * gi_marshalling_tests_ghashtable_utf8_full_return:
  2536. *
  2537. * Returns: (element-type utf8 utf8) (transfer full):
  2538. */
  2539. GHashTable *
  2540. gi_marshalling_tests_ghashtable_utf8_full_return (void)
  2541. {
  2542. GHashTable *hash_table = NULL;
  2543. hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
  2544. g_hash_table_insert (hash_table, g_strdup ("-1"), g_strdup ("1"));
  2545. g_hash_table_insert (hash_table, g_strdup ("0"), g_strdup ("0"));
  2546. g_hash_table_insert (hash_table, g_strdup ("1"), g_strdup ("-1"));
  2547. g_hash_table_insert (hash_table, g_strdup ("2"), g_strdup ("-2"));
  2548. return hash_table;
  2549. }
  2550. /**
  2551. * gi_marshalling_tests_ghashtable_int_none_in:
  2552. * @hash_table: (element-type gint gint) (transfer none):
  2553. */
  2554. void
  2555. gi_marshalling_tests_ghashtable_int_none_in (GHashTable *hash_table)
  2556. {
  2557. g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (-1))), ==, 1);
  2558. g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (0))), ==, 0);
  2559. g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (1))), ==, -1);
  2560. g_assert_cmpint (GPOINTER_TO_INT (g_hash_table_lookup (hash_table, GINT_TO_POINTER (2))), ==, -2);
  2561. }
  2562. /**
  2563. * gi_marshalling_tests_ghashtable_utf8_none_in:
  2564. * @hash_table: (element-type utf8 utf8) (transfer none):
  2565. */
  2566. void
  2567. gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table)
  2568. {
  2569. g_assert_cmpstr (g_hash_table_lookup (hash_table, "-1"), ==, "1");
  2570. g_assert_cmpstr (g_hash_table_lookup (hash_table, "0"), ==, "0");
  2571. g_assert_cmpstr (g_hash_table_lookup (hash_table, "1"), ==, "-1");
  2572. g_assert_cmpstr (g_hash_table_lookup (hash_table, "2"), ==, "-2");
  2573. }
  2574. /**
  2575. * gi_marshalling_tests_ghashtable_utf8_none_out:
  2576. * @hash_table: (out) (element-type utf8 utf8) (transfer none):
  2577. */
  2578. void
  2579. gi_marshalling_tests_ghashtable_utf8_none_out (GHashTable **hash_table)
  2580. {
  2581. static GHashTable *new_hash_table = NULL;
  2582. if (new_hash_table == NULL)
  2583. {
  2584. new_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
  2585. g_hash_table_insert (new_hash_table, "-1", "1");
  2586. g_hash_table_insert (new_hash_table, "0", "0");
  2587. g_hash_table_insert (new_hash_table, "1", "-1");
  2588. g_hash_table_insert (new_hash_table, "2", "-2");
  2589. }
  2590. *hash_table = new_hash_table;
  2591. }
  2592. /**
  2593. * gi_marshalling_tests_ghashtable_utf8_container_out:
  2594. * @hash_table: (out) (element-type utf8 utf8) (transfer container):
  2595. */
  2596. void
  2597. gi_marshalling_tests_ghashtable_utf8_container_out (GHashTable **hash_table)
  2598. {
  2599. *hash_table = g_hash_table_new (g_str_hash, g_str_equal);
  2600. g_hash_table_insert (*hash_table, "-1", "1");
  2601. g_hash_table_insert (*hash_table, "0", "0");
  2602. g_hash_table_insert (*hash_table, "1", "-1");
  2603. g_hash_table_insert (*hash_table, "2", "-2");
  2604. }
  2605. /**
  2606. * gi_marshalling_tests_ghashtable_utf8_full_out:
  2607. * @hash_table: (out) (element-type utf8 utf8) (transfer full):
  2608. */
  2609. void
  2610. gi_marshalling_tests_ghashtable_utf8_full_out (GHashTable **hash_table)
  2611. {
  2612. *hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
  2613. g_hash_table_insert (*hash_table, g_strdup ("-1"), g_strdup ("1"));
  2614. g_hash_table_insert (*hash_table, g_strdup ("0"), g_strdup ("0"));
  2615. g_hash_table_insert (*hash_table, g_strdup ("1"), g_strdup ("-1"));
  2616. g_hash_table_insert (*hash_table, g_strdup ("2"), g_strdup ("-2"));
  2617. }
  2618. /**
  2619. * gi_marshalling_tests_ghashtable_utf8_none_inout:
  2620. * @hash_table: (inout) (element-type utf8 utf8) (transfer none):
  2621. */
  2622. void
  2623. gi_marshalling_tests_ghashtable_utf8_none_inout (GHashTable **hash_table)
  2624. {
  2625. static GHashTable *new_hash_table = NULL;
  2626. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
  2627. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
  2628. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
  2629. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
  2630. if (new_hash_table == NULL)
  2631. {
  2632. new_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
  2633. g_hash_table_insert (new_hash_table, "-1", "1");
  2634. g_hash_table_insert (new_hash_table, "0", "0");
  2635. g_hash_table_insert (new_hash_table, "1", "1");
  2636. }
  2637. *hash_table = new_hash_table;
  2638. }
  2639. /**
  2640. * gi_marshalling_tests_ghashtable_utf8_container_inout:
  2641. * @hash_table: (inout) (element-type utf8 utf8) (transfer container):
  2642. */
  2643. void
  2644. gi_marshalling_tests_ghashtable_utf8_container_inout (GHashTable **hash_table)
  2645. {
  2646. GHashTable *result = g_hash_table_new (g_str_hash, g_str_equal);
  2647. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
  2648. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
  2649. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
  2650. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
  2651. g_hash_table_insert (result, "-1", "1");
  2652. g_hash_table_insert (result, "0", "0");
  2653. g_hash_table_insert (result, "1", "1");
  2654. g_hash_table_unref (*hash_table);
  2655. *hash_table = result;
  2656. }
  2657. /**
  2658. * gi_marshalling_tests_ghashtable_utf8_full_inout:
  2659. * @hash_table: (inout) (element-type utf8 utf8) (transfer full):
  2660. */
  2661. void
  2662. gi_marshalling_tests_ghashtable_utf8_full_inout (GHashTable **hash_table)
  2663. {
  2664. GHashTable *result = g_hash_table_new_full (g_str_hash, g_str_equal,
  2665. g_free, g_free);
  2666. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "-1"), ==, "1");
  2667. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "0"), ==, "0");
  2668. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "1"), ==, "-1");
  2669. g_assert_cmpstr (g_hash_table_lookup (*hash_table, "2"), ==, "-2");
  2670. g_hash_table_insert (result, g_strdup ("-1"), g_strdup ("1"));
  2671. g_hash_table_insert (result, g_strdup ("0"), g_strdup ("0"));
  2672. g_hash_table_insert (result, g_strdup ("1"), g_strdup ("1"));
  2673. g_hash_table_unref (*hash_table);
  2674. *hash_table = result;
  2675. }
  2676. /**
  2677. * gi_marshalling_tests_gvalue_return:
  2678. *
  2679. * Returns: (transfer none):
  2680. */
  2681. GValue *
  2682. gi_marshalling_tests_gvalue_return (void)
  2683. {
  2684. static GValue *value = NULL;
  2685. if (value == NULL)
  2686. {
  2687. value = g_new0 (GValue, 1);
  2688. g_value_init (value, G_TYPE_INT);
  2689. g_value_set_int (value, 42);
  2690. }
  2691. return value;
  2692. }
  2693. /**
  2694. * gi_marshalling_tests_gvalue_in:
  2695. * @value: (transfer none):
  2696. */
  2697. void
  2698. gi_marshalling_tests_gvalue_in (GValue *value)
  2699. {
  2700. g_assert_cmpint (g_value_get_int (value), ==, 42);
  2701. }
  2702. /**
  2703. * gi_marshalling_tests_gvalue_int64_in:
  2704. * @value: (transfer none):
  2705. */
  2706. void
  2707. gi_marshalling_tests_gvalue_int64_in (GValue *value)
  2708. {
  2709. g_assert_cmpint (g_value_get_int64 (value), ==, G_MAXINT64);
  2710. }
  2711. /**
  2712. * gi_marshalling_tests_gvalue_in_with_type:
  2713. * @value: (transfer none):
  2714. * @type:
  2715. */
  2716. void
  2717. gi_marshalling_tests_gvalue_in_with_type (GValue *value, GType type)
  2718. {
  2719. g_assert (g_type_is_a (G_VALUE_TYPE (value), type));
  2720. }
  2721. /**
  2722. * gi_marshalling_tests_gvalue_in_with_modification:
  2723. * @value: (transfer none):
  2724. *
  2725. * Expects a GValue passed by reference which is then modified by
  2726. * this function.
  2727. */
  2728. void
  2729. gi_marshalling_tests_gvalue_in_with_modification (GValue *value)
  2730. {
  2731. g_assert_cmpint (g_value_get_int (value), ==, 42);
  2732. g_value_set_int (value, 24);
  2733. }
  2734. /**
  2735. * gi_marshalling_tests_gvalue_in_enum:
  2736. * @value: (transfer none):
  2737. */
  2738. void
  2739. gi_marshalling_tests_gvalue_in_enum (GValue *value)
  2740. {
  2741. g_assert (g_value_get_enum (value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
  2742. }
  2743. /**
  2744. * gi_marshalling_tests_gvalue_out:
  2745. * @value: (out) (transfer none):
  2746. */
  2747. void
  2748. gi_marshalling_tests_gvalue_out (GValue **value)
  2749. {
  2750. static GValue *new_value = NULL;
  2751. if (new_value == NULL)
  2752. {
  2753. new_value = g_new0 (GValue, 1);
  2754. g_value_init (new_value, G_TYPE_INT);
  2755. g_value_set_int (new_value, 42);
  2756. }
  2757. *value = new_value;
  2758. }
  2759. /**
  2760. * gi_marshalling_tests_gvalue_int64_out:
  2761. * @value: (out) (transfer none):
  2762. */
  2763. void
  2764. gi_marshalling_tests_gvalue_int64_out (GValue **value)
  2765. {
  2766. static GValue *new_value = NULL;
  2767. if (new_value == NULL)
  2768. {
  2769. new_value = g_new0 (GValue, 1);
  2770. g_value_init (new_value, G_TYPE_INT64);
  2771. g_value_set_int64 (new_value, G_MAXINT64);
  2772. }
  2773. *value = new_value;
  2774. }
  2775. /**
  2776. * gi_marshalling_tests_gvalue_out_caller_allocates:
  2777. * @value: (out) (transfer none):
  2778. */
  2779. void
  2780. gi_marshalling_tests_gvalue_out_caller_allocates (GValue *value)
  2781. {
  2782. g_value_init (value, G_TYPE_INT);
  2783. g_value_set_int (value, 42);
  2784. }
  2785. /**
  2786. * gi_marshalling_tests_gvalue_inout:
  2787. * @value: (inout) (transfer none):
  2788. */
  2789. void
  2790. gi_marshalling_tests_gvalue_inout (GValue **value)
  2791. {
  2792. g_assert_cmpint (g_value_get_int (*value), ==, 42);
  2793. g_value_unset (*value);
  2794. g_value_init (*value, G_TYPE_STRING);
  2795. g_value_set_string (*value, "42");
  2796. }
  2797. /**
  2798. * gi_marshalling_tests_gvalue_flat_array:
  2799. * @n_values: number of values
  2800. * @values: (array length=n_values): an array containing values
  2801. */
  2802. void
  2803. gi_marshalling_tests_gvalue_flat_array (guint n_values, const GValue *values)
  2804. {
  2805. g_assert (n_values == 3);
  2806. g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
  2807. g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
  2808. g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
  2809. }
  2810. /**
  2811. * gi_marshalling_tests_return_gvalue_flat_array:
  2812. *
  2813. * Returns: (array fixed-size=3) (transfer full): a flat GValue array
  2814. */
  2815. GValue *
  2816. gi_marshalling_tests_return_gvalue_flat_array (void)
  2817. {
  2818. GValue *array = g_new0 (GValue, 3);
  2819. g_value_init (&array[0], G_TYPE_INT);
  2820. g_value_set_int (&array[0], 42);
  2821. g_value_init (&array[1], G_TYPE_STRING);
  2822. g_value_set_static_string (&array[1], "42");
  2823. g_value_init (&array[2], G_TYPE_BOOLEAN);
  2824. g_value_set_boolean (&array[2], TRUE);
  2825. return array;
  2826. }
  2827. /**
  2828. * gi_marshalling_tests_gvalue_flat_array_round_trip:
  2829. * @one: The first GValue
  2830. * @two: The second GValue
  2831. * @three: The third GValue
  2832. *
  2833. * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
  2834. */
  2835. GValue *
  2836. gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one, const GValue two, const GValue three)
  2837. {
  2838. GValue *array = g_new (GValue, 3);
  2839. array[0] = one;
  2840. array[1] = two;
  2841. array[2] = three;
  2842. return array;
  2843. }
  2844. /**
  2845. * gi_marshalling_tests_gclosure_in:
  2846. * @closure: (transfer none):
  2847. */
  2848. void
  2849. gi_marshalling_tests_gclosure_in (GClosure *closure)
  2850. {
  2851. GValue return_value = { 0, };
  2852. g_value_init (&return_value, G_TYPE_INT);
  2853. g_closure_invoke (closure, &return_value, 0, NULL, NULL);
  2854. g_assert_cmpint (g_value_get_int (&return_value), ==, 42);
  2855. g_value_unset (&return_value);
  2856. }
  2857. static gint
  2858. _closure_return_42 (void)
  2859. {
  2860. return 42;
  2861. }
  2862. static void
  2863. _marshal_INT__VOID (GClosure *closure,
  2864. GValue *return_value,
  2865. guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data)
  2866. {
  2867. typedef gint (*GMarshalFunc_INT__VOID) (void);
  2868. register GMarshalFunc_INT__VOID callback;
  2869. register GCClosure *cc = (GCClosure *) closure;
  2870. callback = (GMarshalFunc_INT__VOID) cc->callback;
  2871. g_value_set_int (return_value, callback ());
  2872. }
  2873. /**
  2874. * gi_marshalling_tests_gclosure_return:
  2875. *
  2876. * Return: a #GClosure
  2877. */
  2878. GClosure *
  2879. gi_marshalling_tests_gclosure_return (void)
  2880. {
  2881. GClosure *closure = g_cclosure_new ((GCallback) _closure_return_42,
  2882. NULL, NULL);
  2883. g_closure_set_marshal (closure, _marshal_INT__VOID);
  2884. return closure;
  2885. }
  2886. /**
  2887. * gi_marshalling_tests_callback_return_value_only:
  2888. * @callback: (scope call):
  2889. */
  2890. glong gi_marshalling_tests_callback_return_value_only (GIMarshallingTestsCallbackReturnValueOnly callback)
  2891. {
  2892. return callback ();
  2893. }
  2894. /**
  2895. * gi_marshalling_tests_callback_one_out_parameter:
  2896. * @callback: (scope call):
  2897. * @a: (out):
  2898. */
  2899. void gi_marshalling_tests_callback_one_out_parameter (GIMarshallingTestsCallbackOneOutParameter callback, gfloat *a)
  2900. {
  2901. callback (a);
  2902. }
  2903. /**
  2904. * gi_marshalling_tests_callback_multiple_out_parameters:
  2905. * @callback: (scope call):
  2906. * @a: (out):
  2907. * @b: (out):
  2908. */
  2909. void
  2910. gi_marshalling_tests_callback_multiple_out_parameters
  2911. (GIMarshallingTestsCallbackMultipleOutParameters callback, gfloat *a, gfloat *b)
  2912. {
  2913. callback (a, b);
  2914. }
  2915. /**
  2916. * gi_marshalling_tests_callback_return_value_and_one_out_parameter:
  2917. * @callback: (scope call):
  2918. * @a: (out):
  2919. */
  2920. glong
  2921. gi_marshalling_tests_callback_return_value_and_one_out_parameter
  2922. (GIMarshallingTestsCallbackReturnValueAndOneOutParameter callback, glong *a)
  2923. {
  2924. return callback (a);
  2925. }
  2926. /**
  2927. * gi_marshalling_tests_callback_return_value_and_multiple_out_parameters:
  2928. * @callback: (scope call):
  2929. * @a: (out):
  2930. * @b: (out):
  2931. */
  2932. glong
  2933. gi_marshalling_tests_callback_return_value_and_multiple_out_parameters
  2934. (GIMarshallingTestsCallbackReturnValueAndMultipleOutParameters callback, glong *a, glong *b)
  2935. {
  2936. return callback (a, b);
  2937. }
  2938. /**
  2939. * gi_marshalling_tests_pointer_in_return:
  2940. *
  2941. * Returns: The same pointer
  2942. */
  2943. gpointer
  2944. gi_marshalling_tests_pointer_in_return (gpointer pointer)
  2945. {
  2946. return pointer;
  2947. }
  2948. GType
  2949. gi_marshalling_tests_genum_get_type (void)
  2950. {
  2951. static GType type = 0;
  2952. if (G_UNLIKELY (type == 0))
  2953. {
  2954. static const GEnumValue values[] = {
  2955. {GI_MARSHALLING_TESTS_GENUM_VALUE1,
  2956. "GI_MARSHALLING_TESTS_GENUM_VALUE1", "value1"},
  2957. {GI_MARSHALLING_TESTS_GENUM_VALUE2,
  2958. "GI_MARSHALLING_TESTS_GENUM_VALUE2", "value2"},
  2959. {GI_MARSHALLING_TESTS_GENUM_VALUE3,
  2960. "GI_MARSHALLING_TESTS_GENUM_VALUE3", "value3"},
  2961. {0, NULL, NULL}
  2962. };
  2963. type = g_enum_register_static (g_intern_static_string ("GIMarshallingTestsGEnum"), values);
  2964. }
  2965. return type;
  2966. }
  2967. GIMarshallingTestsGEnum
  2968. gi_marshalling_tests_genum_returnv (void)
  2969. {
  2970. return GI_MARSHALLING_TESTS_GENUM_VALUE3;
  2971. }
  2972. void
  2973. gi_marshalling_tests_genum_in (GIMarshallingTestsGEnum v)
  2974. {
  2975. g_assert_cmpint (v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
  2976. }
  2977. /**
  2978. * gi_marshalling_tests_genum_out:
  2979. * @v: (out):
  2980. */
  2981. void
  2982. gi_marshalling_tests_genum_out (GIMarshallingTestsGEnum *v)
  2983. {
  2984. *v = GI_MARSHALLING_TESTS_GENUM_VALUE3;
  2985. }
  2986. /**
  2987. * gi_marshalling_tests_genum_inout:
  2988. * @v: (inout):
  2989. */
  2990. void
  2991. gi_marshalling_tests_genum_inout (GIMarshallingTestsGEnum *v)
  2992. {
  2993. g_assert_cmpint (*v, ==, GI_MARSHALLING_TESTS_GENUM_VALUE3);
  2994. *v = GI_MARSHALLING_TESTS_GENUM_VALUE1;
  2995. }
  2996. GIMarshallingTestsEnum
  2997. gi_marshalling_tests_enum_returnv (void)
  2998. {
  2999. return GI_MARSHALLING_TESTS_ENUM_VALUE3;
  3000. }
  3001. void
  3002. gi_marshalling_tests_enum_in (GIMarshallingTestsEnum v)
  3003. {
  3004. g_assert_cmpint (v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
  3005. }
  3006. /**
  3007. * gi_marshalling_tests_enum_out:
  3008. * @v: (out):
  3009. */
  3010. void
  3011. gi_marshalling_tests_enum_out (GIMarshallingTestsEnum *v)
  3012. {
  3013. *v = GI_MARSHALLING_TESTS_ENUM_VALUE3;
  3014. }
  3015. /**
  3016. * gi_marshalling_tests_enum_inout:
  3017. * @v: (inout):
  3018. */
  3019. void
  3020. gi_marshalling_tests_enum_inout (GIMarshallingTestsEnum *v)
  3021. {
  3022. g_assert_cmpint (*v, ==, GI_MARSHALLING_TESTS_ENUM_VALUE3);
  3023. *v = GI_MARSHALLING_TESTS_ENUM_VALUE1;
  3024. }
  3025. GType
  3026. gi_marshalling_tests_flags_get_type (void)
  3027. {
  3028. static GType type = 0;
  3029. if (G_UNLIKELY (type == 0))
  3030. {
  3031. static const GFlagsValue values[] = {
  3032. {GI_MARSHALLING_TESTS_FLAGS_VALUE1,
  3033. "GI_MARSHALLING_TESTS_FLAGS_VALUE1", "value1"},
  3034. {GI_MARSHALLING_TESTS_FLAGS_VALUE2,
  3035. "GI_MARSHALLING_TESTS_FLAGS_VALUE2", "value2"},
  3036. {GI_MARSHALLING_TESTS_FLAGS_VALUE3,
  3037. "GI_MARSHALLING_TESTS_FLAGS_VALUE3", "value3"},
  3038. {GI_MARSHALLING_TESTS_FLAGS_MASK, "GI_MARSHALLING_TESTS_FLAGS_MASK",
  3039. "mask"},
  3040. {GI_MARSHALLING_TESTS_FLAGS_MASK2, "GI_MARSHALLING_TESTS_FLAGS_MASK2",
  3041. "mask2"},
  3042. {0, NULL, NULL}
  3043. };
  3044. type = g_flags_register_static (g_intern_static_string ("GIMarshallingTestsFlags"), values);
  3045. }
  3046. return type;
  3047. }
  3048. GIMarshallingTestsFlags
  3049. gi_marshalling_tests_flags_returnv (void)
  3050. {
  3051. return GI_MARSHALLING_TESTS_FLAGS_VALUE2;
  3052. }
  3053. void
  3054. gi_marshalling_tests_flags_in (GIMarshallingTestsFlags v)
  3055. {
  3056. g_assert (v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
  3057. }
  3058. void
  3059. gi_marshalling_tests_flags_in_zero (GIMarshallingTestsFlags v)
  3060. {
  3061. g_assert (v == 0);
  3062. }
  3063. /**
  3064. * gi_marshalling_tests_flags_out:
  3065. * @v: (out):
  3066. */
  3067. void
  3068. gi_marshalling_tests_flags_out (GIMarshallingTestsFlags *v)
  3069. {
  3070. *v = GI_MARSHALLING_TESTS_FLAGS_VALUE2;
  3071. }
  3072. /**
  3073. * gi_marshalling_tests_flags_inout:
  3074. * @v: (inout):
  3075. */
  3076. void
  3077. gi_marshalling_tests_flags_inout (GIMarshallingTestsFlags *v)
  3078. {
  3079. g_assert (*v == GI_MARSHALLING_TESTS_FLAGS_VALUE2);
  3080. *v = GI_MARSHALLING_TESTS_FLAGS_VALUE1;
  3081. }
  3082. GIMarshallingTestsNoTypeFlags
  3083. gi_marshalling_tests_no_type_flags_returnv (void)
  3084. {
  3085. return GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
  3086. }
  3087. void
  3088. gi_marshalling_tests_no_type_flags_in (GIMarshallingTestsNoTypeFlags v)
  3089. {
  3090. g_assert (v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
  3091. }
  3092. void
  3093. gi_marshalling_tests_no_type_flags_in_zero (GIMarshallingTestsNoTypeFlags v)
  3094. {
  3095. g_assert (v == 0);
  3096. }
  3097. /**
  3098. * gi_marshalling_tests_no_type_flags_out:
  3099. * @v: (out):
  3100. */
  3101. void
  3102. gi_marshalling_tests_no_type_flags_out (GIMarshallingTestsNoTypeFlags *v)
  3103. {
  3104. *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2;
  3105. }
  3106. /**
  3107. * gi_marshalling_tests_no_type_flags_inout:
  3108. * @v: (inout):
  3109. */
  3110. void
  3111. gi_marshalling_tests_no_type_flags_inout (GIMarshallingTestsNoTypeFlags *v)
  3112. {
  3113. g_assert (*v == GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE2);
  3114. *v = GI_MARSHALLING_TESTS_NO_TYPE_FLAGS_VALUE1;
  3115. }
  3116. /**
  3117. * gi_marshalling_tests_simple_struct_returnv:
  3118. *
  3119. * Returns: (transfer none):
  3120. */
  3121. GIMarshallingTestsSimpleStruct *
  3122. gi_marshalling_tests_simple_struct_returnv (void)
  3123. {
  3124. static GIMarshallingTestsSimpleStruct *struct_ = NULL;
  3125. if (struct_ == NULL)
  3126. {
  3127. struct_ = g_new (GIMarshallingTestsSimpleStruct, 1);
  3128. struct_->long_ = 6;
  3129. struct_->int8 = 7;
  3130. }
  3131. return struct_;
  3132. }
  3133. /**
  3134. * gi_marshalling_tests_simple_struct_inv:
  3135. * @struct_: (transfer none):
  3136. */
  3137. void
  3138. gi_marshalling_tests_simple_struct_inv (GIMarshallingTestsSimpleStruct *struct_)
  3139. {
  3140. g_assert_cmpint (struct_->long_, ==, 6);
  3141. g_assert_cmpint (struct_->int8, ==, 7);
  3142. }
  3143. void
  3144. gi_marshalling_tests_simple_struct_method (GIMarshallingTestsSimpleStruct *struct_)
  3145. {
  3146. g_assert_cmpint (struct_->long_, ==, 6);
  3147. g_assert_cmpint (struct_->int8, ==, 7);
  3148. }
  3149. GType
  3150. gi_marshalling_tests_pointer_struct_get_type (void)
  3151. {
  3152. static GType type = 0;
  3153. if (type == 0)
  3154. {
  3155. type = g_pointer_type_register_static ("GIMarshallingTestsPointerStruct");
  3156. }
  3157. return type;
  3158. }
  3159. /**
  3160. * gi_marshalling_tests_pointer_struct_returnv:
  3161. *
  3162. * Returns: (transfer none):
  3163. */
  3164. GIMarshallingTestsPointerStruct *
  3165. gi_marshalling_tests_pointer_struct_returnv (void)
  3166. {
  3167. static GIMarshallingTestsPointerStruct *struct_ = NULL;
  3168. if (struct_ == NULL)
  3169. {
  3170. struct_ = g_new (GIMarshallingTestsPointerStruct, 1);
  3171. struct_->long_ = 42;
  3172. }
  3173. return struct_;
  3174. }
  3175. /**
  3176. * gi_marshalling_tests_pointer_struct_inv:
  3177. * @struct_: (transfer none):
  3178. */
  3179. void
  3180. gi_marshalling_tests_pointer_struct_inv (GIMarshallingTestsPointerStruct *struct_)
  3181. {
  3182. g_assert_cmpint (struct_->long_, ==, 42);
  3183. }
  3184. static GIMarshallingTestsBoxedStruct *
  3185. gi_marshalling_tests_boxed_struct_copy (GIMarshallingTestsBoxedStruct *struct_)
  3186. {
  3187. GIMarshallingTestsBoxedStruct *new_struct;
  3188. if (struct_ == NULL)
  3189. return NULL;
  3190. new_struct = g_slice_new (GIMarshallingTestsBoxedStruct);
  3191. *new_struct = *struct_;
  3192. new_struct->string_ = g_strdup (struct_->string_);
  3193. return new_struct;
  3194. }
  3195. static void
  3196. gi_marshalling_tests_boxed_struct_free (GIMarshallingTestsBoxedStruct *struct_)
  3197. {
  3198. if (struct_ != NULL)
  3199. {
  3200. g_free (struct_->string_);
  3201. g_slice_free (GIMarshallingTestsBoxedStruct, struct_);
  3202. }
  3203. }
  3204. GType
  3205. gi_marshalling_tests_boxed_struct_get_type (void)
  3206. {
  3207. static GType type = 0;
  3208. if (type == 0)
  3209. {
  3210. type = g_boxed_type_register_static ("GIMarshallingTestsBoxedStruct",
  3211. (GBoxedCopyFunc)
  3212. gi_marshalling_tests_boxed_struct_copy,
  3213. (GBoxedFreeFunc) gi_marshalling_tests_boxed_struct_free);
  3214. }
  3215. return type;
  3216. }
  3217. static GType
  3218. gi_marshalling_tests_boxed_glist_get_type (void)
  3219. {
  3220. static GType type = 0;
  3221. if (type == 0)
  3222. {
  3223. type = g_boxed_type_register_static ("GIMarshallingTestsBoxedGList",
  3224. (GBoxedCopyFunc) g_list_copy, (GBoxedFreeFunc) g_list_free);
  3225. }
  3226. return type;
  3227. }
  3228. GIMarshallingTestsBoxedStruct *
  3229. gi_marshalling_tests_boxed_struct_new (void)
  3230. {
  3231. return g_slice_new0 (GIMarshallingTestsBoxedStruct);
  3232. }
  3233. /**
  3234. * gi_marshalling_tests_boxed_struct_returnv:
  3235. *
  3236. * Returns: (transfer none):
  3237. */
  3238. GIMarshallingTestsBoxedStruct *
  3239. gi_marshalling_tests_boxed_struct_returnv (void)
  3240. {
  3241. static GIMarshallingTestsBoxedStruct *struct_ = NULL;
  3242. if (struct_ == NULL)
  3243. {
  3244. struct_ = g_new (GIMarshallingTestsBoxedStruct, 1);
  3245. struct_->long_ = 42;
  3246. struct_->string_ = g_strdup ("hello");
  3247. struct_->g_strv = g_new0 (gchar *, 4);
  3248. struct_->g_strv[0] = g_strdup ("0");
  3249. struct_->g_strv[1] = g_strdup ("1");
  3250. struct_->g_strv[2] = g_strdup ("2");
  3251. struct_->g_strv[3] = NULL;
  3252. }
  3253. return struct_;
  3254. }
  3255. /**
  3256. * gi_marshalling_tests_boxed_struct_inv:
  3257. * @struct_: (transfer none):
  3258. */
  3259. void
  3260. gi_marshalling_tests_boxed_struct_inv (GIMarshallingTestsBoxedStruct *struct_)
  3261. {
  3262. g_assert_cmpint (struct_->long_, ==, 42);
  3263. }
  3264. /**
  3265. * gi_marshalling_tests_boxed_struct_out:
  3266. * @struct_: (out) (transfer none):
  3267. */
  3268. void
  3269. gi_marshalling_tests_boxed_struct_out (GIMarshallingTestsBoxedStruct **struct_)
  3270. {
  3271. static GIMarshallingTestsBoxedStruct *new_struct = NULL;
  3272. if (new_struct == NULL)
  3273. {
  3274. new_struct = g_new0 (GIMarshallingTestsBoxedStruct, 1);
  3275. new_struct->long_ = 42;
  3276. }
  3277. *struct_ = new_struct;
  3278. }
  3279. /**
  3280. * gi_marshalling_tests_boxed_struct_inout:
  3281. * @struct_: (inout) (transfer full):
  3282. */
  3283. void
  3284. gi_marshalling_tests_boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_)
  3285. {
  3286. g_assert_cmpint ((*struct_)->long_, ==, 42);
  3287. g_boxed_free (gi_marshalling_tests_boxed_struct_get_type(), *struct_);
  3288. (*struct_) = g_slice_new0 (GIMarshallingTestsBoxedStruct);
  3289. (*struct_)->long_ = 0;
  3290. }
  3291. static GIMarshallingTestsUnion *
  3292. gi_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
  3293. {
  3294. GIMarshallingTestsUnion *new_union;
  3295. new_union = g_slice_new (GIMarshallingTestsUnion);
  3296. *new_union = *union_;
  3297. return new_union;
  3298. }
  3299. static void
  3300. gi_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
  3301. {
  3302. g_slice_free (GIMarshallingTestsUnion, union_);
  3303. }
  3304. GType
  3305. gi_marshalling_tests_union_get_type (void)
  3306. {
  3307. static GType type = 0;
  3308. if (type == 0)
  3309. {
  3310. type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
  3311. (GBoxedCopyFunc)
  3312. gi_marshalling_tests_union_copy,
  3313. (GBoxedFreeFunc) gi_marshalling_tests_union_free);
  3314. }
  3315. return type;
  3316. }
  3317. /**
  3318. * gi_marshalling_tests_union_returnv:
  3319. *
  3320. * Returns: (transfer none):
  3321. */
  3322. GIMarshallingTestsUnion *
  3323. gi_marshalling_tests_union_returnv (void)
  3324. {
  3325. static GIMarshallingTestsUnion *union_ = NULL;
  3326. if (union_ == NULL)
  3327. {
  3328. union_ = g_new (GIMarshallingTestsUnion, 1);
  3329. union_->long_ = 42;
  3330. }
  3331. return union_;
  3332. }
  3333. /**
  3334. * gi_marshalling_tests_union_inv:
  3335. * @union_: (transfer none):
  3336. */
  3337. void
  3338. gi_marshalling_tests_union_inv (GIMarshallingTestsUnion *union_)
  3339. {
  3340. g_assert_cmpint (union_->long_, ==, 42);
  3341. }
  3342. void
  3343. gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
  3344. {
  3345. g_assert_cmpint (union_->long_, ==, 42);
  3346. }
  3347. enum
  3348. {
  3349. PROP_0,
  3350. PROP_INT_
  3351. };
  3352. static void
  3353. gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in);
  3354. G_DEFINE_TYPE (GIMarshallingTestsObject, gi_marshalling_tests_object, G_TYPE_OBJECT);
  3355. static void
  3356. gi_marshalling_tests_object_init (GIMarshallingTestsObject *object)
  3357. {
  3358. }
  3359. static void
  3360. gi_marshalling_tests_object_finalize (GObject *object)
  3361. {
  3362. G_OBJECT_CLASS (gi_marshalling_tests_object_parent_class)->finalize (object);
  3363. }
  3364. static void
  3365. gi_marshalling_tests_object_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
  3366. {
  3367. g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
  3368. switch (prop_id)
  3369. {
  3370. case PROP_INT_:
  3371. GI_MARSHALLING_TESTS_OBJECT (object)->int_ = g_value_get_int (value);
  3372. break;
  3373. default:
  3374. G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  3375. break;
  3376. }
  3377. }
  3378. static void
  3379. gi_marshalling_tests_object_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
  3380. {
  3381. g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
  3382. switch (prop_id)
  3383. {
  3384. case PROP_INT_:
  3385. g_value_set_int (value, GI_MARSHALLING_TESTS_OBJECT (object)->int_);
  3386. break;
  3387. default:
  3388. G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  3389. break;
  3390. }
  3391. }
  3392. static void
  3393. gi_marshalling_tests_object_class_init (GIMarshallingTestsObjectClass *klass)
  3394. {
  3395. GObjectClass *object_class = G_OBJECT_CLASS (klass);
  3396. #if 0
  3397. GObjectClass *parent_class = G_OBJECT_CLASS (klass);
  3398. #endif
  3399. object_class->finalize = gi_marshalling_tests_object_finalize;
  3400. object_class->set_property = gi_marshalling_tests_object_set_property;
  3401. object_class->get_property = gi_marshalling_tests_object_get_property;
  3402. g_object_class_install_property (object_class, PROP_INT_,
  3403. g_param_spec_int ("int", "Integer",
  3404. "An integer", G_MININT,
  3405. G_MAXINT, 0,
  3406. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  3407. klass->method_with_default_implementation = gi_marshalling_tests_object_real_method_with_default_implementation;
  3408. }
  3409. void
  3410. gi_marshalling_tests_object_static_method (void)
  3411. {
  3412. }
  3413. void
  3414. gi_marshalling_tests_object_method (GIMarshallingTestsObject *object)
  3415. {
  3416. g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
  3417. g_assert_cmpint (object->int_, ==, 42);
  3418. }
  3419. void
  3420. gi_marshalling_tests_object_overridden_method (GIMarshallingTestsObject *object)
  3421. {
  3422. g_return_if_fail (GI_MARSHALLING_TESTS_IS_OBJECT (object));
  3423. g_assert_cmpint (object->int_, ==, 0);
  3424. }
  3425. GIMarshallingTestsObject *
  3426. gi_marshalling_tests_object_new (gint int_)
  3427. {
  3428. return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, "int", int_, NULL);
  3429. }
  3430. GIMarshallingTestsObject *
  3431. gi_marshalling_tests_object_new_fail (gint int_, GError **error)
  3432. {
  3433. g_return_val_if_fail (error == NULL || *error == NULL, NULL);
  3434. g_set_error_literal (error,
  3435. g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN),
  3436. GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
  3437. GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
  3438. return NULL;
  3439. }
  3440. /**
  3441. * gi_marshalling_tests_object_method_array_in:
  3442. * @ints: (array length=length):
  3443. */
  3444. void
  3445. gi_marshalling_tests_object_method_array_in (GIMarshallingTestsObject *object, const gint *ints, gint length)
  3446. {
  3447. g_assert_cmpint (length, ==, 4);
  3448. g_assert_cmpint (ints[0], ==, -1);
  3449. g_assert_cmpint (ints[1], ==, 0);
  3450. g_assert_cmpint (ints[2], ==, 1);
  3451. g_assert_cmpint (ints[3], ==, 2);
  3452. }
  3453. /**
  3454. * gi_marshalling_tests_object_method_array_out:
  3455. * @ints: (out) (array length=length) (transfer none):
  3456. */
  3457. void
  3458. gi_marshalling_tests_object_method_array_out (GIMarshallingTestsObject *object, gint **ints, gint *length)
  3459. {
  3460. static gint values[] = { -1, 0, 1, 2 };
  3461. *length = 4;
  3462. *ints = values;
  3463. }
  3464. /**
  3465. * gi_marshalling_tests_object_method_array_inout:
  3466. * @ints: (inout) (array length=length) (transfer none):
  3467. * @length: (inout):
  3468. */
  3469. void
  3470. gi_marshalling_tests_object_method_array_inout (GIMarshallingTestsObject *object, gint **ints, gint *length)
  3471. {
  3472. static gint values[] = { -2, -1, 0, 1, 2 };
  3473. g_assert_cmpint (*length, ==, 4);
  3474. g_assert_cmpint ((*ints)[0], ==, -1);
  3475. g_assert_cmpint ((*ints)[1], ==, 0);
  3476. g_assert_cmpint ((*ints)[2], ==, 1);
  3477. g_assert_cmpint ((*ints)[3], ==, 2);
  3478. *length = 5;
  3479. *ints = values;
  3480. }
  3481. /**
  3482. * gi_marshalling_tests_object_method_array_return:
  3483. *
  3484. * Returns: (array length=length):
  3485. */
  3486. const gint *
  3487. gi_marshalling_tests_object_method_array_return (GIMarshallingTestsObject *object, gint *length)
  3488. {
  3489. static gint ints[] = { -1, 0, 1, 2 };
  3490. *length = 4;
  3491. return ints;
  3492. }
  3493. /**
  3494. * gi_marshalling_tests_object_method_int8_in:
  3495. * @in: (in):
  3496. */
  3497. void
  3498. gi_marshalling_tests_object_method_int8_in (GIMarshallingTestsObject *self, gint8 in)
  3499. {
  3500. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_in (self, in);
  3501. }
  3502. /**
  3503. * gi_marshalling_tests_object_method_int8_out:
  3504. * @out: (out):
  3505. */
  3506. void
  3507. gi_marshalling_tests_object_method_int8_out (GIMarshallingTestsObject *self, gint8 *out)
  3508. {
  3509. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_out (self, out);
  3510. }
  3511. /**
  3512. * gi_marshalling_tests_object_method_int8_arg_and_out_caller:
  3513. * @out: (out caller-allocates):
  3514. */
  3515. void
  3516. gi_marshalling_tests_object_method_int8_arg_and_out_caller (GIMarshallingTestsObject *self, gint8 arg, gint8 *out)
  3517. {
  3518. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_caller (self, arg, out);
  3519. }
  3520. /**
  3521. * gi_marshalling_tests_object_method_int8_arg_and_out_callee:
  3522. * @out: (out):
  3523. */
  3524. void
  3525. gi_marshalling_tests_object_method_int8_arg_and_out_callee (GIMarshallingTestsObject *self, gint8 arg, gint8 **out)
  3526. {
  3527. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_int8_arg_and_out_callee (self, arg, out);
  3528. }
  3529. /**
  3530. * gi_marshalling_tests_object_method_str_arg_out_ret:
  3531. * @out: (out caller-allocates):
  3532. *
  3533. * Returns: (transfer none)
  3534. */
  3535. const gchar *
  3536. gi_marshalling_tests_object_method_str_arg_out_ret (GIMarshallingTestsObject *self, const gchar *arg, guint *out)
  3537. {
  3538. return GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_str_arg_out_ret (self, arg, out);
  3539. }
  3540. /**
  3541. * gi_marshalling_tests_object_method_with_default_implementation:
  3542. * @in: (in):
  3543. */
  3544. void gi_marshalling_tests_object_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
  3545. {
  3546. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->method_with_default_implementation (self, in);
  3547. }
  3548. static void
  3549. gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshallingTestsObject *self, gint8 in)
  3550. {
  3551. GValue val = { 0, };
  3552. g_value_init (&val, G_TYPE_INT);
  3553. g_value_set_int (&val, in);
  3554. g_object_set_property (G_OBJECT (self), "int", &val);
  3555. }
  3556. /**
  3557. * gi_marshalling_tests_object_vfunc_with_callback: (virtual vfunc_with_callback)
  3558. * @callback: (scope call) (closure callback_data):
  3559. * @callback_data: (allow-none):
  3560. */
  3561. void
  3562. gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *
  3563. object, GIMarshallingTestsCallbackIntInt callback, void *callback_data)
  3564. {
  3565. }
  3566. static int
  3567. _callback (int val, void *user_data)
  3568. {
  3569. g_assert (user_data == (gpointer) 0xdeadbeef);
  3570. return val;
  3571. }
  3572. void
  3573. gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
  3574. {
  3575. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object, _callback, (void *) 0xdeadbeef);
  3576. }
  3577. /**
  3578. * gi_marshalling_tests_object_none_return:
  3579. *
  3580. * Returns: (transfer none):
  3581. */
  3582. GIMarshallingTestsObject *
  3583. gi_marshalling_tests_object_none_return (void)
  3584. {
  3585. static GIMarshallingTestsObject *object = NULL;
  3586. if (object == NULL)
  3587. {
  3588. object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
  3589. }
  3590. return object;
  3591. }
  3592. /**
  3593. * gi_marshalling_tests_object_full_return:
  3594. *
  3595. * Returns: (transfer full):
  3596. */
  3597. GIMarshallingTestsObject *
  3598. gi_marshalling_tests_object_full_return (void)
  3599. {
  3600. return g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
  3601. }
  3602. /**
  3603. * gi_marshalling_tests_object_none_in:
  3604. * @object: (transfer none):
  3605. */
  3606. void
  3607. gi_marshalling_tests_object_none_in (GIMarshallingTestsObject *object)
  3608. {
  3609. g_assert_cmpint (object->int_, ==, 42);
  3610. }
  3611. /**
  3612. * gi_marshalling_tests_object_none_out:
  3613. * @object: (out) (transfer none):
  3614. */
  3615. void
  3616. gi_marshalling_tests_object_none_out (GIMarshallingTestsObject **object)
  3617. {
  3618. static GIMarshallingTestsObject *new_object = NULL;
  3619. if (new_object == NULL)
  3620. {
  3621. new_object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
  3622. }
  3623. *object = new_object;
  3624. }
  3625. /**
  3626. * gi_marshalling_tests_object_full_out:
  3627. * @object: (out) (transfer full):
  3628. */
  3629. void
  3630. gi_marshalling_tests_object_full_out (GIMarshallingTestsObject **object)
  3631. {
  3632. *object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
  3633. }
  3634. /**
  3635. * gi_marshalling_tests_object_none_inout:
  3636. * @object: (inout) (transfer none):
  3637. */
  3638. void
  3639. gi_marshalling_tests_object_none_inout (GIMarshallingTestsObject **object)
  3640. {
  3641. static GIMarshallingTestsObject *new_object = NULL;
  3642. g_assert_cmpint ((*object)->int_, ==, 42);
  3643. if (new_object == NULL)
  3644. {
  3645. new_object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
  3646. new_object->int_ = 0;
  3647. }
  3648. *object = new_object;
  3649. }
  3650. /**
  3651. * gi_marshalling_tests_object_full_inout:
  3652. * @object: (inout) (transfer full):
  3653. */
  3654. void
  3655. gi_marshalling_tests_object_full_inout (GIMarshallingTestsObject **object)
  3656. {
  3657. g_assert_cmpint ((*object)->int_, ==, 42);
  3658. g_object_unref (*object);
  3659. *object = g_object_new (GI_MARSHALLING_TESTS_TYPE_OBJECT, NULL);
  3660. }
  3661. /**
  3662. * gi_marshalling_tests_object_int8_in:
  3663. * @in: (in):
  3664. */
  3665. void
  3666. gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in)
  3667. {
  3668. gi_marshalling_tests_object_method_int8_in (object, in);
  3669. }
  3670. /**
  3671. * gi_marshalling_tests_object_int8_out:
  3672. * @out: (out):
  3673. */
  3674. void
  3675. gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out)
  3676. {
  3677. gi_marshalling_tests_object_method_int8_out (object, out);
  3678. }
  3679. /**
  3680. * gi_marshalling_tests_object_vfunc_return_value_only:
  3681. */
  3682. glong
  3683. gi_marshalling_tests_object_vfunc_return_value_only (GIMarshallingTestsObject *self)
  3684. {
  3685. /* make sure that local variables don't get smashed */
  3686. glong return_value;
  3687. gulong local = 0x12345678;
  3688. return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_only (self);
  3689. g_assert_cmpint (local, ==, 0x12345678);
  3690. return return_value;
  3691. }
  3692. /**
  3693. * gi_marshalling_tests_object_vfunc_one_out_parameter:
  3694. * @a: (out):
  3695. */
  3696. void
  3697. gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *self, gfloat *a)
  3698. {
  3699. /* make sure that local variables don't get smashed */
  3700. gulong local = 0x12345678;
  3701. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_out_parameter (self, a);
  3702. g_assert_cmpint (local, ==, 0x12345678);
  3703. }
  3704. /**
  3705. * gi_marshalling_tests_object_vfunc_multiple_out_parameters:
  3706. * @a: (out):
  3707. * @b: (out):
  3708. */
  3709. void gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b)
  3710. {
  3711. /* make sure that local variables don't get smashed */
  3712. gulong local = 0x12345678;
  3713. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_out_parameters (self, a, b);
  3714. g_assert_cmpint (local, ==, 0x12345678);
  3715. }
  3716. /**
  3717. * gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter:
  3718. * @a: (out):
  3719. */
  3720. void gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a)
  3721. {
  3722. /* make sure that local variables don't get smashed */
  3723. gulong local = 0x12345678;
  3724. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_caller_allocated_out_parameter (self, a);
  3725. g_assert_cmpint (local, ==, 0x12345678);
  3726. }
  3727. /**
  3728. * gi_marshalling_tests_object_vfunc_array_out_parameter:
  3729. * @a: (out) (array zero-terminated):
  3730. */
  3731. void gi_marshalling_tests_object_vfunc_array_out_parameter (GIMarshallingTestsObject *self, gfloat **a)
  3732. {
  3733. /* make sure that local variables don't get smashed */
  3734. gulong local = 0x12345678;
  3735. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_array_out_parameter (self, a);
  3736. g_assert_cmpint (local, ==, 0x12345678);
  3737. }
  3738. /**
  3739. * gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter:
  3740. * @a: (out):
  3741. */
  3742. glong gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMarshallingTestsObject *self, glong *a)
  3743. {
  3744. /* make sure that local variables don't get smashed */
  3745. gulong return_value;
  3746. gulong local = 0x12345678;
  3747. return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_out_parameter (self, a);
  3748. g_assert_cmpint (local, ==, 0x12345678);
  3749. return return_value;
  3750. }
  3751. /**
  3752. * gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters:
  3753. * @a: (out):
  3754. * @b: (out):
  3755. */
  3756. glong
  3757. gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters
  3758. (GIMarshallingTestsObject *self, glong *a, glong *b)
  3759. {
  3760. gulong return_value;
  3761. gulong local = 0x12345678;
  3762. return_value =
  3763. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_out_parameters (self, a, b);
  3764. g_assert_cmpint (local, ==, 0x12345678);
  3765. return return_value;
  3766. }
  3767. /**
  3768. * gi_marshalling_tests_callback_owned_boxed:
  3769. * @callback: (scope call) (closure callback_data):
  3770. * @callback_data: (allow-none):
  3771. */
  3772. glong
  3773. gi_marshalling_tests_callback_owned_boxed (GIMarshallingTestsCallbackOwnedBoxed callback,
  3774. void *callback_data)
  3775. {
  3776. static GIMarshallingTestsBoxedStruct *box = NULL;
  3777. glong ret;
  3778. if (!box)
  3779. box = gi_marshalling_tests_boxed_struct_new ();
  3780. box->long_++;
  3781. callback (box, callback_data);
  3782. ret = box->long_;
  3783. return ret;
  3784. }
  3785. gboolean
  3786. gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *self, gint x, GError **error)
  3787. {
  3788. gulong local = 0x12345678;
  3789. gboolean ret = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_meth_with_err (self,
  3790. x,
  3791. error);
  3792. g_assert_cmpint (local, ==, 0x12345678);
  3793. return ret;
  3794. }
  3795. /**
  3796. * gi_marshalling_tests_object_vfunc_return_enum:
  3797. */
  3798. GIMarshallingTestsEnum
  3799. gi_marshalling_tests_object_vfunc_return_enum (GIMarshallingTestsObject *self)
  3800. {
  3801. /* make sure that local variables don't get smashed */
  3802. GIMarshallingTestsEnum return_value;
  3803. glong local = 0x12345678;
  3804. return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_enum (self);
  3805. g_assert_cmpint (local, ==, 0x12345678);
  3806. return return_value;
  3807. }
  3808. /**
  3809. * gi_marshalling_tests_object_vfunc_out_enum:
  3810. * @_enum: (out):
  3811. */
  3812. void
  3813. gi_marshalling_tests_object_vfunc_out_enum (GIMarshallingTestsObject *self, GIMarshallingTestsEnum *_enum)
  3814. {
  3815. /* make sure that local variables don't get smashed */
  3816. gulong local = 0x12345678;
  3817. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_enum (self, _enum);
  3818. g_assert_cmpint (local, ==, 0x12345678);
  3819. }
  3820. /* NOTE:
  3821. *
  3822. * The following (get_ref_info_for_*) methods are designed to call vfuncs related
  3823. * to object argument marshaling. They do not pass the resulting objects through them
  3824. * as regular vfunc wrapper method do, but rather return reference count and floating
  3825. * information back to the callers. This is useful because callers can do testing of
  3826. * expected reference counts in isolation and from the perspective of C. This is important
  3827. * because if there are bugs in the reverse marshaling, they can obfuscate or compound
  3828. * bugs in marshaling from the vfuncs.
  3829. */
  3830. /**
  3831. * gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_none:
  3832. * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
  3833. * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
  3834. */
  3835. void
  3836. gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_none
  3837. (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
  3838. {
  3839. GObject *object = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_object_transfer_none (self);
  3840. *ref_count = object->ref_count;
  3841. *is_floating = g_object_is_floating (object);
  3842. /* Attempt to sink and unref the returned object and avoid any potential leaks */
  3843. g_object_ref_sink (object);
  3844. g_object_unref (object);
  3845. }
  3846. /**
  3847. * gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_full:
  3848. * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
  3849. * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
  3850. */
  3851. void
  3852. gi_marshalling_tests_object_get_ref_info_for_vfunc_return_object_transfer_full
  3853. (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
  3854. {
  3855. GObject *object = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_object_transfer_full (self);
  3856. *ref_count = object->ref_count;
  3857. *is_floating = g_object_is_floating (object);
  3858. g_object_unref (object);
  3859. }
  3860. /**
  3861. * gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_none:
  3862. * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
  3863. * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
  3864. */
  3865. void
  3866. gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_none
  3867. (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
  3868. {
  3869. GObject *object = NULL;
  3870. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_object_transfer_none (self, &object);
  3871. *ref_count = object->ref_count;
  3872. *is_floating = g_object_is_floating (object);
  3873. /* Attempt to sink and unref the returned object and avoid any potential leaks */
  3874. g_object_ref_sink (object);
  3875. g_object_unref (object);
  3876. }
  3877. /**
  3878. * gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_full:
  3879. * @ref_count: (out): Ref count of the object returned from the vfunc directly after vfunc call.
  3880. * @is_floating: (out): Floating state object returned from the vfunc directly after vfunc call.
  3881. */
  3882. void
  3883. gi_marshalling_tests_object_get_ref_info_for_vfunc_out_object_transfer_full
  3884. (GIMarshallingTestsObject *self, guint *ref_count, gboolean *is_floating)
  3885. {
  3886. GObject *object = NULL;
  3887. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_out_object_transfer_full (self, &object);
  3888. *ref_count = object->ref_count;
  3889. *is_floating = g_object_is_floating (object);
  3890. g_object_unref (object);
  3891. }
  3892. static void
  3893. _vfunc_in_object_destroy_callback (gboolean *destroy_called, GObject *where_the_object_was)
  3894. {
  3895. *destroy_called = TRUE;
  3896. }
  3897. /**
  3898. * gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_none:
  3899. * @type: GType of object to create and pass as in argument to the vfunc
  3900. * @ref_count: (out): Ref count of the in object directly after vfunc call.
  3901. * @is_floating: (out): Floating state of in object directly after vfunc call.
  3902. *
  3903. * Calls vfunc_in_object_transfer_none with a new object of the given type.
  3904. */
  3905. void
  3906. gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_none
  3907. (GIMarshallingTestsObject *self, GType type, guint *ref_count, gboolean *is_floating)
  3908. {
  3909. static gboolean destroy_called;
  3910. GObject *object;
  3911. destroy_called = FALSE;
  3912. object = g_object_new (type, NULL);
  3913. g_object_weak_ref (object, (GWeakNotify) _vfunc_in_object_destroy_callback, &destroy_called);
  3914. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_in_object_transfer_none (self, object);
  3915. if (destroy_called)
  3916. {
  3917. *ref_count = 0;
  3918. *is_floating = FALSE;
  3919. }
  3920. else
  3921. {
  3922. *ref_count = object->ref_count;
  3923. *is_floating = g_object_is_floating (object);
  3924. g_object_unref (object);
  3925. }
  3926. }
  3927. /**
  3928. * gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_full:
  3929. * @type: GType of object to create and pass as in argument to the vfunc
  3930. * @ref_count: (out): Ref count of the in object directly after vfunc call.
  3931. * @is_floating: (out): Floating state of in object directly after vfunc call.
  3932. */
  3933. void
  3934. gi_marshalling_tests_object_get_ref_info_for_vfunc_in_object_transfer_full
  3935. (GIMarshallingTestsObject *self, GType type, guint *ref_count, gboolean *is_floating)
  3936. {
  3937. static gboolean destroy_called;
  3938. GObject *object;
  3939. destroy_called = FALSE;
  3940. object = g_object_new (type, NULL);
  3941. g_object_weak_ref (object, (GWeakNotify) _vfunc_in_object_destroy_callback, &destroy_called);
  3942. /* Calling the vfunc takes ownership of the object, so we use a weak_ref to determine
  3943. * if the object gets destroyed after the call and appropriately return 0 as the ref count.
  3944. */
  3945. GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_in_object_transfer_full (self, object);
  3946. if (destroy_called)
  3947. {
  3948. *ref_count = 0;
  3949. *is_floating = FALSE;
  3950. }
  3951. else
  3952. {
  3953. *ref_count = object->ref_count;
  3954. *is_floating = g_object_is_floating (object);
  3955. }
  3956. }
  3957. G_DEFINE_TYPE (GIMarshallingTestsSubObject, gi_marshalling_tests_sub_object, GI_MARSHALLING_TESTS_TYPE_OBJECT);
  3958. static void
  3959. gi_marshalling_tests_sub_object_init (GIMarshallingTestsSubObject *object)
  3960. {
  3961. }
  3962. static void
  3963. gi_marshalling_tests_sub_object_finalize (GObject *object)
  3964. {
  3965. G_OBJECT_CLASS (gi_marshalling_tests_sub_object_parent_class)->finalize (object);
  3966. }
  3967. static void
  3968. method_deep_hierarchy (GIMarshallingTestsObject *self, gint8 in)
  3969. {
  3970. GValue val = { 0, };
  3971. g_value_init (&val, G_TYPE_INT);
  3972. g_value_set_int (&val, in);
  3973. g_object_set_property (G_OBJECT (self), "int", &val);
  3974. }
  3975. static void
  3976. gi_marshalling_tests_sub_object_class_init (GIMarshallingTestsSubObjectClass *klass)
  3977. {
  3978. G_OBJECT_CLASS (klass)->finalize = gi_marshalling_tests_sub_object_finalize;
  3979. GI_MARSHALLING_TESTS_OBJECT_CLASS (klass)->method_deep_hierarchy = method_deep_hierarchy;
  3980. }
  3981. void
  3982. gi_marshalling_tests_sub_object_sub_method (GIMarshallingTestsSubObject *object)
  3983. {
  3984. g_assert_cmpint (GI_MARSHALLING_TESTS_OBJECT (object)->int_, ==, 0);
  3985. }
  3986. void gi_marshalling_tests_sub_object_overwritten_method (GIMarshallingTestsSubObject *object)
  3987. {
  3988. g_assert_cmpint (GI_MARSHALLING_TESTS_OBJECT (object)->int_, ==, 0);
  3989. }
  3990. G_DEFINE_TYPE (GIMarshallingTestsSubSubObject,
  3991. gi_marshalling_tests_sub_sub_object, GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT);
  3992. static void
  3993. gi_marshalling_tests_sub_sub_object_init (GIMarshallingTestsSubSubObject *object)
  3994. {
  3995. }
  3996. static void gi_marshalling_tests_sub_sub_object_class_init (GIMarshallingTestsSubSubObjectClass *klass)
  3997. {
  3998. }
  3999. /* Interfaces */
  4000. static void
  4001. gi_marshalling_tests_interface_class_init (void *g_iface)
  4002. {
  4003. }
  4004. GType
  4005. gi_marshalling_tests_interface_get_type (void)
  4006. {
  4007. static GType type = 0;
  4008. if (type == 0)
  4009. {
  4010. /* Not adding prerequisite here for test purposes */
  4011. type = g_type_register_static_simple (G_TYPE_INTERFACE,
  4012. "GIMarshallingTestsInterface",
  4013. sizeof
  4014. (GIMarshallingTestsInterfaceIface),
  4015. (GClassInitFunc) gi_marshalling_tests_interface_class_init, 0, NULL, 0);
  4016. }
  4017. return type;
  4018. }
  4019. /**
  4020. * gi_marshalling_tests_interface_test_int8_in:
  4021. * @in: (in):
  4022. */
  4023. void
  4024. gi_marshalling_tests_interface_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
  4025. {
  4026. GI_MARSHALLING_TESTS_INTERFACE_GET_IFACE (self)->test_int8_in (self, in);
  4027. }
  4028. /**
  4029. * gi_marshalling_tests_test_interface_test_int8_in:
  4030. * @in: (in):
  4031. */
  4032. void
  4033. gi_marshalling_tests_test_interface_test_int8_in (GIMarshallingTestsInterface *test_iface, gint8 in)
  4034. {
  4035. gi_marshalling_tests_interface_test_int8_in (test_iface, in);
  4036. }
  4037. static void test_interface_init (GIMarshallingTestsInterfaceIface *iface);
  4038. G_DEFINE_TYPE_WITH_CODE (GIMarshallingTestsInterfaceImpl, gi_marshalling_tests_interface_impl, G_TYPE_OBJECT,
  4039. G_IMPLEMENT_INTERFACE(GI_MARSHALLING_TESTS_TYPE_INTERFACE, test_interface_init))
  4040. static void
  4041. gi_marshalling_tests_interface_impl_test_int8_in (GIMarshallingTestsInterface *self, gint8 in)
  4042. {
  4043. }
  4044. static void test_interface_init (GIMarshallingTestsInterfaceIface *iface)
  4045. {
  4046. iface->test_int8_in = gi_marshalling_tests_interface_impl_test_int8_in;
  4047. }
  4048. static void
  4049. gi_marshalling_tests_interface_impl_init (GIMarshallingTestsInterfaceImpl *object)
  4050. {
  4051. }
  4052. static void
  4053. gi_marshalling_tests_interface_impl_class_init (GIMarshallingTestsInterfaceImplClass *klass)
  4054. {
  4055. }
  4056. /**
  4057. * gi_marshalling_tests_interface_impl_get_as_interface:
  4058. *
  4059. * Returns: (transfer none):
  4060. */
  4061. GIMarshallingTestsInterface *
  4062. gi_marshalling_tests_interface_impl_get_as_interface (GIMarshallingTestsInterfaceImpl *self)
  4063. {
  4064. return (GIMarshallingTestsInterface *) self;
  4065. }
  4066. static void
  4067. gi_marshalling_tests_interface2_class_init (void *g_iface)
  4068. {
  4069. }
  4070. GType
  4071. gi_marshalling_tests_interface2_get_type (void)
  4072. {
  4073. static GType type = 0;
  4074. if (type == 0)
  4075. {
  4076. type = g_type_register_static_simple (G_TYPE_INTERFACE,
  4077. "GIMarshallingTestsInterface2",
  4078. sizeof
  4079. (GIMarshallingTestsInterface2Iface),
  4080. (GClassInitFunc) gi_marshalling_tests_interface2_class_init, 0, NULL, 0);
  4081. }
  4082. return type;
  4083. }
  4084. static void
  4085. gi_marshalling_tests_interface3_class_init (void *g_iface)
  4086. {
  4087. }
  4088. GType
  4089. gi_marshalling_tests_interface3_get_type (void)
  4090. {
  4091. static GType type = 0;
  4092. if (type == 0)
  4093. {
  4094. type = g_type_register_static_simple (G_TYPE_INTERFACE,
  4095. "GIMarshallingTestsInterface3",
  4096. sizeof
  4097. (GIMarshallingTestsInterface3Iface),
  4098. (GClassInitFunc) gi_marshalling_tests_interface3_class_init, 0, NULL, 0);
  4099. }
  4100. return type;
  4101. }
  4102. /**
  4103. * gi_marshalling_tests_interface3_test_variant_array_in:
  4104. * @in: (array length=n_in):
  4105. * @n_in:
  4106. */
  4107. void
  4108. gi_marshalling_tests_interface3_test_variant_array_in
  4109. (GIMarshallingTestsInterface3 *self, GVariant **in, gsize n_in)
  4110. {
  4111. GI_MARSHALLING_TESTS_INTERFACE3_GET_IFACE (self)->test_variant_array_in (self, in, n_in);
  4112. }
  4113. /**
  4114. * gi_marshalling_tests_int_out_out:
  4115. * @int0: (out):
  4116. * @int1: (out):
  4117. */
  4118. void
  4119. gi_marshalling_tests_int_out_out (gint *int0, gint *int1)
  4120. {
  4121. *int0 = 6;
  4122. *int1 = 7;
  4123. }
  4124. /**
  4125. * gi_marshalling_tests_int_three_in_three_out:
  4126. * @a: (in):
  4127. * @b: (in):
  4128. * @c: (in):
  4129. * @out0: (out):
  4130. * @out1: (out):
  4131. * @out2: (out):
  4132. */
  4133. void
  4134. gi_marshalling_tests_int_three_in_three_out (gint a, gint b, gint c, gint *out0, gint *out1, gint *out2)
  4135. {
  4136. *out0 = a;
  4137. *out1 = b;
  4138. *out2 = c;
  4139. }
  4140. /**
  4141. * gi_marshalling_tests_int_return_out:
  4142. * @int_: (out):
  4143. */
  4144. gint
  4145. gi_marshalling_tests_int_return_out (gint *int_)
  4146. {
  4147. *int_ = 7;
  4148. return 6;
  4149. }
  4150. /**
  4151. * gi_marshalling_tests_int_two_in_utf8_two_in_with_allow_none:
  4152. * @a: (in): Must be 1
  4153. * @b: (in): Must be 2
  4154. * @c: (in) (allow-none): Must be "3" or NULL
  4155. * @d: (in) (allow-none): Must be "4" or NULL
  4156. */
  4157. void
  4158. gi_marshalling_tests_int_two_in_utf8_two_in_with_allow_none (gint a, gint b, const gchar *c, const gchar *d)
  4159. {
  4160. g_assert_cmpint (a, ==, 1);
  4161. g_assert_cmpint (b, ==, 2);
  4162. if (c != NULL)
  4163. g_assert_cmpstr (c, ==, "3");
  4164. if (d != NULL)
  4165. g_assert_cmpstr (d, ==, "4");
  4166. }
  4167. /**
  4168. * gi_marshalling_tests_int_one_in_utf8_two_in_one_allows_none:
  4169. * @a: (in): Must be 1
  4170. * @b: (in) (allow-none): Must be "2" or NULL
  4171. * @c: (in): Must be "3"
  4172. */
  4173. void
  4174. gi_marshalling_tests_int_one_in_utf8_two_in_one_allows_none (gint a, const gchar *b, const gchar *c)
  4175. {
  4176. g_assert_cmpint (a, ==, 1);
  4177. if (b != NULL)
  4178. g_assert_cmpstr (b, ==, "2");
  4179. g_assert_cmpstr (c, ==, "3");
  4180. }
  4181. /**
  4182. * gi_marshalling_tests_array_in_utf8_two_in:
  4183. * @ints: (array length=length):
  4184. * @length:
  4185. * @a: (in) (allow-none): Must be "1" or NULL
  4186. * @b: (in) (allow-none): Must be "2" or NULL
  4187. */
  4188. void
  4189. gi_marshalling_tests_array_in_utf8_two_in (const gint *ints, gint length, const gchar *a, const gchar *b)
  4190. {
  4191. g_assert_cmpint (length, ==, 4);
  4192. g_assert_cmpint (ints[0], ==, -1);
  4193. g_assert_cmpint (ints[1], ==, 0);
  4194. g_assert_cmpint (ints[2], ==, 1);
  4195. g_assert_cmpint (ints[3], ==, 2);
  4196. if (a != NULL)
  4197. g_assert_cmpstr (a, ==, "1");
  4198. if (b != NULL)
  4199. g_assert_cmpstr (b, ==, "2");
  4200. }
  4201. /**
  4202. * gi_marshalling_tests_array_in_utf8_two_in_out_of_order:
  4203. * @length:
  4204. * @a: (in) (allow-none): Must be "1" or NULL
  4205. * @ints: (array length=length):
  4206. * @b: (in) (allow-none): Must be "2" or NULL
  4207. */
  4208. void
  4209. gi_marshalling_tests_array_in_utf8_two_in_out_of_order (gint length, const gchar *a, const gint *ints, const gchar *b)
  4210. {
  4211. g_assert_cmpint (length, ==, 4);
  4212. g_assert_cmpint (ints[0], ==, -1);
  4213. g_assert_cmpint (ints[1], ==, 0);
  4214. g_assert_cmpint (ints[2], ==, 1);
  4215. g_assert_cmpint (ints[3], ==, 2);
  4216. if (a != NULL)
  4217. g_assert_cmpstr (a, ==, "1");
  4218. if (b != NULL)
  4219. g_assert_cmpstr (b, ==, "2");
  4220. }
  4221. /* GError */
  4222. void
  4223. gi_marshalling_tests_gerror (GError **error)
  4224. {
  4225. GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
  4226. g_set_error_literal (error, quark,
  4227. GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
  4228. }
  4229. /**
  4230. * gi_marshalling_tests_gerror_array_in:
  4231. * @in_ints: (array zero-terminated):
  4232. */
  4233. void
  4234. gi_marshalling_tests_gerror_array_in (gint *in_ints, GError **error)
  4235. {
  4236. GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
  4237. g_set_error_literal (error, quark,
  4238. GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
  4239. }
  4240. /**
  4241. * gi_marshalling_tests_gerror_out:
  4242. * @error: (out) (allow-none) (transfer full): location for the GError.
  4243. * @debug: (out) (allow-none) (transfer full): location for the debug message
  4244. *
  4245. * Inspired by gst_message_parse_error.
  4246. */
  4247. void
  4248. gi_marshalling_tests_gerror_out (GError **error, gchar **debug)
  4249. {
  4250. GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
  4251. g_set_error_literal (error, quark,
  4252. GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
  4253. if (debug != NULL)
  4254. {
  4255. *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
  4256. }
  4257. }
  4258. /**
  4259. * gi_marshalling_tests_gerror_out_transfer_none:
  4260. * @err: (out) (allow-none) (transfer none): location for the GError.
  4261. * @debug: (out) (allow-none) (transfer none): location for the debug message
  4262. *
  4263. * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
  4264. * must not free.
  4265. */
  4266. void
  4267. gi_marshalling_tests_gerror_out_transfer_none (GError **err, const gchar **debug)
  4268. {
  4269. static GError error = { 0,
  4270. GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
  4271. GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE
  4272. };
  4273. error.domain = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
  4274. *err = &error;
  4275. *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
  4276. }
  4277. /**
  4278. * gi_marshalling_tests_gerror_return:
  4279. *
  4280. * Yet another variant of gi_marshalling_tests_gerror_out().
  4281. *
  4282. * Returns: (transfer full): a GError
  4283. */
  4284. GError *
  4285. gi_marshalling_tests_gerror_return (void)
  4286. {
  4287. GQuark quark = g_quark_from_static_string (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
  4288. return g_error_new (quark, GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE, GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
  4289. }
  4290. static GIMarshallingTestsOverridesStruct *
  4291. gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
  4292. {
  4293. GIMarshallingTestsOverridesStruct *new_struct;
  4294. new_struct = g_slice_new (GIMarshallingTestsOverridesStruct);
  4295. *new_struct = *struct_;
  4296. return new_struct;
  4297. }
  4298. static void
  4299. gi_marshalling_tests_overrides_struct_free (GIMarshallingTestsOverridesStruct *struct_)
  4300. {
  4301. g_slice_free (GIMarshallingTestsOverridesStruct, struct_);
  4302. }
  4303. GType
  4304. gi_marshalling_tests_overrides_struct_get_type (void)
  4305. {
  4306. static GType type = 0;
  4307. if (type == 0)
  4308. {
  4309. type =
  4310. g_boxed_type_register_static ("GIMarshallingTestsOverridesStruct",
  4311. (GBoxedCopyFunc)
  4312. gi_marshalling_tests_overrides_struct_copy,
  4313. (GBoxedFreeFunc) gi_marshalling_tests_overrides_struct_free);
  4314. }
  4315. return type;
  4316. }
  4317. GIMarshallingTestsOverridesStruct *
  4318. gi_marshalling_tests_overrides_struct_new (void)
  4319. {
  4320. return g_slice_new (GIMarshallingTestsOverridesStruct);
  4321. }
  4322. glong gi_marshalling_tests_overrides_struct_method (GIMarshallingTestsOverridesStruct *struct_)
  4323. {
  4324. return 42;
  4325. }
  4326. /**
  4327. * gi_marshalling_tests_overrides_struct_returnv:
  4328. *
  4329. * Returns: (transfer full):
  4330. */
  4331. GIMarshallingTestsOverridesStruct *
  4332. gi_marshalling_tests_overrides_struct_returnv (void)
  4333. {
  4334. return gi_marshalling_tests_overrides_struct_new ();
  4335. }
  4336. G_DEFINE_TYPE (GIMarshallingTestsOverridesObject, gi_marshalling_tests_overrides_object, G_TYPE_OBJECT);
  4337. static void
  4338. gi_marshalling_tests_overrides_object_init (GIMarshallingTestsOverridesObject *object)
  4339. {
  4340. }
  4341. static void
  4342. gi_marshalling_tests_overrides_object_finalize (GObject *object)
  4343. {
  4344. G_OBJECT_CLASS (gi_marshalling_tests_overrides_object_parent_class)->finalize (object);
  4345. }
  4346. static void gi_marshalling_tests_overrides_object_class_init (GIMarshallingTestsOverridesObjectClass *klass)
  4347. {
  4348. GObjectClass *object_class = G_OBJECT_CLASS (klass);
  4349. #if 0
  4350. GObjectClass *parent_class = G_OBJECT_CLASS (klass);
  4351. #endif
  4352. object_class->finalize = gi_marshalling_tests_overrides_object_finalize;
  4353. }
  4354. GIMarshallingTestsOverridesObject *
  4355. gi_marshalling_tests_overrides_object_new (void)
  4356. {
  4357. return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
  4358. }
  4359. glong gi_marshalling_tests_overrides_object_method (GIMarshallingTestsOverridesObject *object)
  4360. {
  4361. return 42;
  4362. }
  4363. /**
  4364. * gi_marshalling_tests_overrides_object_returnv:
  4365. *
  4366. * Returns: (transfer full):
  4367. */
  4368. GIMarshallingTestsOverridesObject *
  4369. gi_marshalling_tests_overrides_object_returnv (void)
  4370. {
  4371. return g_object_new (GI_MARSHALLING_TESTS_TYPE_OVERRIDES_OBJECT, NULL);
  4372. }
  4373. /**
  4374. * gi_marshalling_tests_filename_list_return:
  4375. *
  4376. * Returns: (transfer none) (element-type filename): List of filenames
  4377. */
  4378. GSList *
  4379. gi_marshalling_tests_filename_list_return (void)
  4380. {
  4381. return NULL;
  4382. }
  4383. /**
  4384. * gi_marshalling_tests_param_spec_in_bool:
  4385. */
  4386. void
  4387. gi_marshalling_tests_param_spec_in_bool (const GParamSpec *param)
  4388. {
  4389. g_assert (G_IS_PARAM_SPEC (param));
  4390. g_assert_cmpint (G_PARAM_SPEC_VALUE_TYPE (param), ==, G_TYPE_BOOLEAN);
  4391. g_assert_cmpstr (g_param_spec_get_name ((GParamSpec *) param), ==, "mybool");
  4392. }
  4393. /**
  4394. * gi_marshalling_tests_param_spec_return:
  4395. *
  4396. * Returns: (transfer full): a #GParamSpec
  4397. */
  4398. GParamSpec *
  4399. gi_marshalling_tests_param_spec_return (void)
  4400. {
  4401. return g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
  4402. }
  4403. /**
  4404. * gi_marshalling_tests_param_spec_out:
  4405. * @param: (out):
  4406. */
  4407. void
  4408. gi_marshalling_tests_param_spec_out (GParamSpec **param)
  4409. {
  4410. *param = g_param_spec_string ("test-param", "test", "This is a test", "42", G_PARAM_READABLE);
  4411. }
  4412. enum
  4413. {
  4414. DUMMY_PROPERTY,
  4415. SOME_BOOLEAN_PROPERTY,
  4416. SOME_CHAR_PROPERTY,
  4417. SOME_UCHAR_PROPERTY,
  4418. SOME_INT_PROPERTY,
  4419. SOME_UINT_PROPERTY,
  4420. SOME_LONG_PROPERTY,
  4421. SOME_ULONG_PROPERTY,
  4422. SOME_INT64_PROPERTY,
  4423. SOME_UINT64_PROPERTY,
  4424. SOME_FLOAT_PROPERTY,
  4425. SOME_DOUBLE_PROPERTY,
  4426. SOME_STRV_PROPERTY,
  4427. SOME_BOXED_STRUCT_PROPERTY,
  4428. SOME_VARIANT_PROPERTY,
  4429. SOME_BOXED_GLIST_PROPERTY,
  4430. SOME_OBJECT_PROPERTY,
  4431. };
  4432. G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT);
  4433. static void gi_marshalling_tests_properties_object_init (GIMarshallingTestsPropertiesObject *self)
  4434. {
  4435. }
  4436. static void
  4437. gi_marshalling_tests_properties_object_finalize (GObject *obj)
  4438. {
  4439. GIMarshallingTestsPropertiesObject *self;
  4440. self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (obj);
  4441. if (self->some_strv != NULL) {
  4442. g_strfreev (self->some_strv);
  4443. self->some_strv = NULL;
  4444. }
  4445. G_OBJECT_CLASS (gi_marshalling_tests_properties_object_parent_class)->finalize (obj);
  4446. }
  4447. static void
  4448. gi_marshalling_tests_properties_object_get_property (GObject *object,
  4449. guint property_id, GValue *value, GParamSpec *pspec)
  4450. {
  4451. GIMarshallingTestsPropertiesObject *self;
  4452. self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
  4453. switch (property_id)
  4454. {
  4455. case SOME_BOOLEAN_PROPERTY:
  4456. g_value_set_boolean (value, self->some_boolean);
  4457. break;
  4458. case SOME_CHAR_PROPERTY:
  4459. g_value_set_schar (value, self->some_char);
  4460. break;
  4461. case SOME_UCHAR_PROPERTY:
  4462. g_value_set_uchar (value, self->some_uchar);
  4463. break;
  4464. case SOME_INT_PROPERTY:
  4465. g_value_set_int (value, self->some_int);
  4466. break;
  4467. case SOME_UINT_PROPERTY:
  4468. g_value_set_uint (value, self->some_uint);
  4469. break;
  4470. case SOME_LONG_PROPERTY:
  4471. g_value_set_long (value, self->some_long);
  4472. break;
  4473. case SOME_ULONG_PROPERTY:
  4474. g_value_set_ulong (value, self->some_ulong);
  4475. break;
  4476. case SOME_INT64_PROPERTY:
  4477. g_value_set_int64 (value, self->some_int64);
  4478. break;
  4479. case SOME_UINT64_PROPERTY:
  4480. g_value_set_uint64 (value, self->some_uint64);
  4481. break;
  4482. case SOME_FLOAT_PROPERTY:
  4483. g_value_set_float (value, self->some_float);
  4484. break;
  4485. case SOME_DOUBLE_PROPERTY:
  4486. g_value_set_double (value, self->some_double);
  4487. break;
  4488. case SOME_STRV_PROPERTY:
  4489. g_value_set_boxed (value, self->some_strv);
  4490. break;
  4491. case SOME_BOXED_STRUCT_PROPERTY:
  4492. g_value_set_boxed (value, self->some_boxed_struct);
  4493. break;
  4494. case SOME_BOXED_GLIST_PROPERTY:
  4495. g_value_set_boxed (value, self->some_boxed_glist);
  4496. break;
  4497. case SOME_VARIANT_PROPERTY:
  4498. g_value_set_variant (value, self->some_variant);
  4499. break;
  4500. case SOME_OBJECT_PROPERTY:
  4501. g_value_set_object (value, self->some_object);
  4502. break;
  4503. default:
  4504. G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  4505. break;
  4506. }
  4507. }
  4508. static void
  4509. gi_marshalling_tests_properties_object_set_property (GObject *object,
  4510. guint property_id, const GValue *value, GParamSpec *pspec)
  4511. {
  4512. GIMarshallingTestsPropertiesObject *self;
  4513. self = GI_MARSHALLING_TESTS_PROPERTIES_OBJECT (object);
  4514. switch (property_id)
  4515. {
  4516. case SOME_BOOLEAN_PROPERTY:
  4517. self->some_boolean = g_value_get_boolean (value);
  4518. break;
  4519. case SOME_CHAR_PROPERTY:
  4520. self->some_char = g_value_get_schar (value);
  4521. break;
  4522. case SOME_UCHAR_PROPERTY:
  4523. self->some_uchar = g_value_get_uchar (value);
  4524. break;
  4525. case SOME_INT_PROPERTY:
  4526. self->some_int = g_value_get_int (value);
  4527. break;
  4528. case SOME_UINT_PROPERTY:
  4529. self->some_uint = g_value_get_uint (value);
  4530. break;
  4531. case SOME_LONG_PROPERTY:
  4532. self->some_long = g_value_get_long (value);
  4533. break;
  4534. case SOME_ULONG_PROPERTY:
  4535. self->some_ulong = g_value_get_ulong (value);
  4536. break;
  4537. case SOME_INT64_PROPERTY:
  4538. self->some_int64 = g_value_get_int64 (value);
  4539. break;
  4540. case SOME_UINT64_PROPERTY:
  4541. self->some_uint64 = g_value_get_uint64 (value);
  4542. break;
  4543. case SOME_FLOAT_PROPERTY:
  4544. self->some_float = g_value_get_float (value);
  4545. break;
  4546. case SOME_DOUBLE_PROPERTY:
  4547. self->some_double = g_value_get_double (value);
  4548. break;
  4549. case SOME_STRV_PROPERTY:
  4550. g_strfreev (self->some_strv);
  4551. self->some_strv = g_strdupv (g_value_get_boxed (value));
  4552. break;
  4553. case SOME_BOXED_STRUCT_PROPERTY:
  4554. gi_marshalling_tests_boxed_struct_free (self->some_boxed_struct);
  4555. self->some_boxed_struct = gi_marshalling_tests_boxed_struct_copy (g_value_get_boxed (value));
  4556. break;
  4557. case SOME_BOXED_GLIST_PROPERTY:
  4558. g_list_free (self->some_boxed_glist);
  4559. self->some_boxed_glist = g_list_copy (g_value_get_boxed (value));
  4560. break;
  4561. case SOME_VARIANT_PROPERTY:
  4562. if (self->some_variant != NULL)
  4563. g_variant_unref (self->some_variant);
  4564. self->some_variant = g_value_get_variant (value);
  4565. if (self->some_variant != NULL)
  4566. g_variant_ref (self->some_variant);
  4567. break;
  4568. case SOME_OBJECT_PROPERTY:
  4569. if (self->some_object != NULL)
  4570. g_object_unref (self->some_object);
  4571. self->some_object = g_value_dup_object (value);
  4572. break;
  4573. default:
  4574. G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  4575. break;
  4576. }
  4577. }
  4578. static void gi_marshalling_tests_properties_object_class_init (GIMarshallingTestsPropertiesObjectClass *klass)
  4579. {
  4580. GObjectClass *object_class = G_OBJECT_CLASS (klass);
  4581. object_class->finalize = gi_marshalling_tests_properties_object_finalize;
  4582. object_class->get_property = gi_marshalling_tests_properties_object_get_property;
  4583. object_class->set_property = gi_marshalling_tests_properties_object_set_property;
  4584. g_object_class_install_property (object_class, SOME_BOOLEAN_PROPERTY,
  4585. g_param_spec_boolean ("some-boolean",
  4586. "some-boolean",
  4587. "some-boolean",
  4588. FALSE,
  4589. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4590. g_object_class_install_property (object_class, SOME_CHAR_PROPERTY,
  4591. g_param_spec_char ("some-char",
  4592. "some-char",
  4593. "some-char", G_MININT8,
  4594. G_MAXINT8, 0,
  4595. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4596. g_object_class_install_property (object_class, SOME_UCHAR_PROPERTY,
  4597. g_param_spec_uchar ("some-uchar",
  4598. "some-uchar",
  4599. "some-uchar", 0,
  4600. G_MAXUINT8, 0,
  4601. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4602. g_object_class_install_property (object_class, SOME_INT_PROPERTY,
  4603. g_param_spec_int ("some-int", "some-int",
  4604. "some-int", G_MININT,
  4605. G_MAXINT, 0,
  4606. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4607. g_object_class_install_property (object_class, SOME_UINT_PROPERTY,
  4608. g_param_spec_uint ("some-uint",
  4609. "some-uint",
  4610. "some-uint", 0,
  4611. G_MAXUINT, 0,
  4612. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4613. g_object_class_install_property (object_class, SOME_LONG_PROPERTY,
  4614. g_param_spec_long ("some-long",
  4615. "some-long",
  4616. "some-long", G_MINLONG,
  4617. G_MAXLONG, 0,
  4618. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4619. g_object_class_install_property (object_class, SOME_ULONG_PROPERTY,
  4620. g_param_spec_ulong ("some-ulong",
  4621. "some-ulong",
  4622. "some-ulong", 0,
  4623. G_MAXULONG, 0,
  4624. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4625. g_object_class_install_property (object_class, SOME_INT64_PROPERTY,
  4626. g_param_spec_int64 ("some-int64",
  4627. "some-int64",
  4628. "some-int64",
  4629. G_MININT64, G_MAXINT64,
  4630. 0, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4631. g_object_class_install_property (object_class, SOME_UINT64_PROPERTY,
  4632. g_param_spec_uint64 ("some-uint64",
  4633. "some-uint64",
  4634. "some-uint64", 0,
  4635. G_MAXUINT64, 0,
  4636. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4637. g_object_class_install_property (object_class, SOME_FLOAT_PROPERTY,
  4638. g_param_spec_float ("some-float",
  4639. "some-float",
  4640. "some-float",
  4641. -1 * G_MAXFLOAT,
  4642. G_MAXFLOAT, 0,
  4643. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4644. g_object_class_install_property (object_class, SOME_DOUBLE_PROPERTY,
  4645. g_param_spec_double ("some-double",
  4646. "some-double",
  4647. "some-double",
  4648. -1 * G_MAXDOUBLE,
  4649. G_MAXDOUBLE, 0,
  4650. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4651. g_object_class_install_property (object_class, SOME_STRV_PROPERTY,
  4652. g_param_spec_boxed ("some-strv",
  4653. "some-strv",
  4654. "some-strv",
  4655. G_TYPE_STRV,
  4656. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4657. g_object_class_install_property (object_class, SOME_BOXED_STRUCT_PROPERTY,
  4658. g_param_spec_boxed ("some-boxed-struct",
  4659. "some-boxed-struct",
  4660. "some-boxed-struct",
  4661. gi_marshalling_tests_boxed_struct_get_type
  4662. (), G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4663. /**
  4664. * GIMarshallingTestsPropertiesObject:some-boxed-glist: (type GLib.List(gint)) (transfer none):
  4665. */
  4666. g_object_class_install_property (object_class, SOME_BOXED_GLIST_PROPERTY,
  4667. g_param_spec_boxed ("some-boxed-glist",
  4668. "some-boxed-glist",
  4669. "some-boxed-glist",
  4670. gi_marshalling_tests_boxed_glist_get_type
  4671. (), G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4672. g_object_class_install_property (object_class, SOME_VARIANT_PROPERTY,
  4673. g_param_spec_variant ("some-variant",
  4674. "some-variant",
  4675. "some-variant",
  4676. G_VARIANT_TYPE_ANY,
  4677. NULL,
  4678. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4679. g_object_class_install_property (object_class, SOME_OBJECT_PROPERTY,
  4680. g_param_spec_object ("some-object",
  4681. "some-object",
  4682. "some-object",
  4683. G_TYPE_OBJECT,
  4684. G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
  4685. }
  4686. GIMarshallingTestsPropertiesObject *
  4687. gi_marshalling_tests_properties_object_new (void)
  4688. {
  4689. return g_object_new (GI_MARSHALLING_TESTS_TYPE_PROPERTIES_OBJECT, NULL);
  4690. }