Unified · Split
| @@ -576,12 +576,12 @@ Chuck_DL_MainThreadHook * CK_DLL_CALL ck_create_main_thread_hook( Chuck_DL_Query · 575 unmodified lines | |||
| 576 | //----------------------------------------------------------------------------- | 576 | //----------------------------------------------------------------------------- |
| 577 | t_CKBOOL CK_DLL_CALL ck_doc_class( Chuck_DL_Query * query, const char * doc ) | 577 | t_CKBOOL CK_DLL_CALL ck_doc_class( Chuck_DL_Query * query, const char * doc ) |
| 578 | { | 578 | { |
| 579 | #ifdef CK_DOC // disable unless CK_DOC | 579 | // #ifdef CK_DOC // disable unless CK_DOC |
| 580 | if(query->curr_class) | 580 | if(query->curr_class) |
| 581 | query->curr_class->doc = doc; | 581 | query->curr_class->doc = doc; |
| 582 | else | 582 | else |
| 583 | return FALSE; | 583 | return FALSE; |
| 584 | #endif // CK_DOC | 584 | // #endif // CK_DOC |
| 585 | 585 | ||
| 586 | return TRUE; | 586 | return TRUE; |
| 587 | } | 587 | } |
| @@ -592,12 +592,12 @@ t_CKBOOL CK_DLL_CALL ck_doc_class( Chuck_DL_Query * query, const char * doc ) · 4 unmodified lines | |||
| 592 | //----------------------------------------------------------------------------- | 592 | //----------------------------------------------------------------------------- |
| 593 | t_CKBOOL CK_DLL_CALL ck_add_example( Chuck_DL_Query * query, const char * ex ) | 593 | t_CKBOOL CK_DLL_CALL ck_add_example( Chuck_DL_Query * query, const char * ex ) |
| 594 | { | 594 | { |
| 595 | #ifdef CK_DOC // disable unless CK_DOC | 595 | // #ifdef CK_DOC // disable unless CK_DOC |
| 596 | if(query->curr_class) | 596 | if(query->curr_class) |
| 597 | query->curr_class->examples.push_back(ex); | 597 | query->curr_class->examples.push_back(ex); |
| 598 | else | 598 | else |
| 599 | return FALSE; | 599 | return FALSE; |
| 600 | #endif // CK_DOC | 600 | // #endif // CK_DOC |
| 601 | 601 | ||
| 602 | return TRUE; | 602 | return TRUE; |
| 603 | } | 603 | } |
| @@ -605,12 +605,12 @@ t_CKBOOL CK_DLL_CALL ck_add_example( Chuck_DL_Query * query, const char * ex ) · 1 unmodified line | |||
| 605 | // set current function documentation | 605 | // set current function documentation |
| 606 | t_CKBOOL CK_DLL_CALL ck_doc_func( Chuck_DL_Query * query, const char * doc ) | 606 | t_CKBOOL CK_DLL_CALL ck_doc_func( Chuck_DL_Query * query, const char * doc ) |
| 607 | { | 607 | { |
| 608 | #ifdef CK_DOC // disable unless CK_DOC | 608 | // #ifdef CK_DOC // disable unless CK_DOC |
| 609 | if(query->curr_func) | 609 | if(query->curr_func) |
| 610 | query->curr_func->doc = doc; | 610 | query->curr_func->doc = doc; |
| 611 | else | 611 | else |
| 612 | return FALSE; | 612 | return FALSE; |
| 613 | #endif // CK_DOC | 613 | // #endif // CK_DOC |
| 614 | 614 | ||
| 615 | return TRUE; | 615 | return TRUE; |
| 616 | } | 616 | } |
| @@ -618,12 +618,12 @@ t_CKBOOL CK_DLL_CALL ck_doc_func( Chuck_DL_Query * query, const char * doc ) · 1 unmodified line | |||
| 618 | // set last mvar documentation | 618 | // set last mvar documentation |
| 619 | t_CKBOOL CK_DLL_CALL ck_doc_var( Chuck_DL_Query * query, const char * doc ) | 619 | t_CKBOOL CK_DLL_CALL ck_doc_var( Chuck_DL_Query * query, const char * doc ) |
| 620 | { | 620 | { |
| 621 | #ifdef CK_DOC // disable unless CK_DOC | 621 | // #ifdef CK_DOC // disable unless CK_DOC |
| 622 | if(query->last_var) | 622 | if(query->last_var) |
| 623 | query->last_var->doc = doc; | 623 | query->last_var->doc = doc; |
| 624 | else | 624 | else |
| 625 | return FALSE; | 625 | return FALSE; |
| 626 | #endif // CK_DOC | 626 | // #endif // CK_DOC |
| 627 | 627 | ||
| 628 | return TRUE; | 628 | return TRUE; |
| 629 | } | 629 | } |
| @@ -674,37 +674,36 @@ public: · 673 unmodified lines | |||
| 674 | struct ObjectApi | 674 | struct ObjectApi |
| 675 | { | 675 | { |
| 676 | ObjectApi(); | 676 | ObjectApi(); |
| 677 | |||
| 678 | private: | 677 | private: |
| 678 | // function pointer get_type() | ||
| 679 | Type (* const get_type)( CK_DL_API, Chuck_VM_Shred *, std::string &name ); | 679 | Type (* const get_type)( CK_DL_API, Chuck_VM_Shred *, std::string &name ); |
| 680 | 680 | // function pointer create() | |
| 681 | Object (* const create)( CK_DL_API, Chuck_VM_Shred *, Type type ); | 681 | Object (* const create)( CK_DL_API, Chuck_VM_Shred *, Type type ); |
| 682 | 682 | // function pointer create_string() | |
| 683 | String (* const create_string)( CK_DL_API, Chuck_VM_Shred *, std::string &value ); | 683 | String (* const create_string)( CK_DL_API, Chuck_VM_Shred *, std::string &value ); |
| 684 | 684 | // function pointers for get_mvar_*() | |
| 685 | t_CKBOOL (* const get_mvar_int)( CK_DL_API, Object object, std::string &name, t_CKINT &value ); | 685 | t_CKBOOL (* const get_mvar_int)( CK_DL_API, Object object, std::string &name, t_CKINT &value ); |
| 686 | t_CKBOOL (* const get_mvar_float)( CK_DL_API, Object object, std::string &name, t_CKFLOAT &value ); | 686 | t_CKBOOL (* const get_mvar_float)( CK_DL_API, Object object, std::string &name, t_CKFLOAT &value ); |
| 687 | t_CKBOOL (* const get_mvar_dur)( CK_DL_API, Object object, std::string &name, t_CKDUR &value ); | 687 | t_CKBOOL (* const get_mvar_dur)( CK_DL_API, Object object, std::string &name, t_CKDUR &value ); |
| 688 | t_CKBOOL (* const get_mvar_time)( CK_DL_API, Object object, std::string &name, t_CKTIME &value ); | 688 | t_CKBOOL (* const get_mvar_time)( CK_DL_API, Object object, std::string &name, t_CKTIME &value ); |
| 689 | t_CKBOOL (* const get_mvar_string)( CK_DL_API, Object object, std::string &name, String &value ); | 689 | t_CKBOOL (* const get_mvar_string)( CK_DL_API, Object object, std::string &name, String &value ); |
| 690 | t_CKBOOL (* const get_mvar_object)( CK_DL_API, Object object, std::string &name, Object &value ); | 690 | t_CKBOOL (* const get_mvar_object)( CK_DL_API, Object object, std::string &name, Object &value ); |
| 691 | 691 | // function pointer for set_string() | |
| 692 | t_CKBOOL (* const set_string)( CK_DL_API, String string, std::string &value ); | 692 | t_CKBOOL (* const set_string)( CK_DL_API, String string, std::string &value ); |
| 693 | |||
| 694 | } * const object; | 693 | } * const object; |
| 695 | 694 | ||
| 696 | Api() : | 695 | Api() : |
| 697 | vm(new VMApi), | 696 | vm(new VMApi), |
| 698 | object(new ObjectApi) | 697 | object(new ObjectApi) |
| 699 | {} | 698 | { } |
| 700 | 699 | ||
| 701 | private: | 700 | private: |
| 702 | Api(Api &a) : | 701 | Api( Api & a ) : |
| 703 | vm(a.vm), | 702 | vm(a.vm), |
| 704 | object(a.object) | 703 | object(a.object) |
| 705 | { assert(0); }; | 704 | { assert(0); }; |
| 706 | 705 | ||
| 707 | Api &operator=(Api &a) { assert(0); return a; } | 706 | Api & operator=( Api & a ) { assert(0); return a; } |
| 708 | }; | 707 | }; |
| 709 | } | 708 | } |
| 710 | 709 | ||
| @@ -399,11 +399,11 @@ t_CKBOOL init_class_event( Chuck_Env * env, Chuck_Type * type ) · 398 unmodified lines | |||
| 399 | func->doc = "signal all shreds that are waiting on this event."; | 399 | func->doc = "signal all shreds that are waiting on this event."; |
| 400 | if( !type_engine_import_mfun( env, func ) ) goto error; | 400 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 401 | 401 | ||
| 402 | // add wait() | 402 | // add wait() | commented out 1.4.0.2 (ge) -- it doesn't DO anything!!! |
| 403 | func = make_new_mfun( "void", "wait", event_wait ); | 403 | // func = make_new_mfun( "void", "wait", event_wait ); |
| 404 | func->add_arg( "Shred", "me" ); | 404 | // func->add_arg( "Shred", "me" ); |
| 405 | func->doc = "(currently unsupported)"; | 405 | // func->doc = "(currently unsupported; use Event => now to wait on event)"; |
| 406 | if( !type_engine_import_mfun( env, func ) ) goto error; | 406 | // if( !type_engine_import_mfun( env, func ) ) goto error; |
| 407 | 407 | ||
| 408 | // add can_wait() | 408 | // add can_wait() |
| 409 | func = make_new_mfun( "int", "can_wait", event_can_wait ); | 409 | func = make_new_mfun( "int", "can_wait", event_can_wait ); |
| @@ -954,7 +954,7 @@ t_CKBOOL init_class_array( Chuck_Env * env, Chuck_Type * type ) · 544 unmodified lines | |||
| 954 | // --------- | 954 | // --------- |
| 955 | // add cap() | 955 | // add cap() |
| 956 | func = make_new_mfun( "int", "cap", array_get_capacity_hack ); | 956 | func = make_new_mfun( "int", "cap", array_get_capacity_hack ); |
| 957 | func->doc = "for historical/compatibilty reasons, this is the same as .size(); it is recommended to explicitly use .size() or .capacity()."; | 957 | func->doc = "(deprecated) For historical/compatibilty reasons, .cap() is always equal to .size(); instead of using .cap(), it is recommended to explicitly use .size() or .capacity()."; |
| 958 | if( !type_engine_import_mfun( env, func ) ) goto error; | 958 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 959 | 959 | ||
| 960 | // add capacity() // 1.4.0.2 | 960 | // add capacity() // 1.4.0.2 |
| @@ -37,6 +37,7 @@ · 36 unmodified lines | |||
| 37 | #include "chuck_errmsg.h" | 37 | #include "chuck_errmsg.h" |
| 38 | #include "chuck_lang.h" | 38 | #include "chuck_lang.h" |
| 39 | #include "chuck_io.h" | 39 | #include "chuck_io.h" |
| 40 | #include "chuck_symbol.h" | ||
| 40 | #include "util_string.h" | 41 | #include "util_string.h" |
| 41 | #include "ugen_xxx.h" | 42 | #include "ugen_xxx.h" |
| 42 | 43 | ||
| @@ -6649,19 +6650,105 @@ const char * Chuck_Type::c_name() · 6606 unmodified lines | |||
| 6649 | 6650 | ||
| 6650 | //----------------------------------------------------------------------------- | 6651 | //----------------------------------------------------------------------------- |
| 6651 | // name: apropos() | 6652 | // name: apropos() |
| 6652 | // desc: dump info to string | 6653 | // desc: dump info to string; added 1.4.0.2 (ge) |
| 6654 | // portions of this adapted from ckdoc -- thanks be to Spencer Salazar | ||
| 6653 | //----------------------------------------------------------------------------- | 6655 | //----------------------------------------------------------------------------- |
| 6654 | void Chuck_Type::apropos( std::string & output ) | 6656 | void Chuck_Type::apropos( std::string & output ) |
| 6655 | { | 6657 | { |
| 6656 | // reset | 6658 | // reset |
| 6657 | output = ""; | 6659 | output = ""; |
| 6660 | // line prefix | ||
| 6661 | string PREFIX = ""; // [chuck]: "; | ||
| 6662 | |||
| 6663 | //------------------------------------------------------------------------- | ||
| 6664 | // top level info: name, inheritane, description | ||
| 6665 | //------------------------------------------------------------------------- | ||
| 6666 | string outputTop; | ||
| 6667 | // generate string | ||
| 6668 | apropos_top( outputTop, PREFIX ); | ||
| 6669 | |||
| 6670 | //------------------------------------------------------------------------- | ||
| 6671 | // functions | ||
| 6672 | //------------------------------------------------------------------------- | ||
| 6673 | string outputFuncs; | ||
| 6674 | // generate string | ||
| 6675 | apropos_funcs( outputFuncs, PREFIX, TRUE ); | ||
| 6676 | |||
| 6677 | //------------------------------------------------------------------------- | ||
| 6678 | // variables | ||
| 6679 | //------------------------------------------------------------------------- | ||
| 6680 | string outputVars; | ||
| 6681 | // generate string | ||
| 6682 | // apropos_vars( outputVars, PREFIX, TRUE ); | ||
| 6683 | |||
| 6684 | //------------------------------------------------------------------------- | ||
| 6685 | // examples | ||
| 6686 | //------------------------------------------------------------------------- | ||
| 6687 | string outputExamples; | ||
| 6688 | // generate string | ||
| 6689 | // apropos_examples( outputExamples, PREFIX ); | ||
| 6690 | |||
| 6691 | // done | ||
| 6692 | output = outputTop + outputFuncs + outputVars + outputExamples; | ||
| 6693 | } | ||
| 6694 | |||
| 6695 | |||
| 6696 | |||
| 6697 | |||
| 6698 | //----------------------------------------------------------------------------- | ||
| 6699 | // name: apropos() | ||
| 6700 | // desc: dump info to console | ||
| 6701 | //----------------------------------------------------------------------------- | ||
| 6702 | void Chuck_Type::apropos() | ||
| 6703 | { | ||
| 6704 | // the info | ||
| 6705 | string output; | ||
| 6706 | // get it | ||
| 6707 | this->apropos( output ); | ||
| 6708 | // print it | ||
| 6709 | CK_STDCERR << output << CK_STDENDL; | ||
| 6710 | } | ||
| 6711 | |||
| 6712 | |||
| 6713 | |||
| 6714 | |||
| 6715 | // comparer | ||
| 6716 | static bool comp_func( Chuck_Func * a, Chuck_Func * b ) | ||
| 6717 | { return a->name < b->name; } | ||
| 6718 | |||
| 6719 | // comparer | ||
| 6720 | static bool comp_value( Chuck_Value * a, Chuck_Value * b ) | ||
| 6721 | { return a->name < b->name; } | ||
| 6722 | |||
| 6723 | // capitalize first character | ||
| 6724 | static string capitalize( const string & s ) | ||
| 6725 | { | ||
| 6726 | // copy | ||
| 6727 | string retval = s; | ||
| 6728 | // if not empty and first character is a lower-case letter | ||
| 6729 | if( retval.length() > 0 && retval[0] >= 'a' && retval[0] <= 'z' ) | ||
| 6730 | retval[0] -= 32; | ||
| 6731 | // done | ||
| 6732 | return retval; | ||
| 6733 | } | ||
| 6734 | |||
| 6735 | |||
| 6736 | |||
| 6737 | |||
| 6738 | //----------------------------------------------------------------------------- | ||
| 6739 | // name: apropos_top() | ||
| 6740 | // desc: dump top level info; added 1.4.0.2 (ge) | ||
| 6741 | //----------------------------------------------------------------------------- | ||
| 6742 | void Chuck_Type::apropos_top( std::string & output, const std::string & PREFIX ) | ||
| 6743 | { | ||
| 6658 | // make a string output stream | 6744 | // make a string output stream |
| 6659 | ostringstream sout; | 6745 | ostringstream sout; |
| 6660 | // type | 6746 | // type |
| 6661 | Chuck_Type * type = this; | 6747 | Chuck_Type * type = this; |
| 6662 | // line prefix | ||
| 6663 | string PREFIX = ""; // [chuck]: "; | ||
| 6664 | 6748 | ||
| 6749 | //------------------------------------------------------------------------- | ||
| 6750 | // top level info: name, inheritane, description | ||
| 6751 | //------------------------------------------------------------------------- | ||
| 6665 | // delimiter | 6752 | // delimiter |
| 6666 | sout << PREFIX; | 6753 | sout << PREFIX; |
| 6667 | for( int i = 0; i < str().length(); i++ ) sout << "-"; | 6754 | for( int i = 0; i < str().length(); i++ ) sout << "-"; |
| @@ -6672,10 +6759,13 @@ void Chuck_Type::apropos( std::string & output ) · 4 unmodified lines | |||
| 6672 | sout << PREFIX; | 6759 | sout << PREFIX; |
| 6673 | for( int i = 0; i < str().length(); i++ ) sout << "-"; | 6760 | for( int i = 0; i < str().length(); i++ ) sout << "-"; |
| 6674 | sout << endl; | 6761 | sout << endl; |
| 6762 | // description | ||
| 6763 | if( this->doc != "" ) | ||
| 6764 | sout << PREFIX << " |- " << capitalize(this->doc) << "" << endl; | ||
| 6675 | // inheritance | 6765 | // inheritance |
| 6676 | if( type->parent != NULL ) | 6766 | if( type->parent != NULL ) |
| 6677 | { | 6767 | { |
| 6678 | sout << PREFIX << " |- inherits"; | 6768 | sout << PREFIX << " |- inheritance: " << str(); |
| 6679 | while( type->parent != NULL ) | 6769 | while( type->parent != NULL ) |
| 6680 | { | 6770 | { |
| 6681 | // move up | 6771 | // move up |
| @@ -6687,37 +6777,11 @@ void Chuck_Type::apropos( std::string & output ) · 5 unmodified lines | |||
| 6687 | // set back to this | 6777 | // set back to this |
| 6688 | type = this; | 6778 | type = this; |
| 6689 | } | 6779 | } |
| 6690 | // description | 6780 | // delimiter |
| 6691 | if( this->doc != "" ) | ||
| 6692 | sout << PREFIX << " |- description: " << this->doc << "" << endl; | ||
| 6693 | |||
| 6694 | // // storage for functions in type | ||
| 6695 | // vector<Chuck_Func *> funcs; | ||
| 6696 | // // get functions from type info | ||
| 6697 | // type->parent->parent->info->get_funcs( funcs ); | ||
| 6698 | // // print functions | ||
| 6699 | // for( t_CKUINT i = 0; i < funcs.size(); i++ ) | ||
| 6700 | // { | ||
| 6701 | // // sout << funcs[i]->base_name << endl; | ||
| 6702 | // } | ||
| 6703 | |||
| 6704 | // // storage for values in type | ||
| 6705 | // vector<Chuck_Value *> values; | ||
| 6706 | // // get values from type info | ||
| 6707 | // type->parent->parent->parent->info->get_values( values ); | ||
| 6708 | // // print values | ||
| 6709 | // for( t_CKUINT i = 0; i < values.size(); i++ ) | ||
| 6710 | // { | ||
| 6711 | // CK_STDCERR << values[i]->name << CK_STDENDL; | ||
| 6712 | // } | ||
| 6713 | // | ||
| 6714 | // CK_STDCERR << funcs.size() << " " << values.size() << CK_STDENDL; | ||
| 6715 | |||
| 6716 | sout << PREFIX; | 6781 | sout << PREFIX; |
| 6717 | for( int i = 0; i < str().length(); i++ ) sout << "-"; | 6782 | for( int i = 0; i < str().length(); i++ ) sout << "-"; |
| 6718 | sout << endl; | 6783 | sout << endl; |
| 6719 | 6784 | // store | |
| 6720 | // done | ||
| 6721 | output = sout.str(); | 6785 | output = sout.str(); |
| 6722 | } | 6786 | } |
| 6723 | 6787 | ||
| @@ -6725,15 +6789,173 @@ void Chuck_Type::apropos( std::string & output ) · 1 unmodified line | |||
| 6725 | 6789 | ||
| 6726 | 6790 | ||
| 6727 | //----------------------------------------------------------------------------- | 6791 | //----------------------------------------------------------------------------- |
| 6728 | // name: apropos() | 6792 | // name: apropos_func_arg() |
| 6729 | // desc: dump info to console | 6793 | // desc: helper function for outputing function arguments |
| 6730 | //----------------------------------------------------------------------------- | 6794 | //----------------------------------------------------------------------------- |
| 6731 | void Chuck_Type::apropos() | 6795 | void apropos_func_arg( std::ostringstream & sout, a_Arg_List arg ) |
| 6732 | { | 6796 | { |
| 6733 | // the info | 6797 | // argument type |
| 6734 | string output; | 6798 | sout << arg->type->name.c_str(); |
| 6735 | // get it | 6799 | // is type an array? |
| 6736 | this->apropos( output ); | 6800 | if( arg->type->array_depth ) |
| 6737 | // print it | 6801 | { |
| 6738 | CK_STDCERR << output << CK_STDENDL; | 6802 | for( int i = 0; i < arg->type->array_depth; i++ ) |
| 6803 | sout << "[]"; | ||
| 6804 | } | ||
| 6805 | // space | ||
| 6806 | sout << " "; | ||
| 6807 | // argument name | ||
| 6808 | sout << S_name(arg->var_decl->xid); | ||
| 6809 | // print comma, if there are more arguments after this | ||
| 6810 | if( arg->next != NULL ) | ||
| 6811 | sout << ", "; | ||
| 6812 | } | ||
| 6813 | |||
| 6814 | |||
| 6815 | |||
| 6816 | |||
| 6817 | //----------------------------------------------------------------------------- | ||
| 6818 | // name: apropos_func() | ||
| 6819 | // desc: helper function for outputing function | ||
| 6820 | //----------------------------------------------------------------------------- | ||
| 6821 | void apropos_func( std::ostringstream & sout, Chuck_Func * func, const std::string & PREFIX ) | ||
| 6822 | { | ||
| 6823 | // output return type | ||
| 6824 | sout << func->def->ret_type->c_name(); | ||
| 6825 | // if return type is an array | ||
| 6826 | if( func->def->ret_type->array_depth ) | ||
| 6827 | { | ||
| 6828 | // output "[]" for each dimension of the array | ||
| 6829 | for( int i = 0; i < func->def->ret_type->array_depth; i++ ) | ||
| 6830 | sout << "[]"; | ||
| 6831 | } | ||
| 6832 | // space | ||
| 6833 | sout << " "; | ||
| 6834 | // output function name | ||
| 6835 | sout << S_name(func->def->name); | ||
| 6836 | // open paren | ||
| 6837 | sout << "("; | ||
| 6838 | // extra space, if we have args | ||
| 6839 | if( func->def->arg_list != NULL ) sout << " "; | ||
| 6840 | |||
| 6841 | // argument list | ||
| 6842 | a_Arg_List args = func->def->arg_list; | ||
| 6843 | while( args != NULL ) | ||
| 6844 | { | ||
| 6845 | // output arg | ||
| 6846 | apropos_func_arg( sout, args ); | ||
| 6847 | // move to next | ||
| 6848 | args = args->next; | ||
| 6849 | } | ||
| 6850 | |||
| 6851 | // extra space, if we are args | ||
| 6852 | if( func->def->arg_list != NULL ) sout << " "; | ||
| 6853 | |||
| 6854 | // close paren | ||
| 6855 | sout << ");" << endl; | ||
| 6856 | // output doc | ||
| 6857 | sout << PREFIX << " " << capitalize(func->doc) << endl; | ||
| 6858 | } | ||
| 6859 | |||
| 6860 | |||
| 6861 | |||
| 6862 | |||
| 6863 | //----------------------------------------------------------------------------- | ||
| 6864 | // name: apropos_funcs() | ||
| 6865 | // desc: dump info about funcs; added 1.4.0.2 (ge) | ||
| 6866 | //----------------------------------------------------------------------------- | ||
| 6867 | void Chuck_Type::apropos_funcs( std::string & output, const std::string & PREFIX, t_CKBOOL includeParents ) | ||
| 6868 | { | ||
| 6869 | // make a string output stream | ||
| 6870 | ostringstream sout; | ||
| 6871 | |||
| 6872 | // check type info | ||
| 6873 | if( this->info ) | ||
| 6874 | { | ||
| 6875 | // retrieve functions in this type | ||
| 6876 | vector<Chuck_Func *> funcs; | ||
| 6877 | this->info->get_funcs(funcs); | ||
| 6878 | // retrieve variables in this type | ||
| 6879 | vector<Chuck_Value *> vars; | ||
| 6880 | this->info->get_values(vars); | ||
| 6881 | |||
| 6882 | // member functions | ||
| 6883 | vector<Chuck_Func *> mfuncs; | ||
| 6884 | // static functions | ||
| 6885 | vector<Chuck_Func *> sfuncs; | ||
| 6886 | // member variables | ||
| 6887 | vector<Chuck_Value *> mvars; | ||
| 6888 | // static variables | ||
| 6889 | vector<Chuck_Value *> svars; | ||
| 6890 | // counter by name | ||
| 6891 | map<string, int> func_names; | ||
| 6892 | |||
| 6893 | // iterate over retrieved functions | ||
| 6894 | for( vector<Chuck_Func *>::iterator f = funcs.begin(); f != funcs.end(); f++ ) | ||
| 6895 | { | ||
| 6896 | // get pointer to chuck func | ||
| 6897 | Chuck_Func * func = *f; | ||
| 6898 | // check for NULL | ||
| 6899 | if( func == NULL ) continue; | ||
| 6900 | // see if name appeared before | ||
| 6901 | if( func_names.count(func->name) ) | ||
| 6902 | { | ||
| 6903 | // increment count associated with name | ||
| 6904 | func_names[func->name]++; | ||
| 6905 | // done for now | ||
| 6906 | continue; | ||
| 6907 | } | ||
| 6908 | |||
| 6909 | // create entry for name | ||
| 6910 | func_names[func->name] = 1; | ||
| 6911 | |||
| 6912 | // check for static declaration | ||
| 6913 | if( func->def->static_decl == ae_key_static ) { | ||
| 6914 | // append to static funcs list | ||
| 6915 | sfuncs.push_back(func); | ||
| 6916 | } else { | ||
| 6917 | // append to static funcs list | ||
| 6918 | mfuncs.push_back(func); | ||
| 6919 | } | ||
| 6920 | } | ||
| 6921 | |||
| 6922 | // sort | ||
| 6923 | sort( mfuncs.begin(), mfuncs.end(), comp_func ); | ||
| 6924 | sort( sfuncs.begin(), sfuncs.end(), comp_func ); | ||
| 6925 | |||
| 6926 | // one or more static functions? | ||
| 6927 | if( mfuncs.size() ) | ||
| 6928 | { | ||
| 6929 | // iterate over static functions | ||
| 6930 | for( vector<Chuck_Func *>::iterator f = mfuncs.begin(); f != mfuncs.end(); f++ ) | ||
| 6931 | { | ||
| 6932 | // pointer to chuck func | ||
| 6933 | Chuck_Func * func = *f; | ||
| 6934 | // print line prefix, if any | ||
| 6935 | sout << PREFIX; | ||
| 6936 | // output function content | ||
| 6937 | apropos_func( sout, func, PREFIX ); | ||
| 6938 | } | ||
| 6939 | } | ||
| 6940 | |||
| 6941 | // one or more static functions? | ||
| 6942 | if( sfuncs.size() ) | ||
| 6943 | { | ||
| 6944 | // iterate over static functions | ||
| 6945 | for( vector<Chuck_Func *>::iterator f = sfuncs.begin(); f != sfuncs.end(); f++ ) | ||
| 6946 | { | ||
| 6947 | // pointer to chuck func | ||
| 6948 | Chuck_Func * func = *f; | ||
| 6949 | // print line prefix, if any | ||
| 6950 | sout << PREFIX; | ||
| 6951 | // print static | ||
| 6952 | sout << "static "; | ||
| 6953 | // output function content | ||
| 6954 | apropos_func( sout, func, PREFIX ); | ||
| 6955 | } | ||
| 6956 | } | ||
| 6957 | } | ||
| 6958 | |||
| 6959 | // output to string | ||
| 6960 | output = sout.str(); | ||
| 6739 | } | 6961 | } |
| @@ -655,11 +655,21 @@ protected: · 654 unmodified lines | |||
| 655 | // this for str() and c_name() use only | 655 | // this for str() and c_name() use only |
| 656 | std::string ret; | 656 | std::string ret; |
| 657 | 657 | ||
| 658 | public: | 658 | public: // apropos | 1.4.0.2 (ge) |
| 659 | // dump info to string | ||
| 660 | void apropos( std::string & output ); | ||
| 661 | // dump info to console | 659 | // dump info to console |
| 662 | void apropos(); | 660 | void apropos(); |
| 661 | // dump info to string | ||
| 662 | void apropos( std::string & output ); | ||
| 663 | |||
| 664 | protected: // apropos-related helper function | ||
| 665 | // dump top level info | ||
| 666 | void apropos_top( std::string & output, const std::string & prefix ); | ||
| 667 | // dump info about functions | ||
| 668 | void apropos_funcs( std::string & output, const std::string & prefix, t_CKBOOL includeParent ); | ||
| 669 | // dump info about vars | ||
| 670 | void apropos_vars( std::string & output, const std::string & prefix, t_CKBOOL includeParent ); | ||
| 671 | // dump info about examples | ||
| 672 | void apropos_examples( std::string & output, const std::string & prefix ); | ||
| 663 | }; | 673 | }; |
| 664 | 674 | ||
| 665 | 675 | ||
| @@ -1238,7 +1238,6 @@ CK_DLL_MFUN( MidiFileIn_rewind ); · 1237 unmodified lines | |||
| 1238 | //----------------------------------------------------------------------------- | 1238 | //----------------------------------------------------------------------------- |
| 1239 | DLL_QUERY stk_query( Chuck_DL_Query * QUERY ) | 1239 | DLL_QUERY stk_query( Chuck_DL_Query * QUERY ) |
| 1240 | { | 1240 | { |
| 1241 | |||
| 1242 | Chuck_Env * env = QUERY->env(); | 1241 | Chuck_Env * env = QUERY->env(); |
| 1243 | Chuck_DL_Func * func = NULL; | 1242 | Chuck_DL_Func * func = NULL; |
| 1244 | 1243 | ||
| @@ -70,6 +70,7 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 69 unmodified lines | |||
| 70 | //! returns the shred ID | 70 | //! returns the shred ID |
| 71 | //! (see example/machine.ck) | 71 | //! (see example/machine.ck) |
| 72 | QUERY->add_sfun( QUERY, machine_add_impl, "int", "add" ); | 72 | QUERY->add_sfun( QUERY, machine_add_impl, "int", "add" ); |
| 73 | QUERY->doc_func( QUERY, "add/run a new shred from file at 'path'." ); | ||
| 73 | QUERY->add_arg( QUERY, "string", "path" ); | 74 | QUERY->add_arg( QUERY, "string", "path" ); |
| 74 | 75 | ||
| 75 | // add spork | 76 | // add spork |
| @@ -80,32 +81,37 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 4 unmodified lines | |||
| 80 | // add remove | 81 | // add remove |
| 81 | //! remove shred from VM by shred ID (returned by add/spork) | 82 | //! remove shred from VM by shred ID (returned by add/spork) |
| 82 | QUERY->add_sfun( QUERY, machine_remove_impl, "int", "remove" ); | 83 | QUERY->add_sfun( QUERY, machine_remove_impl, "int", "remove" ); |
| 84 | QUERY->doc_func( QUERY, "remove a running shred by 'id'." ); | ||
| 83 | QUERY->add_arg( QUERY, "int", "id" ); | 85 | QUERY->add_arg( QUERY, "int", "id" ); |
| 84 | 86 | ||
| 85 | // add replace | 87 | // add replace |
| 86 | //! replace shred with new shred from file | 88 | //! replace shred with new shred from file |
| 87 | //! returns shred ID , or 0 on error | 89 | //! returns shred ID , or 0 on error |
| 88 | QUERY->add_sfun( QUERY, machine_replace_impl, "int", "replace" ); | 90 | QUERY->add_sfun( QUERY, machine_replace_impl, "int", "replace" ); |
| 91 | QUERY->doc_func( QUERY, "replace running shred by 'id' with new shred at 'path'." ); | ||
| 89 | QUERY->add_arg( QUERY, "int", "id" ); | 92 | QUERY->add_arg( QUERY, "int", "id" ); |
| 90 | QUERY->add_arg( QUERY, "string", "path" ); | 93 | QUERY->add_arg( QUERY, "string", "path" ); |
| 91 | 94 | ||
| 92 | // add replace | 95 | // add crash |
| 93 | //! replace shred with new shred from file | 96 | //! explicitly crash the virtual machine |
| 94 | //! returns shred ID , or 0 on error | ||
| 95 | QUERY->add_sfun( QUERY, machine_crash_impl, "void", "crash" ); | 97 | QUERY->add_sfun( QUERY, machine_crash_impl, "void", "crash" ); |
| 98 | QUERY->doc_func( QUERY, "explicitly crash the virtual machine." ); | ||
| 96 | 99 | ||
| 97 | // add status | 100 | // add status |
| 98 | //! display current status of VM | 101 | //! display current status of VM |
| 99 | //! (see example/status.ck) | 102 | //! (see example/status.ck) |
| 100 | QUERY->add_sfun( QUERY, machine_status_impl, "int", "status" ); | 103 | QUERY->add_sfun( QUERY, machine_status_impl, "int", "status" ); |
| 101 | 104 | QUERY->doc_func( QUERY, "display current status of virtual machine." ); | |
| 105 | |||
| 102 | // add get intsize (width) | 106 | // add get intsize (width) |
| 103 | //! get the intsize in bits (e.g., 32 or 64) | 107 | //! get the intsize in bits (e.g., 32 or 64) |
| 104 | QUERY->add_sfun( QUERY, machine_intsize_impl, "int", "intsize" ); | 108 | QUERY->add_sfun( QUERY, machine_intsize_impl, "int", "intsize" ); |
| 109 | QUERY->doc_func( QUERY, "get size of int in bits (e.g., 32 or 64)." ); | ||
| 105 | 110 | ||
| 106 | // add shreds | 111 | // add shreds |
| 107 | //! get list of active shreds by id | 112 | //! get list of active shreds by id |
| 108 | QUERY->add_sfun( QUERY, machine_shreds_impl, "int[]", "shreds" ); | 113 | QUERY->add_sfun( QUERY, machine_shreds_impl, "int[]", "shreds" ); |
| 114 | QUERY->doc_func( QUERY, "get list of active shred ids." ); | ||
| 109 | 115 | ||
| 110 | // end class | 116 | // end class |
| 111 | QUERY->end_class( QUERY ); | 117 | QUERY->end_class( QUERY ); |