How to call this function?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: How to call this function?

  1. #1
    Join Date
    Dec 2010
    Posts
    644

    How to call this function?

    Code:
    Value*
    globalVars_get_cf(Value** arg_list, int count)
    {
    	// globalVars.get <global_name>
    	check_arg_count(globalVars.get, 1, count);
    	Value* glob_name = Name::intern(arg_list[0]->to_string());
    	GlobalThunk* t = (GlobalThunk*)globals->get(glob_name);
    	if (!t)
    		throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_NO_SUCH_GLOBAL), glob_name);
    	return t->eval();
    }
    Code:
    // the root MAXScript class
    class Value : public Collectable
    {
    private:
    	ScripterExport static Matrix3  s_error_matrix;
    	ScripterExport static Box2  s_error_box2;
    public:
    	#pragma warning(push)
    	#pragma warning(disable:4100)
    	ValueMetaClass* tag;		// runtime type tag; filled in by subclasses
    
    	ScripterExport virtual BOOL	is_kind_of(ValueMetaClass* c);
    	ScripterExport virtual ValueMetaClass* local_base_class(); // local base class in this class's plug-in
    	virtual Value*	eval() { check_interrupts(); return this; }
    	virtual Value*	eval_no_wrapper() { check_interrupts(); return this; }
    	ScripterExport virtual Value*  apply(Value** arglist, int count, CallContext* cc=NULL);
    	ScripterExport virtual Value*  apply_no_alloc_frame(Value** arglist, int count, CallContext* cc=NULL);
    	virtual void	export_to_scripter() { }
    
    	virtual Value*  map(node_map& m) { unimplemented(_M("map"), this) ; return this; }
    	virtual Value*	map_path(PathName* path, node_map& m) { unimplemented(_M("map_path"), this) ; return this; }
    	virtual Value*	find_first(BOOL (*test_fn)(INode* node, int level, void* arg), void* test_arg) { unimplemented(_M("find_first"), this) ; return this; }
    	virtual Value*	get_path(PathName* path) { unimplemented(_M("get"), this) ; return this; }
    
    	ScripterExport virtual void	sprin1(CharStream* stream);
    	ScripterExport virtual void	sprint(CharStream* stream);
    
    	virtual void	prin1() { sprin1(thread_local(current_stdout)); }
    	virtual void	print() { sprint(thread_local(current_stdout)); }
    	
    	/* include all the protocol declarations */
    
    #include "..\macros\define_abstract_functions.h"
    #	include "..\protocols\math.inl"
    #	include "..\protocols\vector.inl"
    #	include "..\protocols\matrix.inl"
    #	include "..\protocols\quat.inl"
    #	include "..\protocols\arrays.inl"
    #	include "..\protocols\streams.inl"
    #	include "..\protocols\strings.inl"
    #	include "..\protocols\time.inl"
    #	include "..\protocols\color.inl"
    #	include "..\protocols\node.inl"
    #	include "..\protocols\controller.inl"
    #	include "..\protocols\primitives.inl"
    #	include "..\protocols\generics.inl"
    #	include "..\protocols\bitmaps.inl"
    #	include "..\protocols\textures.inl"
    #	include "..\protocols\atmospherics.inl"
    #	// Moved to ..\maxwrapper\mxsnurbs.h into class NURBSObjectValue
    #	include "..\protocols\cameratracker.inl"
    #	include "..\protocols\bigmatrix.inl"
    #	include	"..\protocols\box.inl"
    #	include "..\protocols\physiqueblend.inl"
    #	include "..\protocols\physiquemod.inl"
    #	include	"..\protocols\biped.inl"
    #	include "..\protocols\notekey.inl"
    #	include "..\protocols\xrefs.inl"
    
    	ScripterExport virtual Class_ID get_max_class_id() { return Class_ID(0, 0); }
    	ScripterExport virtual Value* delete_vf(Value** arglist, int arg_count) { ABSTRACT_FUNCTION(_M("delete"), this, Value*); }	  
    	ScripterExport virtual Value* clearSelection_vf(Value** arglist, int arg_count) { ABSTRACT_FUNCTION(_M("clearSelection"), this, Value*); }	  
    
    #undef def_generic
    #define def_generic(fn, name) ScripterExport virtual Value* fn##_vf(Value** arglist, int arg_count);
    #	include "..\protocols\kernel.inl"
    	
    	virtual float		to_float() { ABSTRACT_CONVERTER(float, Float); }
    	virtual double		to_double() { ABSTRACT_CONVERTER(double, Double); }
    	virtual MCHAR*		to_string() { ABSTRACT_CONVERTER(MCHAR*, String); }
    	virtual MSTR		to_filename() { ABSTRACT_CONVERTER(MCHAR*, FileName); }
    	virtual int			to_int() { ABSTRACT_CONVERTER(int, Integer); }
    	virtual INT64		to_int64() { ABSTRACT_CONVERTER(INT64, Integer64); }	
    	virtual INT_PTR		to_intptr() { ABSTRACT_CONVERTER(INT_PTR, IntegerPtr); }	
    	virtual BOOL		to_bool() { ABSTRACT_CONVERTER(BOOL, Boolean); }
    	virtual BitArray&	to_bitarray() { throw ConversionError (this, _M("BitArray")); return *(BitArray*)NULL; }
    	virtual Point4		to_point4() { ABSTRACT_CONVERTER(Point4, Point4); }
    	virtual Point3		to_point3() { ABSTRACT_CONVERTER(Point3, Point3); }
    	virtual Point2		to_point2() { ABSTRACT_CONVERTER(Point2, Point2); }
    	virtual AColor		to_acolor() { throw ConversionError (this, _M("Color")); return AColor(0,0,0); }
    	virtual COLORREF	to_colorref() { throw ConversionError (this, _M("Color")); return RGB(0,0,0); }
    	virtual INode*		to_node() { ABSTRACT_CONVERTER(INode*, <node>); }
    	virtual Ray			to_ray() { throw ConversionError (this, _M("Ray")); return Ray(); }
    	virtual Interval	to_interval() { throw ConversionError (this, _M("Interval")); return Interval();  }
    	virtual Quat		to_quat() { throw ConversionError (this, _M("Quaternion")); return Quat();  }
    	virtual AngAxis		to_angaxis() { throw ConversionError (this, _M("AngleAxis")); return AngAxis();  }
    	virtual Matrix3&	to_matrix3() { throw ConversionError (this, _M("Matrix")); return s_error_matrix;  }
    	virtual float*		to_eulerangles() { ABSTRACT_CONVERTER(float*, Float); }
    	virtual Mtl*		to_mtl() { ABSTRACT_CONVERTER(Mtl*, Material); }
    	virtual Texmap*		to_texmap() { ABSTRACT_CONVERTER(Texmap*, TextureMap); }
    	virtual MtlBase*	to_mtlbase() { ABSTRACT_CONVERTER(MtlBase*, MtlBase); }
    	virtual Modifier*	to_modifier() { ABSTRACT_CONVERTER(Modifier*, Modifier); }
    	virtual TimeValue	to_timevalue() { ABSTRACT_CONVERTER(TimeValue, Time); }
    	virtual Control*	to_controller() { ABSTRACT_CONVERTER(Control*, Controller); }
    	virtual Atmospheric* to_atmospheric() { ABSTRACT_CONVERTER(Atmospheric*, Atmospheric); }
    	virtual Effect*		to_effect() { ABSTRACT_CONVERTER(Effect*, Effect); }						// RK: Added this
    	virtual IMultiPassCameraEffect*	to_mpassCamEffect() { ABSTRACT_CONVERTER(IMultiPassCameraEffect*, Effect); }	// LAM: Added this
    	virtual ShadowType*	to_shadowtype() { ABSTRACT_CONVERTER(ShadowType*, ShadowType); }			// RK: Added this
    	virtual FilterKernel*	to_filter() { ABSTRACT_CONVERTER(FilterKernel*, FilterKernel); }		// RK: Added this
    	virtual INode*		to_rootnode() { ABSTRACT_CONVERTER(INode*, <root>); }						// RK: Added this
    	virtual ITrackViewNode* to_trackviewnode() { ABSTRACT_CONVERTER(ITrackViewNode*, TrackViewNode); }
    	virtual NURBSIndependentPoint* to_nurbsindependentpoint() { throw ConversionError (this, _M("NURBSIndependentPoint")); return (NURBSIndependentPoint*)0;  }
    	virtual NURBSPoint*	to_nurbspoint() { throw ConversionError (this, _M("NURBSPoint")); return (NURBSPoint*)0;  }
    	virtual NURBSObject* to_nurbsobject() { throw ConversionError (this, _M("NURBSObject")); return (NURBSObject*)0;  }
    	virtual NURBSControlVertex* to_nurbscontrolvertex() { throw ConversionError (this, _M("NURBSControlVertex")); return (NURBSControlVertex*)0;  }
    	virtual NURBSCurve* to_nurbscurve() { throw ConversionError (this, _M("NURBSCurve")); return (NURBSCurve*)0;  }
    	virtual NURBSCVCurve* to_nurbscvcurve() { throw ConversionError (this, _M("NURBSCVCurve")); return (NURBSCVCurve*)0;  }
    	virtual NURBSSurface* to_nurbssurface() { throw ConversionError (this, _M("NURBSSurface")); return (NURBSSurface*)0;  }
    	virtual NURBSTexturePoint* to_nurbstexturepoint() { throw ConversionError (this, _M("NURBSTexturePoint")); return (NURBSTexturePoint*)0;  }
    	virtual NURBSSet*	to_nurbsset() { throw ConversionError (this, _M("NURBSSet")); return (NURBSSet*)0;  }
    	virtual ReferenceTarget* to_reftarg() { ABSTRACT_CONVERTER(ReferenceTarget*, MaxObject); }
    	virtual Mesh*		to_mesh() { ABSTRACT_CONVERTER(Mesh*, Mesh); }
    	virtual Thunk*		to_thunk() { ABSTRACT_CONVERTER(Thunk*, &-reference); }
    	virtual void		to_fpvalue(FPValue& v) { throw ConversionError (this, _M("FPValue")); }
    
    	virtual Renderer*	to_renderer() { ABSTRACT_CONVERTER(Renderer*, Renderer); }	// LAM: Added this 9/15/01
    
    	virtual Box2&	to_box2() { throw ConversionError (this, _M("Box2")); return s_error_box2;  }
    	virtual NURBSTextureSurface* to_nurbstexturesurface() { throw ConversionError (this, _M("NURBSTextureSurface")); return (NURBSTextureSurface*)0;  }
    	virtual NURBSDisplay* to_nurbsdisplay() { throw ConversionError (this, _M("NURBSDisplay")); return (NURBSDisplay*)0;  }
    	virtual TessApprox*	 to_tessapprox() { throw ConversionError (this, _M("TessApprox")); return (TessApprox*)0;  }
    
    	virtual Value*	widen_to(Value* arg, Value** arg_list) { ABSTRACT_WIDENER(arg); }
    	virtual BOOL	comparable(Value* arg) { return (tag == arg->tag); }
    	virtual BOOL	is_const() { return FALSE; }
    	// LAM - 7/8/03 - defect 504956 - following identifies classes that derive from MAXWrapper. Only other implementation is in MAXWrapper
    	// used by garbage collector to prevent collection of MAXWrapper-derived values while doing light collection
    	virtual BOOL	derives_from_MAXWrapper()  { return FALSE; } 
    
    	ScripterExport virtual Value*	get_property(Value** arg_list, int count);
    	ScripterExport virtual Value*	set_property(Value** arg_list, int count);
    	ScripterExport		   Value*	_get_property(Value* prop);
    	ScripterExport virtual Value*	_set_property(Value* prop, Value* val);
    	virtual Value*	get_container_property(Value* prop, Value* cur_prop) { if (!dontThrowAccessorError) throw AccessorError (cur_prop, prop); return NULL; }
    	virtual Value*	set_container_property(Value* prop, Value* val, Value* cur_prop) { throw AccessorError (cur_prop, prop); return NULL;}
    
    	// polymorphic default type predicates - abstracted over by is_x(v) macros as needed
    	virtual BOOL	_is_collection() { return FALSE; }
    	virtual BOOL	_is_charstream() { return FALSE; }
    	virtual BOOL	_is_rolloutcontrol() { return FALSE; }
    	virtual BOOL	_is_rolloutthunk() { return FALSE; }
    	virtual BOOL	_is_function()	 { return FALSE; }
    	virtual BOOL	_is_selection()	 { return FALSE; }
    	virtual BOOL	_is_thunk()		{ return FALSE; }
    	virtual BOOL	_is_indirect_thunk() { return FALSE; }
    
    	// yield selection set iterator if you can
    	virtual SelectionIterator* selection_iterator() { throw RuntimeError (_M("Operation requires a selection (Array or BitArray)")); return NULL; }
    
    	// scene persistence functions
    	ScripterExport virtual IOResult Save(ISave* isave);
    	// the Load fn is a static method on loadbale classes, see SceneIO.cpp & .h and each loadable class
    
    	// called during MAX exit to have all MAXScript-side refs dropped (main implementation in MAXWrapper)
    	virtual void drop_MAX_refs() { }
    
    	// access ID'd FPInterface if supported
    	virtual BaseInterface* GetInterface(Interface_ID id) { return NULL; }
    
    
    	// stack allocation routines
    	ScripterExport Value* make_heap_permanent();
    	ScripterExport Value* make_heap_static() { Value* v = make_heap_permanent(); v->flags |= GC_STATIC; return v; }
    
    	ScripterExport Value* get_heap_ptr() { if (!has_heap_copy()) return migrate_to_heap(); return is_on_stack() ? get_stack_heap_ptr() : this; } 
    	ScripterExport Value* get_stack_heap_ptr() { return (Value*)next; }
    	ScripterExport Value* migrate_to_heap();
    	ScripterExport Value* get_live_ptr() { return is_on_stack() && has_heap_copy() ? get_stack_heap_ptr() : this; } 
    	#pragma warning(pop)
    };
    I want to create a MCHAR* type which is believed to be in strings.inl., I don't show the strings.inl file for now which might bring into larger confusion.

    Will this do
    MCHAR* name = globalVars.get("Name");
    Thanks in advance
    Jack
    Last edited by lucky6969b; July 25th, 2013 at 08:00 AM.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,444

    Re: How to call this function?

    Quote Originally Posted by lucky6969b View Post
    Will this do
    MCHAR* name = globalVars.get("Name");
    Thanks in advance
    Jack
    Isn't there documentation that comes with this code you're using?
    I want to create a MCHAR* type which is believed to be in strings.inl.,
    Whatever an MCHAR is...
    Code:
    MCHAR mc;
    MCHAR* pMc = &mc;
    If you're asking us to figure out this class, again, where are the docs?

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Dec 2010
    Posts
    644

  4. #4
    Join Date
    Apr 1999
    Posts
    27,444

    Re: How to call this function?

    So what do those docs say? You really can't be expecting someone to use their time to read all of that information.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; July 25th, 2013 at 03:37 PM.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,517

    Re: How to call this function?

    Did you read it?
    Victor Nijegorodov

  6. #6
    Join Date
    Apr 1999
    Posts
    27,444

    Re: How to call this function?

    This is an API, where it takes a programmer time to familiarize themselves with it. This isn't just a C++ code or syntax issue, where you can just ask a simple question and get a simple answer.

    Do you think that an MCHAR or a Value or a Collectable is C++ nomenclature? It isn't -- these are terms used by the API authors, and they and others using their library knows what these terms are.

    The person you need to ask would have to have the experience in using this particular set of libraries, so that you get a proper answer.

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center