{"id":3095,"date":"2018-12-09T21:04:56","date_gmt":"2018-12-09T12:04:56","guid":{"rendered":"http:\/\/oohito.com\/nqthm\/?p=3095"},"modified":"2018-12-09T21:04:56","modified_gmt":"2018-12-09T12:04:56","slug":"pharo%e3%81%8b%e3%82%89c%e3%81%a7%e6%9b%b8%e3%81%84%e3%81%9f%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0%e3%82%92%e5%91%bc%e3%81%b3%e5%87%ba%e3%81%99","status":"publish","type":"post","link":"https:\/\/oohito.com\/nqthm\/archives\/3095","title":{"rendered":"Pharo\u304b\u3089C\u3067\u66f8\u3044\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u547c\u3073\u51fa\u3059"},"content":{"rendered":"\n<p>\u3053\u308c\u306f<a href=\"https:\/\/qiita.com\/advent-calendar\/2018\/smalltalk\">Smalltalk Advent Calendar 2018<\/a>\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n\n\n<p>\u3054\u304f\u7a00\u306bPharo\u304b\u3089\u5916\u90e8\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u547c\u3073\u51fa\u3057\u3066\u4f7f\u3044\u305f\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u4ee5\u524d\u306f\u5916\u90e8\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u547c\u3073\u51fa\u3059\u4ed5\u7d44\u307f\u304c\u6bce\u5e74\u306e\u3088\u3046\u306b\u5909\u308f\u3063\u3066\u3044\u305f\u305f\u3081\u3001\u3061\u3087\u3063\u3068\u3054\u7121\u6c99\u6c70\u3057\u3066\u3044\u308b\u3068\u7f6e\u3044\u3066\u3051\u307c\u308a\u3092\u98df\u3089\u3046\u3053\u3068\u304c\u591a\u3005\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n<p>\u6700\u8fd1\u3067\u306f UFFI \u3068\u3044\u3046\u4ed5\u7d44\u307f\u3067\u843d\u3061\u7740\u3044\u305f\u611f\u304c\u3042\u308a\u307e\u3059\u304c\u3001Pharo \u306e\u3053\u3068\u306a\u306e\u3067\u307e\u305f\u5909\u308f\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f UFFI \u3092\u4f7f\u3063\u3066 Pharo \u304b\u3089 C \u3067\u66f8\u3044\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u547c\u3073\u51fa\u3059\u65b9\u6cd5\u3092\u7c21\u5358\u306b\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n<h2 class=\"wp-block-heading\">C\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u6e96\u5099<\/h2>\n\n\n<p>\u307e\u305a\u306f\u3001C\u8a00\u8a9e\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u7528\u610f\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\u666e\u6bb5 Linux \u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3001Linux (64bit) \u3092\u4f8b\u306b\u8aac\u660e\u3057\u307e\u3059\u3002\u304a\u305d\u3089\u304f\u3001mingw \u3092\u4f7f\u3048\u3070 Windows \u3067\u3082\u540c\u3058\u3088\u3046\u306b\u3044\u3051\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-preformatted\">int doublenumber(int n)<br \/>{<br \/>    return n * 2;<br \/>}<br \/><\/pre>\n\n\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u7528\u610f\u3057\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u540d\u306f uffitest.c \u3068\u3057\u307e\u3059\u3002\u5185\u5bb9\u306f\u6574\u6570\u30922\u500d\u3059\u308b doublenumber \u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n\n\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u5171\u6709\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-preformatted\">gcc -fPIC -shared -o uffitest.so uffitest.c<\/pre>\n\n\n<p>\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b uffitest.so \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u3067\u304d\u307e\u3059\u3002<br \/><\/p>\n\n\n<h2 class=\"wp-block-heading\">UFFITestLibrary \u30af\u30e9\u30b9\u306e\u4f5c\u6210<br \/><\/h2>\n\n\n<p>Pharo \u3092\u8d77\u52d5\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f Linux \u7248\u306ePharo6.1 \u306e\u30a4\u30e1\u30fc\u30b8\u3092 64bit VM \u3067\u8d77\u52d5\u3057\u305f\u3082\u306e\u3068\u3057\u307e\u3059\u3002UFFILibrary \u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u305f UFFITestLibrary \u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/><\/p>\n\n\n<pre class=\"wp-block-preformatted\">FFILibrary subclass: #UFFITestLibrary<br \/>\n    instanceVariableNames: ''<br \/>\n    classVariableNames: ''<br \/>\n    package: 'UFFITest'<\/pre>\n\n\n<p>\u3053\u306e\u30af\u30e9\u30b9\u3067\u5916\u90e8\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u306e\u7d50\u3073\u3064\u304d\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30e1\u30bd\u30c3\u30c9\u3068\u3057\u3066\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-preformatted\">unixModuleName<br \/>    ^ 'uffitest.so'<\/pre>\n\n\n<p>\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u5148\u7a0b\u4f5c\u3063\u305f uffitest.so \u30d5\u30a1\u30a4\u30eb\u306e\u3042\u308a\u304b\u3092\u793a\u3057\u307e\u3059\u3002\u30a4\u30e1\u30fc\u30b8\u3068\u540c\u3058\u5834\u6240\u306b\u3042\u308b\u306a\u3089\u30d1\u30b9\u6307\u5b9a\u306f\u4e0d\u8981\u306a\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n<p>\u4ed6\u306eOS\u3067\u4f7f\u3046\u5834\u5408\u306b\u306f\u5225\u306e\u30e1\u30bd\u30c3\u30c9\u540d\u3092\u7528\u3044\u307e\u3059\u3002Mac OS X\u306a\u3089\u3070 macModuleName \u3068\u3057\u3001Windows \u306a\u3089\u3070 win32ModuleName \u3092\u4f7f\u3044\u307e\u3059\u3002Windows \u306f 32bit VM \u3057\u304b\u516c\u958b\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u5148\u7a0b\u306e\u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\u308232bt\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n<h2 class=\"wp-block-heading\">\u5916\u90e8\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u547c\u3073\u51fa\u3059\u30e1\u30bd\u30c3\u30c9\u306e\u8ffd\u52a0<br \/><\/h2>\n\n\n<p>doublenumber \u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u3069\u3093\u306a\u30af\u30e9\u30b9\u306b\u66f8\u3044\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u3067\u306f\u30c6\u30b9\u30c8\u306e\u305f\u3081 UFFITest \u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-preformatted\">Object subclass: #UFFITest<br \/>\n    instanceVariableNames: ''<br \/>\n    classVariableNames: ''<br \/>\n    package: 'UFFITest'<\/pre>\n\n\n<p>\u4f55\u306e\u5909\u54f2\u3082\u306a\u3044 Object \u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u305f\u30af\u30e9\u30b9\u3067\u3059\u3002\u3053\u306e\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5074\u306b doubleNumber: \u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u767b\u9332\u3057\u307e\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u5f15\u6570\u3092\uff11\u3064\u53d6\u308a\u3001\u305d\u306e2\u500d\u306e\u5024\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-preformatted\">doubleNumber: anInteger<br \/>\n    ^ self ffiCall: #( int doublenumber (int anInteger)) module: UFFITestLibrary<\/pre>\n\n\n<p>\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f #ffiCall:module: \u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u308b\u3060\u3051\u306e\u3082\u306e\u3067\u3059\u3002\u7b2c\u4e00\u5f15\u6570\u306b\u306f C\u8a00\u8a9e\u306e\u95a2\u6570\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7\u5ba3\u8a00\u306e\u3088\u3046\u306a\u5f62\u5f0f\u3067\u3001\u547c\u3073\u51fa\u3059\u95a2\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u7b2c\u4e8c\u5f15\u6570\u306b\u306f\u5171\u6709\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5b9a\u7fa9\u3057\u305f\u30af\u30e9\u30b9\u540d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/><\/p>\n\n\n<h2 class=\"wp-block-heading\">\u8a66\u3057\u3066\u307f\u308b<br \/><\/h2>\n\n\n<p>\u4ee5\u4e0a\u3067\u6e96\u5099\u306f\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\u5b9f\u969b\u306b\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002Playground \u3092\u958b\u3044\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n\n\n<pre class=\"wp-block-preformatted\">UFFITest new doubleNumber: 10. <br \/><\/pre>\n\n\n<p>Go \u3092\u62bc\u305b\u3070\u7d50\u679c(20)\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n<h2 class=\"wp-block-heading\">\u30a8\u30e9\u30fc\uff1f<\/h2>\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/oohito.com\/nqthm\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-09-20-44-16-1-700x187.png\" alt=\"\" class=\"wp-image-3099\"\/><\/figure>\n\n\n<p>External module not found \u3068\u3044\u3046\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u51fa\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u9069\u5207\u306a\u5171\u6709\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u6642\u306b\u73fe\u308c\u307e\u3059\u3002Pharo \u306e\u30a4\u30e1\u30fc\u30b8\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u304b\u300132bit VM\u306a\u306e\u306b64bit\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u306a\u3063\u3066\u3044\u306a\u3044\u304b\u3001UFFITestLibrary \u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u9593\u9055\u3063\u3066\u3044\u306a\u3044\u304b\u306a\u3069\u3001\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n<h2 class=\"wp-block-heading\">\u304a\u308f\u308a\u306b<br \/><\/h2>\n\n\n<p>\u3069\u3046\u3060\u3063\u305f\u3067\u3057\u3087\u3046\u304b\uff1f\u7c21\u5358\u306bC\u8a00\u8a9e\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u305b\u308b\u3053\u3068\u304c\u308f\u304b\u3063\u305f\u3068\u601d\u3044\u307e\u3059\u3002C-API \u3092\u6301\u3063\u3066\u3044\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u6d3b\u7528\u3059\u308b\u52a9\u3051\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<br \/><\/p>\n\n\n<p><br \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u308c\u306fSmalltalk Advent Calendar 2018\u306e\u8a18\u4e8b\u3067\u3059\u3002 \u3054\u304f\u7a00\u306bPharo\u304b\u3089\u5916\u90e8\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u547c\u3073\u51fa\u3057\u3066\u4f7f\u3044\u305f\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u4ee5\u524d\u306f\u5916\u90e8\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u547c\u3073\u51fa\u3059\u4ed5\u7d44\u307f\u304c\u6bce\u5e74\u306e\u3088\u3046\u306b\u5909\u308f\u3063\u3066\u3044\u305f\u305f\u3081&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,19],"tags":[],"class_list":["post-3095","post","type-post","status-publish","format-standard","hentry","category-pharo","category-tutorials"],"_links":{"self":[{"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/posts\/3095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/comments?post=3095"}],"version-history":[{"count":0,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/posts\/3095\/revisions"}],"wp:attachment":[{"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/media?parent=3095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/categories?post=3095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oohito.com\/nqthm\/wp-json\/wp\/v2\/tags?post=3095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}