4 ==================================
6 ==================================
8 コード生成器で Ring アプリケーションへ C/C++ ライブラリを接続する方法を学びます。
16 コード生成プログラムは parsec.ring であり、
17 Ring で別の Ring コードを実行できます
19 URL : https://github.com/ring-lang/ring/tree/master/extensions/codegen
21 例えば、設定ファイル test.cf を読み込んでソースコードファイル test.c を生成するには、 parsec.ring を実行します。
25 ring parsec.ring test.cf test.c
34 設定ファイル (\*.cf) は、コード生成器への入力ファイルです。
35 このファイルは C/C++ ライブラリから呼び出す関数プロトタイプを決定します。
37 設定ファイルの記述方法は次の規則に従います。
40 pair: コード生成器; 関数プロトタイプの用法
43 ======================
45 * C 関数の接続用コードを生成するには、 C 関数プロトタイプを記述します。
51 ALLEGRO_DISPLAY *al_create_display(int w, int h)
52 void al_destroy_display(ALLEGRO_DISPLAY *display)
53 int al_get_new_display_flags(void)
54 void al_set_new_display_flags(int flags)
55 int al_get_new_display_option(int option, int *importance)
57 前述の用例では al_create_display(), al_destroy_display(), al_get_new_display_flags(),
58 al_set_new_diplay_flas() および al_get_new_display_option()
59 関数の接続に五本の関数生成をコード生成器に指示します。
67 RING_FUNC(ring_al_create_display)
69 if ( RING_API_PARACOUNT != 2 ) {
70 RING_API_ERROR(RING_API_MISS2PARA);
73 if ( ! RING_API_ISNUMBER(1) ) {
74 RING_API_ERROR(RING_API_BADPARATYPE);
77 if ( ! RING_API_ISNUMBER(2) ) {
78 RING_API_ERROR(RING_API_BADPARATYPE);
81 RING_API_RETCPOINTER(al_create_display( (int ) RING_API_GETNUMBER(1),
82 (int ) RING_API_GETNUMBER(2)),"ALLEGRO_DISPLAY");
86 RING_FUNC(ring_al_destroy_display)
88 if ( RING_API_PARACOUNT != 1 ) {
89 RING_API_ERROR(RING_API_MISS1PARA);
92 if ( ! RING_API_ISPOINTER(1) ) {
93 RING_API_ERROR(RING_API_BADPARATYPE);
96 al_destroy_display((ALLEGRO_DISPLAY *) RING_API_GETCPOINTER(1,"ALLEGRO_DISPLAY"));
100 RING_FUNC(ring_al_get_new_display_flags)
102 if ( RING_API_PARACOUNT != 0 ) {
103 RING_API_ERROR(RING_API_BADPARACOUNT);
106 RING_API_RETNUMBER(al_get_new_display_flags());
110 RING_FUNC(ring_al_set_new_display_flags)
112 if ( RING_API_PARACOUNT != 1 ) {
113 RING_API_ERROR(RING_API_MISS1PARA);
116 if ( ! RING_API_ISNUMBER(1) ) {
117 RING_API_ERROR(RING_API_BADPARATYPE);
120 al_set_new_display_flags( (int ) RING_API_GETNUMBER(1));
124 RING_FUNC(ring_al_get_new_display_option)
126 if ( RING_API_PARACOUNT != 2 ) {
127 RING_API_ERROR(RING_API_MISS2PARA);
130 if ( ! RING_API_ISNUMBER(1) ) {
131 RING_API_ERROR(RING_API_BADPARATYPE);
134 if ( ! RING_API_ISSTRING(2) ) {
135 RING_API_ERROR(RING_API_BADPARATYPE);
138 RING_API_RETNUMBER(al_get_new_display_option( (int ) RING_API_GETNUMBER(1),
139 RING_API_GETINTPOINTER(2)));
140 RING_API_ACCEPTINTVALUE(2) ;
143 前述の用例から、コード生成器は時間と手間の節約になることがわかります。
151 * コードを直接生成するには <code> ~ </code> に追加したいコードを記述してください。
158 /* こちらへ C コードを書いてください。 */
161 この機能はコード生成器で処理を行わないコードの記述時に使用します。
162 例えば、ヘッダファイルやマクロによる定数の定義などです。
165 pair: コード生成器; 関数名の接頭辞
170 * 全ての関数に付ける接頭辞を決定するには <funcstart> ~ </funcstart> に指定したい接頭辞を記述してください。
171 例えば、 Allegro ゲームプログラミング・ライブラリを接続した後に全てのライブラリ関数名が
172 “al” で始まるようにするためには、このコードを設定ファイルへ記述します。
181 pair: コード生成器; 構造体を接続する関数の生成
184 ==========================
186 * 構造体の接続用関数を生成するには (構造体メンバの作成、削除、取得)
187 <struct> ~ </struct> に指定したい構造体名を記述してください。
188 なお、構造体名を記述してから { ~ } に構造体メンバをコンマで区切って記述します。
196 ALLEGRO_EVENT { type , keyboard.keycode , mouse.x , mouse.y }
199 前述の用例では ALLEGRO_COLOR 構造体の作成と削除を行う二本の関数を生成します。
200 また ALLEGRO_EVENT 構造体の作成と削除を行う二本の関数、および
201 ALLEGRO_EVENT のメンバ (type, keyboard.keycode, mouse.x, mouse.y) を受け取る四本の関数を生成します。
204 pair: コード生成器; 構造体メンバ型の決定
209 構造体メンバ名の先頭にポインタの名前を決定できます。
215 SDL_Surface {flags,SDL_PixelFormat *format,w,h,pitch,void *pixels}
223 <constant> ~ </constant> で定数を定義します。
225 生成器は定数の値を取得するのに必要な関数を生成します。
227 また、 Ring ヘッダファイル (\*.rh) から同一ファイル名の Ring コードで用いる定数の定義も生成します。
241 .. note:: 生成されたソースファイルの後には必ず parsec.ring へ \*.rh ファイル名を渡してください。
247 ring ..\codegen\parsec.ring libsdl.cf ring_libsdl.c ring_libsdl.rh
250 pair: コード生成器; 新しい関数の登録
255 <register> ~ </register> に関数プロトタイプを記述することで、関数を登録できます。
256 このような関数のコードは、関数プロトタイプを直接記述しない場合に限り記述が必要です。
267 RING_FUNC(ring_al_exit)
269 if ( RING_API_PARACOUNT != 0 ) {
270 RING_API_ERROR(RING_API_BADPARACOUNT);
277 前述の用例では al_exit() 関数を登録しました。この関数は Allegro ライブラリの一部ではありませんが、必要なので追加した関数です。この関数が <code> ~ </code> にある場合はコードとして扱われます。この関数は C 言語ライブラリから exit() 関数を呼び出します。
280 pair: コード生成器; 設定ファイルにコメントを書くには
283 ================================
285 * コメントは <comment> ~ </comment> に記述します。
296 pair: コード生成器; コードの生成時にコード実行するには
299 ==================================
301 * コード生成器で設定ファイルを読み込むときに Ring コードの実行を要求するには
302 <runcode> ~ </runcode> にコードを書きます。
309 aNumberTypes + "al_fixed"
312 前述の行は文字列“al_fixed”をリスト NumberTypes へ追加するためのコードです。
313 このリストには、関数プロトタイプにおいてコード生成器が検出したときに数値としてみなせる型があります。
321 関数プロトタイプで使用する列挙型の追加用に aEnumTypes リストがあります。
328 aNumberTypes + "qreal"
329 aNumberTypes + "qint64"
330 aEnumTypes + "Qt::GestureType"
331 aEnumTypes + "Qt::GestureFlag"
336 pair: コード生成器; 条件式による篩い分け
341 <filter> ~ </filter> は、
342 条件に基づいて設定ファイルの一部を包含または除外します。例えば、
347 ... functions related to windows
357 しかし、定数は別の型でも良いです。例えば、 (ポインタ : void \*)
359 <constant> ~ </constant> の使用前に <runcode> ~ </runcode> を記述することで、
360 コード生成器で使われる二つのグローバル変数を用いて定数の型を決定します。
362 最初の変数は $nDefaultConstantType であり、この定数を指定できます。
364 * C_CONSTANT_TYPE_NUMBER
365 * C_CONSTANT_TYPE_STRING
366 * C_CONSTANT_TYPE_POINTER
368 C_CONSTANT_TYPE_POINTER の使用時は、
369 $cDefaultConstantPointerType の二つ目にあるグローバル変数のポインタ型の決定が必要です。
373 この用例では、この機能を FreeGLUT ライブラリーにおける定数の定義で使用しています。
378 $nDefaultConstantType = C_CONSTANT_TYPE_POINTER
379 $cDefaultConstantPointerType = "void"
383 GLUT_STROKE_MONO_ROMAN
386 GLUT_BITMAP_TIMES_ROMAN_10
387 GLUT_BITMAP_TIMES_ROMAN_24
388 GLUT_BITMAP_HELVETICA_10
389 GLUT_BITMAP_HELVETICA_12
390 GLUT_BITMAP_HELVETICA_18
394 pair: コード生成器; Allegro ライブラリ用の設定ファイル
396 Allegro ライブラリ用の設定ファイル
397 ==================================
399 この設定ファイル (1000行以下) は Allegro ライブラリの関数用です。
400 このファイルをコード生成器で処理したときに生成される C 言語コードは約 12000 行です!
402 この設定ファイルはコード生成器の完全な用例として参照できます。
404 RingAllegro 関数の確認にも使えます!
409 #define ALLEGRO_NO_MAGIC_MAIN
411 #include <allegro5/allegro.h>
412 #include "allegro5/allegro_image.h"
413 #include <allegro5/allegro_font.h>
414 #include <allegro5/allegro_ttf.h>
415 #include <allegro5/allegro_audio.h>
416 #include <allegro5/allegro_acodec.h>
417 #include <allegro5/allegro_opengl.h>
418 #include <allegro5/allegro_direct3d.h>
419 #include <allegro5/allegro_color.h>
420 #include <allegro5/allegro_memfile.h>
421 #include "allegro5/allegro_native_dialog.h"
422 #include <allegro5/allegro_physfs.h>
423 #include <allegro5/allegro_primitives.h>
431 ALLEGRO_EVENT { type , keyboard.keycode , mouse.x , mouse.y }
442 RING_FUNC(ring_al_exit)
444 if ( RING_API_PARACOUNT != 0 ) {
445 RING_API_ERROR(RING_API_BADPARACOUNT);
459 aNumberTypes + "al_fixed"
462 ALLEGRO_CONFIG *al_create_config(void)
463 void al_destroy_config(ALLEGRO_CONFIG *config)
464 ALLEGRO_CONFIG *al_load_config_file(const char *filename)
465 ALLEGRO_CONFIG *al_load_config_file_f(ALLEGRO_FILE *file)
466 bool al_save_config_file(const char *filename, const ALLEGRO_CONFIG *config)
467 bool al_save_config_file_f(ALLEGRO_FILE *file, const ALLEGRO_CONFIG *config)
468 void al_add_config_section(ALLEGRO_CONFIG *config, const char *name)
472 完全なコピーは Ring ソースコードの配布物をご確認ください。
475 pair: コード生成器; スレッドへの対応
480 この設定ファイルの別の部分は、スレッドライブラリで Ring アプリケーションへスレッドを
481 追加する方法について学ぶことができるため重要です。
483 考えかたとして Ring コードを実行するために ring_vm_mutexfunctions() および ring_vm_runcodefromthread() を使用します。
492 void *al_func_thread(ALLEGRO_THREAD *thread, void *pPointer)
497 pList = (List *) pPointer ;
498 pVM = (VM *) ring_list_getpointer(pList,2);
499 cStr = ring_list_getstring(pList,1);
500 ring_vm_runcodefromthread(pVM,cStr);
501 ring_list_delete(pList);
505 RING_FUNC(ring_al_create_thread)
507 ALLEGRO_THREAD *pThread;
509 if ( RING_API_PARACOUNT != 1 ) {
510 RING_API_ERROR(RING_API_MISS1PARA);
513 if ( ! RING_API_ISSTRING(1) ) {
514 RING_API_ERROR(RING_API_BADPARATYPE);
517 pList = ring_list_new(0);
518 ring_list_addstring(pList,RING_API_GETSTRING(1));
519 ring_list_addpointer(pList,pPointer);
520 ring_vm_mutexfunctions((VM *) pPointer,al_create_mutex,
521 al_lock_mutex,al_unlock_mutex,al_destroy_mutex);
522 pThread = al_create_thread(al_func_thread, pList);
523 al_start_thread(pThread);
524 RING_API_RETCPOINTER(pThread,"ALLEGRO_THREAD");
527 RING_FUNC(ring_al_run_detached_thread)
530 if ( RING_API_PARACOUNT != 1 ) {
531 RING_API_ERROR(RING_API_MISS1PARA);
534 if ( ! RING_API_ISSTRING(1) ) {
535 RING_API_ERROR(RING_API_BADPARATYPE);
538 pList = ring_list_new(0);
539 ring_list_addstring(pList,RING_API_GETSTRING(1));
540 ring_list_addpointer(pList,pPointer);
541 ring_vm_mutexfunctions((VM *) pPointer,al_create_mutex,
542 al_lock_mutex,al_unlock_mutex,al_destroy_mutex);
543 al_run_detached_thread(al_func_thread, pList);
548 ALLEGRO_THREAD *al_create_thread(void)
549 void al_run_detached_thread(void)
552 void al_start_thread(ALLEGRO_THREAD *thread)
553 void al_join_thread(ALLEGRO_THREAD *thread, void **ret_value)
554 void al_set_thread_should_stop(ALLEGRO_THREAD *thread)
555 bool al_get_thread_should_stop(ALLEGRO_THREAD *thread)
556 void al_destroy_thread(ALLEGRO_THREAD *thread)
557 ALLEGRO_MUTEX *al_create_mutex(void)
558 ALLEGRO_MUTEX *al_create_mutex_recursive(void)
559 void al_lock_mutex(ALLEGRO_MUTEX *mutex)
560 void al_unlock_mutex(ALLEGRO_MUTEX *mutex)
561 void al_destroy_mutex(ALLEGRO_MUTEX *mutex)
562 ALLEGRO_COND *al_create_cond(void)
563 void al_destroy_cond(ALLEGRO_COND *cond)
564 void al_wait_cond(ALLEGRO_COND *cond, ALLEGRO_MUTEX *mutex)
567 pair: コード生成器; C++ クラスの接続に関するコード生成器の規則
569 C++ クラスの接続に関するコード生成器の規則
570 ==========================================
572 * <class> ~ </class> にクラスを定義します。
573 * <class> ~ </class> に“name, nonew, para, parent, codename,
574 passvmpointer, abstract および staticmethods”などの属性を設定できます。
575 * 値が不要な場合に限り、属性名:値 (attributename:value)、
576 または属性名 (attributename) による記法で属性を設定します。
577 * “name” 属性は C++ コードのクラス名を決定します。
578 また、この名前は Ring コードにおけるデフォルトの名前になります。
579 * nonew 命令はメソッドの新規作成または削除は不要であることを意味します。
580 * parent 属性は親クラス名を決定します。
581 * codename 属性は C++ コードで別のクラス名を決定します。
582 * passvmpointer 命令は新しいオブジェクトの作成時にクラスのコンストラクタへ
583 Ring 仮想計算機のポインタを渡すことを意味します。これは codename 属性をクラス定義として設定するときに発生するため、
584 このクラスでは仮想計算機のポインタが必要です
585 (例えば C++ から Ring コードの実行のために使用)。
586 * abstract 命令は、このクラスでは“オブジェクトが作成されない”ため、新しいメソッドは不要であることを意味します。
587 * staticmethods 命令はメソッドを呼び出すためのオブジェ クトを用意する必要はないことを意味します。
588 * <nodllstartup> により #include “ring.h” を回避できます。これはスタートアップコードを記述するために必要です。
589 * <libinitfunc> によりライブラリ関数へ登録する関数名を変更できます。
590 * <ignorecpointertype> はポインタ型の検査を無視します。
591 * aStringTypes リストは const char \* として扱われる新しい型を定義します。
592 * aBeforeReturn リストは関数から変数を返すときに変数名末尾に挿入される
594 * aNewMethodName リストは C++ のメソッドを呼び出すときに Ring のコードで使用されるメソッドの別名を定義できます。
595 この機能は、 C++ メソッドで “load”, ”next”, ”end” および “done” など
596 Ring のキーワードと同一名称であるため必要となるものです。
597 * メソッドのプロトタイプでは - メソッド名に @ を使うときは、
598 同じメソッドで様々な仮引数 (C++ のように) があることを意味します。
601 pair: コード生成器; C++ ライブラリ接続用設定ファイルの用法
603 C++ ライブラリ接続用設定ファイルの用法
604 ======================================
606 Ring アプリケーションから C++ ライブラリを使うにはコード生成器でコードを生成します。
607 C ライブラリで使うと、 \*.c ファイルではなく \*.cpp ファイルを生成します。
608 また、生成ファイルも決定します (\*.ring)。
609 このファイルには C++ のクラスとオブジェクトを使用する C++ 関数と接続するための Ring コードによるクラスがあります。
613 ring parsec.ring generator\qt.cf ring_qt.cpp ring_qt.ring
617 pair: コード生成器; Qt フレームワーク用の設定ファイル
620 =================================
622 これは Qt クラスとの接続に用いる設定ファイルです。
623 設定ファイルは約 3500 行であり、生成されるコードは約 56000 行の C++ コード、
624 および約 9000 行の Ring コードとなります。
630 <libinitfunc> ring_qt_start
641 #include "gpushbutton.h"
643 #include "glineedit.h"
644 #include "gtextedit.h"
645 #include "glistwidget.h"
646 #include "gtreeview.h"
647 #include "gtreewidget.h"
648 #include "gcombobox.h"
649 #include "gtabwidget.h"
650 #include "gtablewidget.h"
651 #include "gprogressbar.h"
652 #include "gspinbox.h"
655 #include "gwebview.h"
656 #include "gcheckbox.h"
657 #include "gradiobutton.h"
658 #include "gbuttongroup.h"
659 #include "gvideowidget.h"
661 #include "gtcpserver.h"
662 #include "giodevice.h"
663 #include "gabstractsocket.h"
664 #include "gtcpsocket.h"
665 #include "gcolordialog.h"
666 #include "gallevents.h"
667 #include <QApplication>
674 #include <QPushButton>
675 #include <QMainWindow>
676 #include <QVBoxLayout>
677 #include <QHBoxLayout>
680 #include <QListWidget>
683 #include <QFileSystemModel>
684 #include <QTreeWidget>
685 #include <QTreeWidgetItem>
691 #include <QMainWindow>
692 #include <QStatusBar>
693 #include <QDockWidget>
694 #include <QTabWidget>
695 #include <QTableWidget>
696 #include <QTableWidgetItem>
697 #include <QSizePolicy>
699 #include <QAbstractScrollArea>
700 #include <QAbstractItemView>
701 #include <QProgressBar>
704 #include <QAbstractSlider>
706 #include <QDateTimeEdit>
707 #include <QAbstractSpinBox>
712 #include <QRadioButton>
713 #include <QButtonGroup>
714 #include <QMediaPlayer>
715 #include <QMediaPlaylist>
716 #include <QVideoWidget>
720 #include <QMessageBox>
722 #include <QFileDialog>
729 #include <QWebSettings>
731 #include <QByteArray>
733 #include <QAbstractSocket>
734 #include <QTcpSocket>
735 #include <QTcpServer>
736 #include <QNetworkProxy>
737 #include <QHostAddress>
742 #include <QModelIndex>
743 #include <QFontDialog>
745 #include <QTextCursor>
746 #include <QTextBlock>
747 #include <QTextDocumentFragment>
748 #include <QColorDialog>
749 #include <QHeaderView>
750 #include <QStringList>
751 #include <QKeySequence>
752 #include <QLCDNumber>
753 #include <QInputDialog>
754 #include <QDesktopWidget>
756 #include <QTextDocument>
760 #define RING_DLL __declspec(dllexport)
762 RING_DLL void ringlib_init(RingState *pRingState)
765 new QApplication(pRingState->argc,pRingState->argv);
766 ring_qt_start(pRingState) ;
774 aStringTypes + "QString"
775 aBeforeReturn + ["QString",".toStdString().c_str()"]
776 aNewMethodName + ["QWebView","load","loadpage"]
777 aNewMethodName + ["QMediaPlaylist","load","loadfile"]
778 aNewMethodName + ["QMediaPlaylist","next","movenext"]
779 aNewMethodName + ["QPainter","end","endpaint"]
780 aNewMethodName + ["QPicture","load","loadfile"]
781 aNewMethodName + ["QLineEdit","end","endtext"]
782 aNewMethodName + ["QDialog","done","donedialog"]
783 aNewMethodName + ["QTextDocument","end","enddoc"]
784 aNewMethodName + ["QTextBlock","next","nextblock"]
795 void processEvents(void)
800 RING_FUNC(ring_qApp_quit)
805 RING_FUNC(ring_qApp_exec)
810 RING_FUNC(ring_qApp_processEvents)
812 qApp->processEvents();
822 bool blockSignals(bool block)
823 QObjectList children(void)
824 void dumpObjectInfo(void)
825 void dumpObjectTree(void)
826 bool inherits(const char *className)
827 void installEventFilter(QObject *filterObj)
828 bool isWidgetType(void)
829 void killTimer(int id)
830 void moveToThread(QThread *targetThread)
831 QString objectName(void)
832 QObject *parent(void)
833 QVariant property(const char *name)
834 void removeEventFilter(QObject *obj)
835 void setObjectName(QString)
836 void setParent(QObject *parent)
837 bool setProperty(const char *name, QVariant)
838 bool signalsBlocked(void)
839 int startTimer(int interval)
840 QThread *thread(void)
841 void deleteLater(void)
849 bool acceptDrops(void)
850 QString accessibleDescription(void)
851 QString accessibleName(void)
852 void activateWindow(void)
853 void addAction(QAction *action)
854 void adjustSize(void)
855 bool autoFillBackground(void)
856 int backgroundRole(void)
858 QWidget *childAt(int x, int y)
859 QRect childrenRect(void)
860 QRegion childrenRegion(void)
861 void clearFocus(void)
863 QMargins contentsMargins(void)
864 QRect contentsRect(void)
865 int contextMenuPolicy(void)
867 int effectiveWinId(void)
868 void ensurePolished(void)
869 int focusPolicy(void)
870 QWidget *focusProxy(void)
871 QWidget *focusWidget(void)
873 QFontInfo fontInfo(void)
874 QFontMetrics fontMetrics(void)
875 int foregroundRole(void)
876 QRect frameGeometry(void)
877 QSize frameSize(void)
879 void getContentsMargins(int *left, int *top, int *right, int *bottom)
880 void grabGesture(int gesture, int flags)
881 void grabKeyboard(void)
883 int grabShortcut(QKeySequence , int context)
884 QGraphicsEffect *graphicsEffect(void)
885 QGraphicsProxyWidget *graphicsProxyWidget(void)
887 bool hasMouseTracking(void)
889 int heightForWidth(int w)
890 int inputMethodHints(void)
891 QVariant inputMethodQuery(int query)
892 void insertAction(QAction *before, QAction *action)
893 bool isActiveWindow(void)
894 bool isAncestorOf(QWidget *child)
896 bool isEnabledTo(QWidget *ancestor)
897 bool isFullScreen(void)
899 bool isMaximized(void)
900 bool isMinimized(void)
903 bool isVisibleTo(QWidget *ancestor)
905 bool isWindowModified(void)
906 QLayout *layout(void)
907 int layoutDirection(void)
909 QPoint mapFrom(QWidget *parent, QPoint)
910 QPoint mapFromGlobal(QPoint)
911 QPoint mapFromParent(QPoint)
912 QPoint mapTo(QWidget *parent, QPoint)
913 QPoint mapToGlobal(QPoint pos)
914 QPoint mapToParent(QPoint pos)
916 int maximumHeight(void)
917 QSize maximumSize(void)
918 int maximumWidth(void)
919 int minimumHeight(void)
920 QSize minimumSize(void)
921 int minimumWidth(void)
922 void move(int x, int y)
923 QWidget *nativeParentWidget(void)
924 QWidget *nextInFocusChain(void)
925 QRect normalGeometry(void)
926 void overrideWindowFlags(int flags)
927 QPalette palette(void)
928 QWidget *parentWidget(void)
930 QWidget *previousInFocusChain(void)
932 void releaseKeyboard(void)
933 void releaseMouse(void)
934 void releaseShortcut(int id)
935 void removeAction(QAction *action)
936 void render(QPaintDevice *target, QPoint,QRegion, int)
937 void repaint(int x, int y, int w, int h)
938 void resize(int w, int h)
939 bool restoreGeometry(QByteArray)
940 QByteArray saveGeometry(void)
941 void scroll(int dx, int dy)
942 void setAcceptDrops(bool on)
943 void setAccessibleDescription(QString)
944 void setAccessibleName(QString)
945 void setAttribute(int attribute, bool on)
946 void setAutoFillBackground(bool enabled)
947 void setBackgroundRole(int role)
948 void setBaseSize(int basew, int baseh)
949 void setContentsMargins(int left, int top, int right, int bottom)
950 void setContextMenuPolicy(int policy)
951 void setCursor(QCursor)
952 void setFixedHeight(int h)
953 void setFixedSize(int w, int h)
954 void setFixedWidth(int w)
955 void setFocus(int reason)
956 void setFocusPolicy(int policy)
957 void setFocusProxy(QWidget *w)
959 void setForegroundRole(int role)
960 void setGeometry(int x, int y, int w, int h)
961 void setGraphicsEffect(QGraphicsEffect *effect)
962 void setInputMethodHints(int hints)
963 void setLayout(QLayout *layout)
964 void setLayoutDirection(int direction)
965 void setLocale(QLocale)
966 void setMask(QBitmap)
967 void setMaximumHeight(int maxh)
968 void setMaximumSize(int maxw, int maxh)
969 void setMaximumWidth(int maxw)
970 void setMinimumHeight(int minh)
971 void setMinimumSize(int minw, int minh)
972 void setMinimumWidth(int minw)
973 void setMouseTracking(bool enable)
974 void setPalette(QPalette)
975 void setParent(QWidget *parent)
976 void setShortcutAutoRepeat(int id, bool enable)
977 void setShortcutEnabled(int id, bool enable)
978 void setSizeIncrement(int w, int h)
979 void setSizePolicy(int horizontal, int vertical)
980 void setStatusTip(QString)
981 void setStyle(QStyle *style)
982 void setToolTip(QString)
983 void setUpdatesEnabled(bool enable)
984 void setWhatsThis(QString)
985 void setWindowFilePath(QString)
986 void setWindowFlags(int type)
987 void setWindowIcon(QIcon)
988 void setWindowIconText(QString)
989 void setWindowModality(int windowModality)
990 void setWindowOpacity(double level)
991 void setWindowRole(QString)
992 void setWindowState(int windowState)
994 QSize sizeIncrement(void)
995 QSizePolicy sizePolicy(void)
996 void stackUnder(QWidget *w)
997 QString statusTip(void)
999 QString styleSheet(void)
1000 bool testAttribute(int attribute)
1001 QString toolTip(void)
1002 bool underMouse(void)
1003 void ungrabGesture(int gesture)
1004 void unsetCursor(void)
1005 void unsetLayoutDirection(void)
1006 void unsetLocale(void)
1007 void update(int x, int y, int w, int h)
1008 void updateGeometry(void)
1009 bool updatesEnabled(void)
1010 QRegion visibleRegion(void)
1011 QString whatsThis(void)
1014 QWidget *window(void)
1015 QString windowFilePath(void)
1016 int windowFlags(void)
1017 QIcon windowIcon(void)
1018 QString windowIconText(void)
1019 int windowModality(void)
1020 double windowOpacity(void)
1021 QString windowRole(void)
1022 int windowState(void)
1023 QString windowTitle(void)
1024 int windowType(void)
1031 void setDisabled(bool disable)
1032 void setEnabled(bool)
1033 void setHidden(bool hidden)
1034 void setStyleSheet(QString)
1035 void setWindowModified(bool)
1036 void setWindowTitle(QString)
1038 void showFullScreen(void)
1039 void showMaximized(void)
1040 void showMinimized(void)
1041 void showNormal(void)
1042 QWidget *find(int id)
1043 QWidget *keyboardGrabber(void)
1044 QWidget *mouseGrabber(void)
1045 void setTabOrder(QWidget *first, QWidget *second)
1054 QWidget *buddy(void)
1055 bool hasScaledContents(void)
1056 bool hasSelectedText(void)
1060 bool openExternalLinks(void)
1061 QPicture *picture(void)
1062 QPixmap *pixmap(void)
1063 QString selectedText(void)
1064 int selectionStart(void)
1065 void setAlignment(int)
1066 void setBuddy(QWidget *buddy)
1069 void setOpenExternalLinks(bool open)
1070 void setScaledContents(bool)
1071 void setSelection(int start, int length)
1072 void setTextFormat(int)
1073 void setTextInteractionFlags(int flags)
1074 void setWordWrap(bool on)
1076 int textFormat(void)
1077 int textInteractionFlags(void)
1080 void setMovie(QMovie *movie)
1081 void setNum(double num)
1082 void setPicture(QPicture)
1083 void setPixmap(QPixmap)
1084 void setText(QString)
1090 codename: GPushButton
1094 void setText(const char *)
1095 void setClickEvent(const char *)
1097 void setIconSize(QSize)
1108 void backspace(void)
1109 QCompleter *completer(void)
1110 QMenu *createStandardContextMenu(void)
1111 void cursorBackward(bool mark, int steps)
1112 void cursorForward(bool mark, int steps)
1113 int cursorMoveStyle(void)
1114 int cursorPosition(void)
1115 int cursorPositionAt(QPoint)
1116 void cursorWordBackward(bool mark)
1117 void cursorWordForward(bool mark)
1120 QString displayText(void)
1121 bool dragEnabled(void)
1124 void getTextMargins(int *left, int *top, int *right, int *bottom)
1125 bool hasAcceptableInput(void)
1127 bool hasSelectedText(void)
1128 void home(bool mark)
1129 QString inputMask(void)
1130 void insert(QString)
1131 bool isModified(void)
1132 bool isReadOnly(void)
1133 bool isRedoAvailable(void)
1134 bool isUndoAvailable(void)
1136 QString placeholderText(void)
1137 QString selectedText(void)
1138 int selectionStart(void)
1139 void setAlignment(int flag)
1140 void setCompleter(QCompleter *c)
1141 void setCursorMoveStyle(int style)
1142 void setCursorPosition(int)
1143 void setDragEnabled(bool b)
1144 void setEchoMode(int)
1146 void setInputMask(QString)
1147 void setMaxLength(int)
1148 void setModified(bool)
1149 void setPlaceholderText(QString)
1150 void setReadOnly(bool)
1151 void setSelection(int start, int length)
1152 void setTextMargins(int left, int top, int right, int bottom)
1153 void setValidator(QValidator *v)
1155 QMargins textMargins(void)
1156 QValidator *validator(void)
1163 void selectAll(void)
1164 void setText(QString)
1167 void setTextChangedEvent(const char *)
1168 void setcursorPositionChangedEvent(const char *)
1169 void seteditingFinishedEvent(const char *)
1170 void setreturnPressedEvent(const char *)
1171 void setselectionChangedEvent(const char *)
1172 void settextEditedEvent(const char *)
1174 .. note:: ソースコード全文は Ring ソースコードの配布物にあるため、
1175 この取扱説明書からは前述の設定ファイルにおける内容の大部分を割愛しています。
1179 pair: コード生成器; 静的メソッド
1184 Ring 1.8 からコード生成器は staticmethods オプションに対応しました。
1186 これにより、コード生成器はクラスでメソッドを呼び出すためのオブジェクトの準備は不要であることを検出できるようになりました。
1190 .. code-block:: none
1193 name: QStandardPaths
1199 QString displayName(QStandardPaths::StandardLocation type)
1200 QString findExecutable(QString executableName, QStringList paths))
1203 pair: コード生成器; ファイルの読み込み
1208 コード生成器は <loadfile> 命令に対応しました (Ring 1.9 以降)。
1210 .. code-block:: ring
1212 <loadfile> filename.cf
1214 これは、拡張機能設定ファイルを複数のファイルへ分割するのに便利です。
1218 ファイル : RingQt 拡張機能の qt_module_network.cf より引用
1220 .. code-block:: ring
1226 <loadfile> qabstractsocket.cf
1227 <loadfile> qnetworkproxy.cf
1228 <loadfile> qtcpsocket.cf
1229 <loadfile> qtcpserver.cf
1230 <loadfile> qhostaddress.cf
1231 <loadfile> qhostinfo.cf
1232 <loadfile> qnetworkrequest.cf
1233 <loadfile> qnetworkaccessmanager.cf
1234 <loadfile> qnetworkreply.cf
1237 pair: コード生成器; マネージドクラス
1242 コード生成器は、クラス定義時の <managed> オプションに対応しました (Ring 1.9 以降)。
1244 このオプションにより、生成器は C ポインタを返すために RING_API_RETMANAGEDCPOINTER() を使用します。
1246 これにより、ガベージコレクターは C ポインタを管理対象にします。
1250 .. code-block:: ring
1254 para: QString, int, int, bool
1260 pair: コード生成器; 設定ファイルの用例
1267 * RingAllegro : https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/allegro.cf
1268 * RingQt : https://github.com/ring-lang/ring/blob/master/extensions/ringqt/classes/qt.cf
1269 * RingLibSDL : https://github.com/ring-lang/ring/blob/master/extensions/ringsdl/libsdl.cf
1271 設定ファイルの変更後に、必ずコードの生成をしてください。
1274 * RingAllegro : https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/gencode.bat
1275 * RingQt : https://github.com/ring-lang/ring/blob/master/extensions/ringqt/gencode.bat
1276 * RingLibSDL : https://github.com/ring-lang/ring/blob/master/extensions/ringsdl/gencode.bat
1278 コード生成後にライブラリのビルドを必ずしてください。この用例から学ぶことができます。
1280 * RingAllegro : https://github.com/ring-lang/ring/blob/master/extensions/ringallegro/buildvc.bat
1281 * RingQt : https://github.com/ring-lang/ring/blob/master/extensions/ringqt/buildmingw32.bat
1282 * RingLibSDL : https://github.com/ring-lang/ring/blob/master/extensions/ringsdl/buildvc.bat