Table of Contents
|
Obj->setSourceModel( $(QAbstractItemModel*) );
}
xmlListPtr l=$[xmlListCreate];
int num=100;
xmlListPushBack(l,&num);
return l;
}
QWidgetAction* Obj = new QWidgetAction($(QWidget*)); Obj->setDefaultWidget($(QWidget*)); return Obj;}
<kind> /* Kind of the specialized type. Select it from the following list: normal common_param common_retval env common_env */ </kind> <data_type> /* Name of the corresponding real data type, one per line. You can specify several data types if kind is 'common_param' or 'common_retval', one per line. This section is not used if kind is 'env' or 'common_env' */ </data_type> <value> /* Value for initialization (true, 1.0, "string", ...) */ </value> <pre_condition> /* Precondition on associated function parameter. Example: $0!=NULL */ </pre_condition> <post_condition> /* Postcondition on associated function return value or parameter. Example: $0!=NULL && $obj.style() == DotLine */ </post_condition> <init_code> /* Code that should be invoked before function call. Example: $0->start(); */ </init_code> <final_code> /* Code that should be invoked after function call. Example: $0->end(); */ </final_code> <global_code> /* Declarations of auxiliary functions and global variables, header includes */ </global_code> <decl_code> /* Code that will be pasted instead of parameter automatic declaration. Example: char \$0[16]; */ </decl_code> <associating> <interfaces> /* List of interfaces (mangled/symbol names in C++) that will be associated with the specialized type, one per line */ </interfaces> <except> /* List of interfaces (mangled/symbol names in C++) that will not be associated with the specialized type, one per line. This section is used if kind is 'common_env', 'common_param' or 'common_return' */ </except> <links> /* Associations with the return value, parameters or/and object, one per line: param1 param2 ... object retval */ </links> <param_name> /* Associations with the parameters by name, one per line: param_name1 param_name2 param_name3 ... */ </param_name> </associating> <associating> /* Other associations */ </associating> <name> /* Name of the specialized type */ </name> <libs> /* External shared objects, one per line. If spectype contains call of the functions from some external shared objects then these objects should be listed here. Corresponding external header files should be included in global_code */ </libs></spec_type>
<collection> <spec_type> /* Specialized Type №1 */ </spec_type> <spec_type> /* Specialized Type №2 */ </spec_type> ... </collection> <collection> /* Other Collection */ </collection>
api-sanity-checker -specialized-types SPECTYPES.xml -gen -build -run
api-sanity-checker -test-data DIR -specialized-types SPECTYPES.xml -gen -build -run
For accessing test data files in the attributes of specialized types you should use TEST_DATA_PATH("file")
construction. Test generator will copy specified file to the local "testdata/" directory and replace TEST_DATA_PATH("file")
with the "testdata/file"
in the generated code.
QSound* create_QSound()
{
QSound* Obj=new QSound(TEST_DATA_PATH("SoundFile.wav"));
Obj->setLoops(5);
return Obj;
}
<spec_type> <kind> common_env </kind> <init_code> g_type_init(); </init_code> </spec_type> <spec_type> <kind> common_param </kind> <data_type> GObject* </data_type> <value> g_object_new (G_TYPE_OBJECT, NULL) </value> <global_code> #include <glib.h> </global_code> </spec_type>
<spec_type> <kind> common_param </kind> <data_type> xmlListPtr </data_type> <value> create_filled_list() </value> <constraint> $0!=NULL </constraint> <global_code> xmlListPtr create_filled_list() { xmlListPtr l = $[xmlListCreate]; int num = 100; xmlListPushBack(l, &num); return l; } </global_code> </spec_type>
<spec_type> <kind> normal </kind> <data_type> xmlListPtr </data_type> <value> create_filled_list() </value> <global_code> xmlListPtr create_filled_list() { xmlListPtr l = $[xmlListCreate]; int num = 100; xmlListPushBack(l, &num); return l; } </global_code> <associating> <interfaces> xmlListAppend </interfaces> <links> param1 </links> </associating> </spec_type>
<spec_type> <kind> common_env </kind> <global_code> #include<QApplication> #include<QTimer> </global_code> <init_code> #ifdef Q_WS_X11 bool useGUI = getenv( "DISPLAY" ) != 0; #else bool useGUI = TRUE; #endif QApplication* app = new QApplication(argc, argv, useGUI); </init_code> <final_code> QTimer::singleShot(100, app, SLOT(quit())); app->exec(); </final_code> </spec_type>
<spec_type> <kind> common_env </kind> <init_code> gtk_init(&argc, &argv); </init_code> <final_code> gtk_timeout_add(100, &main_loop_quit, NULL); gtk_main(); </final_code> <global_code> #include <gtk.h> gboolean main_loop_quit(gpointer data) { gtk_main_quit(); return FALSE; } </global_code> <associating> <except> gtk_init gtk_init_check gtk_parse_args gdk_init gdk_init_check gdk_parse_args gtk_test_init </except> </associating> </spec_type>
<spec_type> <kind> common_param </kind> <data_type> xmlTextReaderPtr </data_type> <value> create_reader() </value> <global_code> xmlTextReaderPtr create_reader(int n) { xmlTextReaderPtr reader = xmlReaderForFile(TEST_DATA_PATH("file.xml"), NULL, 0); int i; for(i=0; i<n; i+=1) { xmlTextReaderRead(reader); } return reader; } </global_code> </spec_type>
<spec_type> <kind> normal </kind> <data_type> void* </data_type> <constraint> $0!=NULL </constraint> <associating> <interfaces> xmlLinkGetData </interfaces> <links> retval </links> </associating> </spec_type>