hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
47a39822348b7fcfbe566c05fd4ab9592b658491
50,722
h
C
Library/LuaLib/lua_tinker.h
ysm1180/NewJojoGame
d46be6e979642ed3f139ad7905c983ac03356dd2
[ "MIT" ]
6
2018-10-12T08:06:35.000Z
2019-01-20T12:53:35.000Z
Library/LuaLib/lua_tinker.h
ysm1180/ThreeKingdoms-Caocao
d46be6e979642ed3f139ad7905c983ac03356dd2
[ "MIT" ]
2
2018-10-12T08:09:05.000Z
2019-01-20T12:55:27.000Z
Library/LuaLib/lua_tinker.h
ysm1180/NewJojoGame
d46be6e979642ed3f139ad7905c983ac03356dd2
[ "MIT" ]
2
2018-05-19T17:49:23.000Z
2018-10-15T03:10:57.000Z
// lua_tinker.h // // LuaTinker - Simple and light C++ wrapper for Lua. // // Copyright (c) 2005-2007 Kwon-il Lee (zupet@hitel.net) // // please check Licence.txt file for licence and legal issues. #if !defined(_LUA_TINKER_H_) #define _LUA_TINKER_H_ #define UNUSED(x) (void)(x) extern "C" { #include "lauxlib.h" #include "lua.h" #include "lualib.h" }; #include <new> #include <string> namespace three_kingdoms { class CWindowControl; class CMenu; class CTextFont; class CListViewColumn; class CListViewRow; class BinaryFile; class CME5File; } // namespace three_kingdoms namespace lua_tinker { // init LuaTinker void init(lua_State* L); void init_s64(lua_State* L); void init_u64(lua_State* L); // string-buffer excution void dofile(lua_State* L, const char* filename); void dostring(lua_State* L, const char* buff); void dobuffer(lua_State* L, const char* buff, size_t sz, const char* n = "lua_tinker::dobuffer()", bool isReturnValue = false); // debug helpers void enum_stack(lua_State* L); int on_error(lua_State* L); void print_error(lua_State* L, const char* fmt, ...); // dynamic type extention struct lua_value { virtual void to_lua(lua_State* L) = 0; }; // class helper int meta_get(lua_State* L); int meta_set(lua_State* L); void push_meta(lua_State* L, const char* name); // type trait template <typename T> struct class_name; struct table; template <bool C, typename A, typename B> struct if_ {}; template <typename A, typename B> struct if_<true, A, B> { typedef A type; }; template <typename A, typename B> struct if_<false, A, B> { typedef B type; }; template <typename A> struct is_ptr { static const bool value = false; }; template <typename A> struct is_ptr<A*> { static const bool value = true; }; template <typename A> struct is_ref { static const bool value = false; }; template <typename A> struct is_ref<A&> { static const bool value = true; }; template <typename A> struct remove_const { typedef A type; }; template <typename A> struct remove_const<const A> { typedef A type; }; template <typename A> struct base_type { typedef A type; }; template <typename A> struct base_type<A*> { typedef A type; }; template <typename A> struct base_type<A&> { typedef A type; }; template <typename A> struct class_type { typedef typename remove_const<typename base_type<A>::type>::type type; }; template <typename A> struct is_obj { static const bool value = true; }; template <> struct is_obj<char> { static const bool value = false; }; template <> struct is_obj<unsigned char> { static const bool value = false; }; template <> struct is_obj<short> { static const bool value = false; }; template <> struct is_obj<unsigned short> { static const bool value = false; }; template <> struct is_obj<long> { static const bool value = false; }; template <> struct is_obj<unsigned long> { static const bool value = false; }; template <> struct is_obj<int> { static const bool value = false; }; template <> struct is_obj<unsigned int> { static const bool value = false; }; template <> struct is_obj<float> { static const bool value = false; }; template <> struct is_obj<double> { static const bool value = false; }; template <> struct is_obj<char*> { static const bool value = false; }; template <> struct is_obj<const char*> { static const bool value = false; }; template <> struct is_obj<bool> { static const bool value = false; }; template <> struct is_obj<lua_value*> { static const bool value = false; }; template <> struct is_obj<long long> { static const bool value = false; }; template <> struct is_obj<unsigned long long> { static const bool value = false; }; template <> struct is_obj<table> { static const bool value = false; }; ///////////////////////////////// enum { no = 1, yes = 2 }; typedef char (&no_type)[no]; typedef char (&yes_type)[yes]; struct int_conv_type { int_conv_type(int); }; no_type int_conv_tester(...); yes_type int_conv_tester(int_conv_type); no_type vfnd_ptr_tester(const volatile char*); no_type vfnd_ptr_tester(const volatile short*); no_type vfnd_ptr_tester(const volatile int*); no_type vfnd_ptr_tester(const volatile long*); no_type vfnd_ptr_tester(const volatile double*); no_type vfnd_ptr_tester(const volatile float*); no_type vfnd_ptr_tester(const volatile bool*); yes_type vfnd_ptr_tester(const volatile void*); template <typename T> T* add_ptr(T&); template <bool C> struct bool_to_yesno { typedef no_type type; }; template <> struct bool_to_yesno<true> { typedef yes_type type; }; template <typename T> struct is_enum { static T arg; static const bool value = ((sizeof(int_conv_tester(arg)) == sizeof(yes_type)) && (sizeof(vfnd_ptr_tester(add_ptr(arg))) == sizeof(yes_type))); }; ///////////////////////////////// // from lua template <typename T> struct void2val { static T invoke(void* input) { return *(T*)input; } }; template <typename T> struct void2ptr { static T* invoke(void* input) { return (T*)input; } }; template <typename T> struct void2ref { static T& invoke(void* input) { return *(T*)input; } }; template <typename T> struct void2type { static T invoke(void* ptr) { return if_< is_ptr<T>::value, void2ptr<typename base_type<T>::type>, typename if_<is_ref<T>::value, void2ref<typename base_type<T>::type>, void2val<typename base_type<T>::type> >::type>::type:: invoke(ptr); } }; struct user { user(void* p) : m_p(p) {} virtual ~user() {} void* m_p; }; template <typename T> struct user2type { static T invoke(lua_State* L, int index) { return void2type<T>::invoke(lua_touserdata(L, index)); } }; template <typename T> struct lua2enum { static T invoke(lua_State* L, int index) { return (T)(int)lua_tonumber(L, index); } }; template <typename T> struct lua2object { static T invoke(lua_State* L, int index) { if (!lua_isuserdata(L, index)) { lua_pushstring(L, "no class at first argument. (forgot ':' expression ?)"); lua_error(L); } return void2type<T>::invoke(user2type<user*>::invoke(L, index)->m_p); } }; template <typename T> T lua2type(lua_State* L, int index) { return if_<is_enum<T>::value, lua2enum<T>, lua2object<T> >::type::invoke( L, index); } template <typename T> struct val2user : user { val2user() : user(new T) {} template <typename T1> val2user(T1 t1) : user(new T(t1)) {} template <typename T1, typename T2> val2user(T1 t1, T2 t2) : user(new T(t1, t2)) {} template <typename T1, typename T2, typename T3> val2user(T1 t1, T2 t2, T3 t3) : user(new T(t1, t2, t3)) {} template <typename T1, typename T2, typename T3, typename T4> val2user(T1 t1, T2 t2, T3 t3, T4 t4) : user(new T(t1, t2, t3, t4)) {} template <typename T1, typename T2, typename T3, typename T4, typename T5> val2user(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : user(new T(t1, t2, t3, t4, t5)) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> val2user(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) : user(new T(t1, t2, t3, t4, t5, t6)) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> val2user(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) : user(new T(t1, t2, t3, t4, t5, t6, t7)) {} ~val2user() { delete ((T*)m_p); } }; template <typename T> struct ptr2user : user { ptr2user(T* t) : user((void*)t) {} }; template <typename T> struct ref2user : user { ref2user(T& t) : user(&t) {} }; // to lua template <typename T> struct val2lua { static void invoke(lua_State* L, T& input) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>(input); } }; template <typename T> struct ptr2lua { static void invoke(lua_State* L, T* input) { if (input) { new (lua_newuserdata(L, sizeof(ptr2user<T>))) ptr2user<T>(input); } else { lua_pushnil(L); } } }; template <typename T> struct ref2lua { static void invoke(lua_State* L, T& input) { new (lua_newuserdata(L, sizeof(ref2user<T>))) ref2user<T>(input); } }; template <typename T> struct enum2lua { static void invoke(lua_State* L, T val) { lua_pushnumber(L, (int)val); } }; template <typename T> struct object2lua { static void invoke(lua_State* L, T val) { if_<is_ptr<T>::value, ptr2lua<typename base_type<T>::type>, typename if_<is_ref<T>::value, ref2lua<typename base_type<T>::type>, val2lua<typename base_type<T>::type> >::type>::type:: invoke(L, val); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); } }; template <typename T> void type2lua(lua_State* L, T val) { if_<is_enum<T>::value, enum2lua<T>, object2lua<T> >::type::invoke(L, val); } // get value from cclosure template <typename T> T upvalue_(lua_State* L) { return user2type<T>::invoke(L, lua_upvalueindex(1)); } // read a value from lua stack template <typename T> T read(lua_State* L, int index) { return lua2type<T>(L, index); } template <> char* read(lua_State* L, int index); template <> const char* read(lua_State* L, int index); template <> std::string read(lua_State* L, int index); template <> std::wstring read(lua_State* L, int index); template <> char read(lua_State* L, int index); template <> unsigned char read(lua_State* L, int index); template <> short read(lua_State* L, int index); template <> unsigned short read(lua_State* L, int index); template <> long read(lua_State* L, int index); template <> unsigned long read(lua_State* L, int index); template <> int read(lua_State* L, int index); template <> unsigned int read(lua_State* L, int index); template <> float read(lua_State* L, int index); template <> double read(lua_State* L, int index); template <> bool read(lua_State* L, int index); template <> void read(lua_State* L, int index); template <> long long read(lua_State* L, int index); template <> unsigned long long read(lua_State* L, int index); template <> table read(lua_State* L, int index); template <> ::three_kingdoms::CWindowControl* read(lua_State* L, int index); template <> ::three_kingdoms::CMenu* read(lua_State* L, int index); template <> ::three_kingdoms::CTextFont* read(lua_State* L, int index); template <> ::three_kingdoms::CListViewColumn* read(lua_State* L, int index); template <> ::three_kingdoms::CListViewRow* read(lua_State* L, int index); template <> ::three_kingdoms::BinaryFile* read(lua_State* L, int index); template <> ::three_kingdoms::CME5File* read(lua_State* L, int index); // push a value to lua stack template <typename T> void push(lua_State* L, T ret) { type2lua<T>(L, ret); } template <> void push(lua_State* L, char ret); template <> void push(lua_State* L, unsigned char ret); template <> void push(lua_State* L, std::string ret); template <> void push(lua_State* L, std::wstring ret); template <> void push(lua_State* L, short ret); template <> void push(lua_State* L, unsigned short ret); template <> void push(lua_State* L, long ret); template <> void push(lua_State* L, unsigned long ret); template <> void push(lua_State* L, int ret); template <> void push(lua_State* L, unsigned int ret); template <> void push(lua_State* L, float ret); template <> void push(lua_State* L, double ret); template <> void push(lua_State* L, char* ret); template <> void push(lua_State* L, const char* ret); template <> void push(lua_State* L, bool ret); template <> void push(lua_State* L, lua_value* ret); template <> void push(lua_State* L, long long ret); template <> void push(lua_State* L, unsigned long long ret); template <> void push(lua_State* L, table ret); // pop a value from lua stack template <typename T> T pop(lua_State* L) { T t = read<T>(L, -1); lua_pop(L, 1); return t; } template <> void pop(lua_State* L); template <> table pop(lua_State* L); // functor (with return value) template <typename RVal, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void, typename T5 = void, typename T6 = void, typename T7 = void> struct functor { static int invoke(lua_State* L) { push(L, upvalue_<RVal (*)(T1, T2, T3, T4, T5, T6, T7)>(L)( read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3), read<T4>(L, 4), read<T5>(L, 5), read<T6>(L, 6), read<T7>(L, 7))); return 1; } }; template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> struct functor<RVal, T1, T2, T3, T4, T5, T6> { static int invoke(lua_State* L) { push(L, upvalue_<RVal (*)(T1, T2, T3, T4, T5, T6)>(L)( read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3), read<T4>(L, 4), read<T5>(L, 5), read<T6>(L, 6))); return 1; } }; template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5> struct functor<RVal, T1, T2, T3, T4, T5> { static int invoke(lua_State* L) { push(L, upvalue_<RVal (*)(T1, T2, T3, T4, T5)>(L)( read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3), read<T4>(L, 4), read<T5>(L, 5))); return 1; } }; template <typename RVal, typename T1, typename T2, typename T3, typename T4> struct functor<RVal, T1, T2, T3, T4> { static int invoke(lua_State* L) { push(L, upvalue_<RVal (*)(T1, T2, T3, T4)>(L)(read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3), read<T4>(L, 4))); return 1; } }; template <typename RVal, typename T1, typename T2, typename T3> struct functor<RVal, T1, T2, T3> { static int invoke(lua_State* L) { push(L, upvalue_<RVal (*)(T1, T2, T3)>(L)(read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3))); return 1; } }; template <typename RVal, typename T1, typename T2> struct functor<RVal, T1, T2> { static int invoke(lua_State* L) { push(L, upvalue_<RVal (*)(T1, T2)>(L)(read<T1>(L, 1), read<T2>(L, 2))); return 1; } }; template <typename RVal, typename T1> struct functor<RVal, T1> { static int invoke(lua_State* L) { push(L, upvalue_<RVal (*)(T1)>(L)(read<T1>(L, 1))); return 1; } }; template <typename RVal> struct functor<RVal> { static int invoke(lua_State* L) { push(L, upvalue_<RVal (*)()>(L)()); return 1; } }; // functor (without return value) template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> struct functor<void, T1, T2, T3, T4, T5, T6, T7> { static int invoke(lua_State* L) { upvalue_<void (*)(T1, T2, T3, T4, T5)>(L)( read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3), read<T4>(L, 4), read<T5>(L, 5), read<T6>(L, 6), read<T7>(L, 7)); return 0; } }; template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> struct functor<void, T1, T2, T3, T4, T5, T6> { static int invoke(lua_State* L) { upvalue_<void (*)(T1, T2, T3, T4, T5)>(L)(read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3), read<T4>(L, 4), read<T5>(L, 5), read<T6>(L, 6)); return 0; } }; template <typename T1, typename T2, typename T3, typename T4, typename T5> struct functor<void, T1, T2, T3, T4, T5> { static int invoke(lua_State* L) { upvalue_<void (*)(T1, T2, T3, T4, T5)>(L)(read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3), read<T4>(L, 4), read<T5>(L, 5)); return 0; } }; template <typename T1, typename T2, typename T3, typename T4> struct functor<void, T1, T2, T3, T4> { static int invoke(lua_State* L) { upvalue_<void (*)(T1, T2, T3, T4)>(L)(read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3), read<T4>(L, 4)); return 0; } }; template <typename T1, typename T2, typename T3> struct functor<void, T1, T2, T3> { static int invoke(lua_State* L) { upvalue_<void (*)(T1, T2, T3)>(L)(read<T1>(L, 1), read<T2>(L, 2), read<T3>(L, 3)); return 0; } }; template <typename T1, typename T2> struct functor<void, T1, T2> { static int invoke(lua_State* L) { upvalue_<void (*)(T1, T2)>(L)(read<T1>(L, 1), read<T2>(L, 2)); return 0; } }; template <typename T1> struct functor<void, T1> { static int invoke(lua_State* L) { upvalue_<void (*)(T1)>(L)(read<T1>(L, 1)); return 0; } }; template <> struct functor<void> { static int invoke(lua_State* L) { upvalue_<void (*)()>(L)(); return 0; } }; // functor (non-managed) template <typename T1> struct functor<int, lua_State*, T1> { static int invoke(lua_State* L) { return upvalue_<int (*)(lua_State*, T1)>(L)(L, read<T1>(L, 1)); } }; template <> struct functor<int, lua_State*> { static int invoke(lua_State* L) { return upvalue_<int (*)(lua_State*)>(L)(L); } }; // push_functor template <typename RVal> void push_functor(lua_State* L, RVal (*func)()) { UNUSED(func); lua_pushcclosure(L, functor<RVal>::invoke, 1); } template <typename RVal, typename T1> void push_functor(lua_State* L, RVal (*func)(T1)) { UNUSED(func); lua_pushcclosure(L, functor<RVal, T1>::invoke, 1); } template <typename RVal, typename T1, typename T2> void push_functor(lua_State* L, RVal (*func)(T1, T2)) { UNUSED(func); lua_pushcclosure(L, functor<RVal, T1, T2>::invoke, 1); } template <typename RVal, typename T1, typename T2, typename T3> void push_functor(lua_State* L, RVal (*func)(T1, T2, T3)) { UNUSED(func); lua_pushcclosure(L, functor<RVal, T1, T2, T3>::invoke, 1); } template <typename RVal, typename T1, typename T2, typename T3, typename T4> void push_functor(lua_State* L, RVal (*func)(T1, T2, T3, T4)) { UNUSED(func); lua_pushcclosure(L, functor<RVal, T1, T2, T3, T4>::invoke, 1); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5> void push_functor(lua_State* L, RVal (*func)(T1, T2, T3, T4, T5)) { UNUSED(func); lua_pushcclosure(L, functor<RVal, T1, T2, T3, T4, T5>::invoke, 1); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> void push_functor(lua_State* L, RVal (*func)(T1, T2, T3, T4, T5, T6)) { UNUSED(func); lua_pushcclosure(L, functor<RVal, T1, T2, T3, T4, T5, T6>::invoke, 1); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> void push_functor(lua_State* L, RVal (*func)(T1, T2, T3, T4, T5, T6, T7)) { UNUSED(func); lua_pushcclosure(L, functor<RVal, T1, T2, T3, T4, T5, T6, T7>::invoke, 1); } // member variable struct var_base { virtual void get(lua_State* L) = 0; virtual void set(lua_State* L) = 0; }; template <typename T, typename V> struct mem_var : var_base { V T::*_var; mem_var(V T::*val) : _var(val) {} void get(lua_State* L) { push<if_<is_obj<V>::value, V&, V>::type>(L, read<T*>(L, 1)->*(_var)); } void set(lua_State* L) { read<T*>(L, 1)->*(_var) = read<V>(L, 3); } }; // class member functor (with return value) template <typename RVal, typename T, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void, typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void> struct mem_functor { static int invoke(lua_State* L) { push( L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)(T1, T2, T3, T4, T5, T6, T7, T8)>( L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6), read<T6>(L, 7), read<T7>(L, 8), read<T8>(L, 9))); ; return 1; } }; template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> struct mem_functor<RVal, T, T1, T2, T3, T4, T5, T6, T7> { static int invoke(lua_State* L) { push( L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)(T1, T2, T3, T4, T5, T6, T7)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6), read<T6>(L, 7), read<T7>(L, 8))); return 1; } }; template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> struct mem_functor<RVal, T, T1, T2, T3, T4, T5, T6> { static int invoke(lua_State* L) { push(L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)(T1, T2, T3, T4, T5, T6)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6), read<T6>(L, 7))); return 1; } }; template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5> struct mem_functor<RVal, T, T1, T2, T3, T4, T5> { static int invoke(lua_State* L) { push(L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)(T1, T2, T3, T4, T5)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6))); return 1; } }; template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4> struct mem_functor<RVal, T, T1, T2, T3, T4> { static int invoke(lua_State* L) { push(L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)(T1, T2, T3, T4)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5))); return 1; } }; template <typename RVal, typename T, typename T1, typename T2, typename T3> struct mem_functor<RVal, T, T1, T2, T3> { static int invoke(lua_State* L) { push(L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)(T1, T2, T3)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4))); return 1; } }; template <typename RVal, typename T, typename T1, typename T2> struct mem_functor<RVal, T, T1, T2> { static int invoke(lua_State* L) { push(L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)(T1, T2)>(L))( read<T1>(L, 2), read<T2>(L, 3))); return 1; } }; template <typename RVal, typename T, typename T1> struct mem_functor<RVal, T, T1> { static int invoke(lua_State* L) { push(L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)(T1)>(L))(read<T1>(L, 2))); return 1; } }; template <typename RVal, typename T> struct mem_functor<RVal, T> { static int invoke(lua_State* L) { push(L, (read<T*>(L, 1)->*upvalue_<RVal (T::*)()>(L))()); return 1; } }; // class member functor (without return value) template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> struct mem_functor<void, T, T1, T2, T3, T4, T5, T6, T7, T8> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)(T1, T2, T3, T4, T5, T6, T7, T8)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6), read<T6>(L, 7), read<T7>(L, 8), read<T8>(L, 9)); return 0; } }; template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> struct mem_functor<void, T, T1, T2, T3, T4, T5, T6, T7> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)(T1, T2, T3, T4, T5, T6, T7)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6), read<T6>(L, 7), read<T7>(L, 8)); return 0; } }; template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> struct mem_functor<void, T, T1, T2, T3, T4, T5, T6> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)(T1, T2, T3, T4, T5, T6)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6), read<T6>(L, 7)); return 0; } }; template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> struct mem_functor<void, T, T1, T2, T3, T4, T5> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)(T1, T2, T3, T4, T5)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6)); return 0; } }; template <typename T, typename T1, typename T2, typename T3, typename T4> struct mem_functor<void, T, T1, T2, T3, T4> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)(T1, T2, T3, T4)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5)); return 0; } }; template <typename T, typename T1, typename T2, typename T3> struct mem_functor<void, T, T1, T2, T3> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)(T1, T2, T3)>(L))( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4)); return 0; } }; template <typename T, typename T1, typename T2> struct mem_functor<void, T, T1, T2> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)(T1, T2)>(L))(read<T1>(L, 2), read<T2>(L, 3)); return 0; } }; template <typename T, typename T1> struct mem_functor<void, T, T1> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)(T1)>(L))(read<T1>(L, 2)); return 0; } }; template <typename T> struct mem_functor<void, T> { static int invoke(lua_State* L) { (read<T*>(L, 1)->*upvalue_<void (T::*)()>(L))(); return 0; } }; // class member functor (non-managed) template <typename T, typename T1> struct mem_functor<int, T, lua_State*, T1> { static int invoke(lua_State* L) { return (read<T*>(L, 1)->*upvalue_<int (T::*)(lua_State*, T1)>(L))( L, read<T1>(L, 2)); } }; template <typename T> struct mem_functor<int, T, lua_State*> { static int invoke(lua_State* L) { return (read<T*>(L, 1)->*upvalue_<int (T::*)(lua_State*)>(L))(L); } }; // push_functor template <typename RVal, typename T> void push_functor(lua_State* L, RVal (T::*func)()) { UNUSED(func); lua_pushcclosure(L, mem_functor<RVal, T>::invoke, 1); } template <typename RVal, typename T> void push_functor(lua_State* L, RVal (T::*func)() const) { lua_pushcclosure(L, mem_functor<RVal, T>::invoke, 1); } template <typename RVal, typename T, typename T1> void push_functor(lua_State* L, RVal (T::*func)(T1)) { UNUSED(func); lua_pushcclosure(L, mem_functor<RVal, T, T1>::invoke, 1); } template <typename RVal, typename T, typename T1> void push_functor(lua_State* L, RVal (T::*func)(T1) const) { lua_pushcclosure(L, mem_functor<RVal, T, T1>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2> void push_functor(lua_State* L, RVal (T::*func)(T1, T2)) { UNUSED(func); lua_pushcclosure(L, mem_functor<RVal, T, T1, T2>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2> void push_functor(lua_State* L, RVal (T::*func)(T1, T2) const) { lua_pushcclosure(L, mem_functor<RVal, T, T1, T2>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3)) { UNUSED(func); lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3) const) { lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3, T4)) { UNUSED(func); lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3, T4>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3, T4) const) { lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3, T4>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3, T4, T5)) { UNUSED(func); lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3, T4, T5>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3, T4, T5) const) { lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3, T4, T5>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3, T4, T5, T6)) { UNUSED(func); lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3, T4, T5, T6>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3, T4, T5, T6) const) { lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3, T4, T5, T6>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3, T4, T5, T6, T7)) { UNUSED(func); lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3, T4, T5, T6, T7>::invoke, 1); } template <typename RVal, typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> void push_functor(lua_State* L, RVal (T::*func)(T1, T2, T3, T4, T5, T6, T7) const) { lua_pushcclosure(L, mem_functor<RVal, T, T1, T2, T3, T4, T5, T6, T7>::invoke, 1); } // constructor template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> int constructor(lua_State* L) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6), read<T6>(L, 7), read<T7>(L, 8)); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); return 1; } template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> int constructor(lua_State* L) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>(read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6), read<T6>(L, 7)); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); return 1; } template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5> int constructor(lua_State* L) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>(read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5), read<T5>(L, 6)); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); return 1; } template <typename T, typename T1, typename T2, typename T3, typename T4> int constructor(lua_State* L) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>( read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4), read<T4>(L, 5)); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); return 1; } template <typename T, typename T1, typename T2, typename T3> int constructor(lua_State* L) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>(read<T1>(L, 2), read<T2>(L, 3), read<T3>(L, 4)); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); return 1; } template <typename T, typename T1, typename T2> int constructor(lua_State* L) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>(read<T1>(L, 2), read<T2>(L, 3)); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); return 1; } template <typename T, typename T1> int constructor(lua_State* L) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>(read<T1>(L, 2)); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); return 1; } template <typename T> int constructor(lua_State* L) { new (lua_newuserdata(L, sizeof(val2user<T>))) val2user<T>(); push_meta(L, class_name<typename class_type<T>::type>::name()); lua_setmetatable(L, -2); return 1; } // destroyer template <typename T> int destroyer(lua_State* L) { ((user*)lua_touserdata(L, 1))->~user(); return 0; } // global function template <typename F> void def(lua_State* L, const char* name, F func) { lua_pushlightuserdata(L, (void*)func); push_functor(L, func); lua_setglobal(L, name); } // global variable template <typename T> void set(lua_State* L, const char* name, T object) { push(L, object); lua_setglobal(L, name); } template <typename T> T get(lua_State* L, const char* name) { lua_getglobal(L, name); return pop<T>(L); } template <typename T> void decl(lua_State* L, const char* name, T object) { set(L, name, object); } // ref call template <typename RVal> RVal call(lua_State* L, int ref) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { if (lua_pcall(L, 0, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1> RVal call(lua_State* L, int ref, T1 arg) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { push(L, arg); if (lua_pcall(L, 1, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2> RVal call(lua_State* L, int ref, T1 arg1, T2 arg2) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); if (lua_pcall(L, 2, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3> RVal call(lua_State* L, int ref, T1 arg1, T2 arg2, T3 arg3) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); if (lua_pcall(L, 3, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4> RVal call(lua_State* L, int ref, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); if (lua_pcall(L, 4, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5> RVal call(lua_State* L, int ref, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); push(L, arg5); if (lua_pcall(L, 5, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> RVal call(lua_State* L, int ref, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); push(L, arg5); push(L, arg6); if (lua_pcall(L, 6, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> RVal call(lua_State* L, int ref, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); push(L, arg5); push(L, arg6); push(L, arg7); if (lua_pcall(L, 7, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> RVal call(lua_State* L, int ref, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, ref); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); push(L, arg5); push(L, arg6); push(L, arg7); push(L, arg8); if (lua_pcall(L, 8, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error(L, "lua_tinker::call() attempt to call error (not a function)"); } lua_remove(L, -2); return pop<RVal>(L); } // call template <typename RVal> RVal call(lua_State* L, const char* name) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { if (lua_pcall(L, 0, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1> RVal call(lua_State* L, const char* name, T1 arg) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { push(L, arg); if (lua_pcall(L, 1, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2> RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); if (lua_pcall(L, 2, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3> RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2, T3 arg3) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); if (lua_pcall(L, 3, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4> RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); if (lua_pcall(L, 4, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5> RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); push(L, arg5); if (lua_pcall(L, 5, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); push(L, arg5); push(L, arg6); if (lua_pcall(L, 6, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); push(L, arg5); push(L, arg6); push(L, arg7); if (lua_pcall(L, 7, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_getglobal(L, name); if (lua_isfunction(L, -1)) { push(L, arg1); push(L, arg2); push(L, arg3); push(L, arg4); push(L, arg5); push(L, arg6); push(L, arg7); push(L, arg8); if (lua_pcall(L, 8, 1, errfunc) != 0) { lua_pop(L, 1); } } else { print_error( L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, -2); return pop<RVal>(L); } template <typename RVal> RVal call(lua_State* lua, const wchar_t* name) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName); } template <typename RVal, typename T1> RVal call(lua_State* lua, const wchar_t* name, T1 arg) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName, arg); } template <typename RVal, typename T1, typename T2> RVal call(lua_State* lua, const wchar_t* name, T1 arg1, T2 arg2) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName, arg1, arg2); } template <typename RVal, typename T1, typename T2, typename T3> RVal call(lua_State* lua, const wchar_t* name, T1 arg1, T2 arg2, T3 arg3) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName, arg1, arg2, arg3); } template <typename RVal, typename T1, typename T2, typename T3, typename T4> RVal call(lua_State* lua, const wchar_t* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName, arg1, arg2, arg3, arg4); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5> RVal call(lua_State* lua, const wchar_t* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName, arg1, arg2, arg3, arg4, arg5); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> RVal call(lua_State* lua, const wchar_t* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName, arg1, arg2, arg3, arg4, arg5, arg6); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> RVal call(lua_State* lua, const wchar_t* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } template <typename RVal, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> RVal call(lua_State* lua, const wchar_t* name, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) { char callName[256] = {}; size_t convertedSize = 0; wcstombs_s(&convertedSize, callName, wcslen(name) + 1, name, wcslen(name)); return lua_tinker::call<RVal>(lua, callName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); } // } // class init template <typename T> void class_add(lua_State* L, const char* name) { class_name<T>::name(name); lua_newtable(L); lua_pushstring(L, "__name"); lua_pushstring(L, name); lua_rawset(L, -3); lua_pushstring(L, "__index"); lua_pushcclosure(L, meta_get, 0); lua_rawset(L, -3); lua_pushstring(L, "__newindex"); lua_pushcclosure(L, meta_set, 0); lua_rawset(L, -3); lua_pushstring(L, "__gc"); lua_pushcclosure(L, destroyer<T>, 0); lua_rawset(L, -3); lua_setglobal(L, name); } // Tinker Class Inheritence template <typename T, typename P> void class_inh(lua_State* L) { push_meta(L, class_name<T>::name()); if (lua_istable(L, -1)) { lua_pushstring(L, "__parent"); push_meta(L, class_name<P>::name()); lua_rawset(L, -3); } lua_pop(L, 1); } // Tinker Class Constructor template <typename T, typename F> void class_con(lua_State* L, F func) { push_meta(L, class_name<T>::name()); if (lua_istable(L, -1)) { lua_newtable(L); lua_pushstring(L, "__call"); lua_pushcclosure(L, func, 0); lua_rawset(L, -3); lua_setmetatable(L, -2); } lua_pop(L, 1); } // Tinker Class Functions template <typename T, typename F> void class_def(lua_State* L, const char* name, F func) { push_meta(L, class_name<T>::name()); if (lua_istable(L, -1)) { lua_pushstring(L, name); new (lua_newuserdata(L, sizeof(F))) F(func); push_functor(L, func); lua_rawset(L, -3); } lua_pop(L, 1); } // Tinker Class Variables template <typename T, typename BASE, typename VAR> void class_mem(lua_State* L, const char* name, VAR BASE::*val) { push_meta(L, class_name<T>::name()); if (lua_istable(L, -1)) { lua_pushstring(L, name); new (lua_newuserdata(L, sizeof(mem_var<BASE, VAR>))) mem_var<BASE, VAR>(val); lua_rawset(L, -3); } lua_pop(L, 1); } template <typename T> struct class_name { // global name static const char* name(const char* name = NULL) { static char temp[256] = ""; if (name) { strcpy_s(temp, name); } return temp; } }; // Table Object on Stack struct table_obj { table_obj(lua_State* L, int index); ~table_obj(); void inc_ref(); void dec_ref(); bool validate(); template <typename T> void set(const char* name, T object) { if (validate()) { lua_pushstring(m_L, name); push(m_L, object); lua_settable(m_L, m_index); } } template <typename T> T get(const char* name) { if (validate()) { lua_pushstring(m_L, name); lua_gettable(m_L, m_index); } else { lua_pushnil(m_L); } return pop<T>(m_L); } lua_State* m_L; int m_index; const void* m_pointer; int m_ref; }; // Table Object Holder struct table { table(lua_State* L); table(lua_State* L, int index); table(lua_State* L, const char* name); table(const table& input); ~table(); template <typename T> void set(const char* name, T object) { m_obj->set(name, object); } template <typename T> T get(const char* name) { return m_obj->get<T>(name); } table_obj* m_obj; }; } // namespace lua_tinker #endif //_LUA_TINKER_H_
27.124064
80
0.622531
[ "object" ]
47b3537b51815e78cd75f2d1479ccf6f7f8cd7b8
41,760
c
C
stellar_wind_cartesian/init.c
sddyates/PlutoProblems
68e5b5e6375a63981989057f45937e587b95b5b6
[ "MIT" ]
null
null
null
stellar_wind_cartesian/init.c
sddyates/PlutoProblems
68e5b5e6375a63981989057f45937e587b95b5b6
[ "MIT" ]
null
null
null
stellar_wind_cartesian/init.c
sddyates/PlutoProblems
68e5b5e6375a63981989057f45937e587b95b5b6
[ "MIT" ]
2
2019-07-02T05:47:42.000Z
2021-12-08T05:42:15.000Z
/*================================================================================*/ /* Initilisation file for a radiativly driven stellar wind with a non-rigid dipole configuration magnetic field. The boundary and initial conditions are taken from Runacres and Owocki (2002) The method for calculating the radiative acceleration comes from CAK (1975) The model only works with polar corrdinates in 2D & 3D, with the MHD module. 1D, HD, RHD, RMHD and other geometries do not work at the moment. */ #include "pluto.h" double TwoDimensionalInterp(const Data *d, RBox *box, Grid *grid, int i, int j, int k, double *x1, double *x2, double r, double ddr); double ThreeDimensionalInterp(const Data *d, RBox *box, Grid *grid, int i, int j, int k, double *x1, double *x2, double *x3, double r, double ddr); double VelocityStellarSurface2D(const Data *d, RBox *box, Grid *grid, int i, int j, int k, double *x1, double *x2, double *x3, double r); double VelocityStellarSurface3D(const Data *d, RBox *box, Grid *grid, int i, int j, int k, double *x1, double *x2, double *x3, double r); /*================================================================================*/ void Init (double *v, double x1, double x2, double x3){ double Mratio = g_inputParam[M_RATIO], Lratio = g_inputParam[L_RATIO], Bcgs = g_inputParam[B_CGS], T = g_inputParam[TT], mu = g_inputParam[MU], a = g_inputParam[AA], b = g_inputParam[b_law], Q = g_inputParam[QQ], a_eff = g_inputParam[aa_eff], beta = g_inputParam[BB], M_star = (Mratio*CONST_Msun/UNIT_MASS), Edd = (2.6e-5*(Lratio)*(1.0/Mratio)), L = (Lratio*L_SUN/UNIT_L), c = 3.0e+5, M_dot = pow(1.0+a_eff,-(1.0/a_eff)) * a_eff * pow(1.0-a_eff,-1)* (L/(c*c))*pow(((Q*Edd)*pow(1.0-Edd,-1)),pow(a_eff,-1)-1.0), cs = sqrt(UNIT_kB*T/(mu*(CONST_AH/UNIT_MASS)*CONST_amu)), Cs_p = g_inputParam[Cs_P], Bq = Bcgs/UNIT_B, v_esc = sqrt(2.0*UNIT_G*M_star*(1.0-Edd)), v_inf = 3.0*v_esc,//v_esc * sqrt((a/(1.0-a))), vv = 0.0, Omega = 0.0, x = 0.0, y = 0.0, z = 0.0, xp = 0.0, yp = 0.0, zp = 0.0, bx = 0.0, by = 0.0, bz = 0.0, bxp = 0.0, byp = 0.0, bzp = 0.0, r = 0.0, r2 = 0.0, rp = 0.0, rp2 = 0.0, rb = 0.0, rb2 = 0.0, theta = 0.0; double vel_x1, vel_x2, vel_x3, vel_mag, vel_mag2; #if EOS == IDEAL g_gamma = 1.05; #endif #if EOS == ISOTHERMAL g_isoSoundSpeed = sqrt(UNIT_kB*T/(mu*(CONST_AH/UNIT_MASS)*CONST_amu)); #endif r2 = EXPAND(x1*x1,+x2*x2,+x3*x3); r = sqrt(r2); beta *= 0.0174532925; #if DIMENSIONS == 2 xp = x1*cos(beta) - x2*sin(beta); yp = x1*sin(beta) + x2*cos(beta); #endif #if DIMENSIONS == 3 xp = x1*cos(beta) - x3*sin(beta); yp = x2; zp = x1*sin(beta) + x3*cos(beta); #endif rp2 = EXPAND(xp*xp, + yp*yp, + zp*zp); rp = sqrt(rp2); Omega = (0.5*sqrt((8.0*UNIT_G*M_star)/27.0)); if (r > 1.0) { #if DIMENSIONS == 2 theta = atan2(xp,yp); #endif #if DIMENSIONS == 3 theta = acos(zp/rp); #endif vv = v_inf*pow(1.0 - (1.0/r),b); v[RHO] = (M_dot/(4.0*CONST_PI*vv*r2)); #if EOS == IDEAL v[PRS] = (v[RHO]*T/(KELVIN*mu)); #endif D_EXPAND(v[VX1] = vv*x1/r;, v[VX2] = vv*x2/r;, v[VX3] = vv*x3/r;) #if PHYSICS == MHD #if BACKGROUND_FIELD == NO #if DIMENSIONS == 2 bx = 3.0*xp*yp*Bq*pow(rp,-5); by = (3.0*pow(yp,2)-pow(rp,2))*Bq*pow(rp,-5); bxp = bx*cos(beta) + by*sin(beta);; byp = -bx*sin(beta) + by*cos(beta); EXPAND(v[BX1] = bxp;, v[BX2] = byp;, v[BX3] = 0.0;) #endif #if DIMENSIONS == 3 bx = 3.0*xp*zp*Bq*pow(rp,-5); by = 3.0*yp*zp*Bq*pow(rp,-5); bz = (3.0*pow(zp,2)-pow(rp,2))*Bq*pow(rp,-5); bxp = bx*cos(beta) + bz*sin(beta); byp = by; bzp = -bx*sin(beta) + bz*cos(beta); EXPAND(v[BX1] = bxp;, v[BX2] = byp;, v[BX3] = bzp;) #endif #endif #endif } else if (r > 0.5 && r <= 1.0) { v[RHO] = (M_dot/(4.0*CONST_PI*(cs/Cs_p))); #if EOS == IDEAL v[PRS] = (v[RHO]*T/(KELVIN*mu)); #endif vel_mag = v_inf*pow(1.0 - (1.0/1.001),b); D_EXPAND(vel_x1 = 0.0;, vel_x2 = 0.0;, vel_x3 = 0.0;) D_EXPAND(v[VX1] = vel_mag*x1/r;, v[VX2] = vel_mag*x2/r;, v[VX3] = vel_mag*x3/r;) #if PHYSICS == MHD #if BACKGROUND_FIELD == NO #if DIMENSIONS == 2 bx = 3.0*xp*yp*Bq*pow(rp,-5); by = (3.0*pow(yp,2)-pow(rp,2))*Bq*pow(rp,-5); bxp = bx*cos(beta) + by*sin(beta);; byp = -bx*sin(beta) + by*cos(beta); EXPAND(v[BX1] = bxp;, v[BX2] = byp;, v[BX3] = 0.0;) #endif #if DIMENSIONS == 3 bx = 3.0*xp*zp*Bq*pow(rp,-5); by = 3.0*yp*zp*Bq*pow(rp,-5); bz = (3.0*pow(zp,2)-pow(rp,2))*Bq*pow(rp,-5); bxp = bx*cos(beta) + bz*sin(beta); byp = by; bzp = -bx*sin(beta) + bz*cos(beta); EXPAND(v[BX1] = bxp;, v[BX2] = byp;, v[BX3] = bzp;) #endif #endif #endif } else if (r <= 0.5 ) { v[RHO] = (M_dot/(4.0*CONST_PI*(cs/Cs_p))); #if EOS == IDEAL v[PRS] = (v[RHO]*T/(KELVIN*mu)); #endif D_EXPAND(v[VX1] = 0.0;, v[VX2] = 0.0;, v[VX3] = 0.0;) #if PHYSICS == MHD #if BACKGROUND_FIELD == NO #if DIMENSIONS == 2 bx = 0.0; by = Bq*16.0; bxp = bx*cos(beta) + by*sin(beta);; byp = -bx*sin(beta) + by*cos(beta); EXPAND(v[BX1] = bxp;, v[BX2] = byp;, v[BX3] = 0.0;) #endif #if DIMENSIONS == 3 bx = 0.0; by = 0.0; bz = 16.0*Bq; bxp = bx*cos(beta) + bz*sin(beta); byp = by; bzp = -bx*sin(beta) + bz*cos(beta); EXPAND(v[BX1] = bxp;, v[BX2] = byp;, v[BX3] = bzp;) #endif #endif #endif } } /*================================================================================*/ /*================================================================================*/ #if BACKGROUND_FIELD == YES void BackgroundField (double x1, double x2, double x3, double *B0) { double x, y, z; double xp, yp, zp; double bx, by, bz; double bxp, byp, bzp; double r, r2, rp, rp2, rb, rb2; double theta, beta, Bq, Bcgs; Bcgs = g_inputParam[B_CGS]; Bq = Bcgs/UNIT_B; beta = g_inputParam[BB]; r2 = EXPAND(x1*x1,+x2*x2,+x3*x3); r = sqrt(r2); beta *= 0.0174532925; #if DIMENSIONS == 2 xp = x1*cos(beta) - x2*sin(beta); yp = x1*sin(beta) + x2*cos(beta); #endif #if DIMENSIONS == 3 xp = x1*cos(beta) - x3*sin(beta); yp = x2; zp = x1*sin(beta) + x3*cos(beta); #endif rp2 = EXPAND(xp*xp, + yp*yp, + zp*zp); rp = sqrt(rp2); if (r <= 0.5 ) { #if DIMENSIONS == 2 bx = 0.0; by = Bq*16.0; bxp = bx*cos(beta) + by*sin(beta);; byp = -bx*sin(beta) + by*cos(beta); B0[0] = bxp; B0[1] = byp; B0[2] = 0.0; #endif #if DIMENSIONS == 3 bx = 0.0; by = 0.0; bz = 16.0*Bq; bxp = bx*cos(beta) + bz*sin(beta); byp = by; bzp = -bx*sin(beta) + bz*cos(beta); B0[0] = bxp; B0[1] = byp; B0[2] = bzp; #endif } else if (r > 0.5){ #if DIMENSIONS == 2 bx = 3.0*xp*yp*Bq*pow(rp,-5); by = (3.0*pow(yp,2)-pow(rp,2))*Bq*pow(rp,-5); bxp = bx*cos(beta) + by*sin(beta);; byp = -bx*sin(beta) + by*cos(beta); B0[0] = bxp; B0[1] = byp; B0[2] = 0.0; #endif #if DIMENSIONS == 3 bx = 3.0*xp*zp*Bq*pow(rp,-5); by = 3.0*yp*zp*Bq*pow(rp,-5); bz = (3.0*pow(zp,2)-pow(rp,2))*Bq*pow(rp,-5); bxp = bx*cos(beta) + bz*sin(beta); byp = by; bzp = -bx*sin(beta) + bz*cos(beta); B0[0] = bxp; B0[1] = byp; B0[2] = bzp; #endif } } #endif /*================================================================================*/ void Analysis (const Data *d, Grid *grid){} /*================================================================================*/ void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid) { int i, j, k, p, o, l, m, n, ghost, phase, kprime, jprime; double Cs_p, Mratio, Lratio, T, mu, a, b, Q, a_eff, beta, Omega, shell, M_star; double Edd, L, c, M_dot, ke, Omega2, A, Bcgs, cs, Bq, v_esc, v_inf; double bx = 0.0, by = 0.0, bz = 0.0; double bxp = 0.0, byp = 0.0, bzp = 0.0; double x = 0.0, y = 0.0, z = 0.0; double xp = 0.0, yp = 0.0, zp = 0.0; double *x1 = grid[IDIR].x, *x2 = grid[JDIR].x, *x3 = grid[KDIR].x; double *dx1 = grid[IDIR].dx, *dx2 = grid[JDIR].dx, *dx3 = grid[KDIR].dx; double ***vx1 = d->Vc[VX1], ***vx2 = d->Vc[VX2], ***vx3 = d->Vc[VX3]; double dx = 0.0, dy = 0.0, dz = 0.0; double P00 = 0.0, P01 = 0.0, P11 = 0.0, P12 = 0.0, P22 = 0.0; double dvdr = 0.0, dvdr2 = 0.0, Beq = 0.0, vel_mag; double vr = 0.0, vr2 = 0.0, r = 0.0, r2 = 0.0, theta = 0.0, phi = 0.0; double dr2 = 0.0, dr = 0.0, ddr = 0.0, rb = 0.0, rb2 = 0.0, rp = 0.0, rp2 = 0.0, dI2 = 0.0, dI = 0.0, vrI[2]; double gL = 0.0, nu2_c = 0.0, B = 0.0, sigma = 0.0, f = 0.0, vv = 0.0; Cs_p = g_inputParam[Cs_P]; Mratio = g_inputParam[M_RATIO]; Lratio = g_inputParam[L_RATIO]; T = g_inputParam[TT]; mu = g_inputParam[MU]; a = g_inputParam[AA]; b = g_inputParam[b_law]; Q = g_inputParam[QQ]; a_eff = g_inputParam[aa_eff]; beta = g_inputParam[BB]; Omega = g_inputParam[OMEGA]; shell = g_inputParam[SHELL]; M_star = (Mratio*CONST_Msun/UNIT_MASS); Edd = (2.6e-5*(Lratio)*(1.0/Mratio)); L = (Lratio*L_SUN/UNIT_L); c = 3.0e+5; M_dot = pow(1.0+a_eff,-(1.0/a_eff)) * a_eff * pow(1.0-a_eff,-1)* (L*pow(c,-2))*pow(((Q*Edd)*pow(1.0-Edd,-1)),pow(a_eff,-1)-1.0); ke = ((4.0*CONST_PI*UNIT_G*M_star*c*Edd)/L); Omega2 = pow(Omega,2)*(8.0/27.0)*UNIT_G*M_star; A = ((1.0/(1.0-a))*((ke*L*Q)/(4.0*CONST_PI*c))); Bcgs = g_inputParam[B_CGS]; cs = sqrt(UNIT_kB*T/(mu*(CONST_AH/UNIT_MASS)*CONST_amu)); Bq = Bcgs/UNIT_B; v_esc = sqrt(2.0*UNIT_G*M_star*(1.0-Edd)); v_inf = 3.0*v_esc;//v_esc * sqrt((a/(1.0-a))); #if EOS == IDEAL g_gamma = 1.05; #endif #if EOS == ISOTHERMAL g_isoSoundSpeed = sqrt(UNIT_kB*T/(mu*(CONST_AH/UNIT_MASS)*CONST_amu)); #endif beta *= 0.0174532925; if(side == 0){DOM_LOOP(k,j,i){ r2 = EXPAND(x1[i]*x1[i],+x2[j]*x2[j],+x3[k]*x3[k]); r = sqrt(r2); #if DIMENSIONS == 2 xp = x1[i]*cos(beta) - x2[j]*sin(beta); yp = x1[i]*sin(beta) + x2[j]*cos(beta); #endif #if DIMENSIONS == 3 xp = x1[i]*cos(beta) - x3[k]*sin(beta); yp = x2[j]; zp = x1[i]*sin(beta) + x3[k]*cos(beta); #endif rp2 = EXPAND(xp*xp, + yp*yp, + zp*zp); rp = sqrt(xp*xp + yp*yp + zp*zp); if (r <= 0.5 ) { d->Vc[RHO][k][j][i] = (M_dot/(4.0*CONST_PI*(cs/Cs_p))); #if EOS == IDEAL d->Vc[PRS][k][j][i] = (d->Vc[RHO][k][j][i]*T/(KELVIN*mu)); #endif D_EXPAND(d->Vc[VX1][k][j][i] = 0.0;, d->Vc[VX2][k][j][i] = 0.0;, d->Vc[VX3][k][j][i] = 0.0;) #if PHYSICS == MHD #if BACKGROUND_FIELD == NO #if DIMENSIONS == 2 bx = 0.0; by = 16.0*Bq; bxp = bx*cos(beta) + by*sin(beta); byp = -bx*sin(beta) + by*cos(beta); EXPAND(d->Vc[BX1][k][j][i] = bxp;, d->Vc[BX2][k][j][i] = byp;, d->Vc[BX3][k][j][i] = 0.0;) #endif #if DIMENSIONS == 3 bx = 0.0; by = 0.0; bz = 16.0*Bq; bxp = bx*cos(beta) + bz*sin(beta); byp = by; bzp = -bx*sin(beta) + bz*cos(beta); EXPAND(d->Vc[BX1][k][j][i] = bxp;, d->Vc[BX2][k][j][i] = byp;, d->Vc[BX3][k][j][i] = bzp;) #endif #endif #endif d->flag[k][j][i] |= FLAG_INTERNAL_BOUNDARY; } else if (r > 0.5 && r <= 1.0) { d->Vc[RHO][k][j][i] = (M_dot/(4.0*CONST_PI*(cs/Cs_p))); #if EOS == IDEAL d->Vc[PRS][k][j][i] = (d->Vc[RHO][k][j][i]*T/(KELVIN*mu)); #endif dx = x1[i+1] - x1[i]; dy = x2[j+1] - x2[j]; dz = x3[k+1] - x3[k]; dr2 = EXPAND(dx*dx,+dy*dy,+dz*dz); dr = sqrt(dr2); ddr = 0.9*dr; #if DIMENSIONS == 2 if (r < 1.0 && r + 5.0*ddr > 1.0) { vel_mag = TwoDimensionalInterp(d, box, grid, i, j, k, x1, x2, r, dr); } else { vel_mag = 0.0; } #endif #if DIMENSIONS == 3 if (r < 1.0 && r + 5.0*ddr > 1.0) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, dr); } else { vel_mag = 0.0; } #endif D_EXPAND(d->Vc[VX1][k][j][i] = vel_mag*x1[i]/r;, d->Vc[VX2][k][j][i] = vel_mag*x2[j]/r;, d->Vc[VX3][k][j][i] = vel_mag*x3[k]/r;) #if PHYSICS == MHD #if BACKGROUND_FIELD == NO #if DIMENSIONS == 2 bx = 3.0*xp*yp*Bq*pow(rp,-5); by = (3.0*pow(yp,2)-pow(rp,2))*Bq*pow(rp,-5); bxp = bx*cos(beta) + by*sin(beta); byp = -bx*sin(beta) + by*cos(beta); EXPAND(d->Vc[BX1][k][j][i] = bxp;, d->Vc[BX2][k][j][i] = byp;, d->Vc[BX3][k][j][i] = 0.0;) #endif #if DIMENSIONS == 3 bx = 3.0*xp*zp*Bq*pow(rp,-5); by = 3.0*yp*zp*Bq*pow(rp,-5); bz = (3.0*pow(zp,2)-pow(rp,2))*Bq*pow(rp,-5); bxp = bx*cos(beta) + bz*sin(beta); byp = by; bzp = -bx*sin(beta) + bz*cos(beta); EXPAND(d->Vc[BX1][k][j][i] = bxp;, d->Vc[BX2][k][j][i] = byp;, d->Vc[BX3][k][j][i] = bzp;) #endif #endif #endif d->flag[k][j][i] |= FLAG_INTERNAL_BOUNDARY; } /* - Radiative diriving calculation. - */ if (r > 1.0){ /* - Determine infinitesimal radial distance dr - */ //dr2 = EXPAND(dx1[i]*dx1[i],+dx2[j]*dx2[j],+dx3[k]*dx3[k]); //dr = sqrt(dr2); dx = x1[i+1] - x1[i]; dy = x2[j+1] - x2[j]; dz = x3[k+1] - x3[k]; dr2 = EXPAND(dx*dx,+dy*dy,+dz*dz); dr = sqrt(dr2); for (p = 0; p < 2; p++) { if (p == 0) { ddr = -0.9*dr; } else { ddr = 0.9*dr; } /* - Find nearest nighbours and record coordinates - */ #if DIMENSIONS == 2 vrI[p] = TwoDimensionalInterp(d, box, grid, i, j, k, x1, x2, r, ddr); #endif #if DIMENSIONS == 3 vrI[p] = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); #endif } vr = EXPAND(vx1[k][j][i]*x1[i]/r, + vx2[k][j][i]*x2[j]/r, + vx3[k][j][i]*x3[k]/r); P00 = vrI[0]; P11 = vr; P22 = vrI[1]; P01 = ((0.5*fabs(ddr)*P00)+(0.5*fabs(ddr)*P11))/fabs(ddr); P12 = ((0.5*fabs(ddr)*P11)+(0.5*fabs(ddr)*P22))/fabs(ddr); dvdr = fabs(((1.0/12.0)*P00)-((2.0/3.0)*P01)+((2.0/3.0)*P12) -((1.0/12.0)*P22))/fabs(0.5*ddr); //dvdr = fabs((vrI[1] - vrI[0])/(2.0*ddr)); nu2_c = (1.0-(1.0/(r*r))); B = ((d->Vc[RHO][k][j][i])*Q*c*ke); sigma = (r/fabs(vr))*(dvdr)-1.0; f = ((pow(1.0+sigma,1.0+a)-pow(1.0+sigma*nu2_c,1.0+a))/((1.0+a)*(1.0-nu2_c)*sigma*pow(1.0+sigma,a))); gL = fabs(f*A*pow(r,-2)*pow(dvdr/B,a)); #if AMR_ON == YES #if DIMENSIONS == 3 if (i < 4 || j < 4 || k < 4) { gL = 0.0; } else if (i > IEND-3 || j > JEND-3 || k > KEND-3){ gL = 0.0; } #endif #if DIMENSIONS == 2 if (i < 4 || j < 4) { gL = 0.0; } else if (i > IEND-3 || j > JEND-3){ gL = 0.0; //printf("gl = %f, f = %f, A = %f, r = %f, dvdr = %f, B = %f, a = %f \n", gL, f, A, r, dvdr, B, a); } #endif #endif D_EXPAND(vx1[k][j][i] += (gL*x1[i]/r)*g_dt;, vx2[k][j][i] += (gL*x2[j]/r)*g_dt;, vx3[k][j][i] += (gL*x3[k]/r)*g_dt;) } // end of if r > shell. #if EOS == IDEAL if (d->Vc[PRS][k][j][i] < d->Vc[RHO][k][j][i]*T/(KELVIN*mu)) { d->Vc[PRS][k][j][i] = (d->Vc[RHO][k][j][i]*T/(KELVIN*mu)); } #endif }} // end of DOM loop. } // End of function. #if BODY_FORCE != NO #if CAK == YES void BodyForceVector(double *rubrik, double *v, double *g, double *x_box) { double x1, x2, x3; /* x1 = *x_box[0][1][1][1]; x2 = *x_box[1][1][1][1]; x3 = *x_box[2][1][1][1]; */ #endif #if CAK == NO void BodyForceVector(double *v, double *g, double x1, double x2, double x3) { #endif double M_star, Edd, Omega, Mratio, Lratio; double r2, r, omega_fr, Omega_star; double Fin_x1, Fin_x2, gg, g_in; Mratio = g_inputParam[M_RATIO]; Lratio = g_inputParam[L_RATIO]; Omega = g_inputParam[OMEGA]; M_star = (Mratio*CONST_Msun/UNIT_MASS); Edd = (2.6e-5*(Lratio)*(1.0/Mratio)); Omega_star = Omega*sqrt((8.0/27.0)*UNIT_G*M_star); /* - Rotational frequency (orbit and frame)) - */ omega_fr = Omega_star; /* - Distance from star - */ r2 = EXPAND(x1*x1, + x2*x2, + x3*x3); r = sqrt(r2); /* - Gravity outside bodies - */ gg = -UNIT_G*(M_star - Edd)/r/r; /* - Gravity inside bodies - */ g_in = -(4.0/3.0)*CONST_PI*UNIT_G*v[RHO]; /* - Coriolis and centrifugal forces - */ #if DIMENSIONS == 2 Fin_x1 = omega_fr*omega_fr*x1; Fin_x2 = 0.0; #endif #if DIMENSIONS == 3 Fin_x1 = omega_fr*omega_fr*x1 + 2.0*omega_fr*v[VX2]; Fin_x2 = omega_fr*omega_fr*x2 - 2.0*omega_fr*v[VX1]; #endif if (r >= 1.0){ /* - External gravity + centrifugal + coriolis - */ g[IDIR] = gg*x1/r + Fin_x1; g[JDIR] = gg*x2/r + Fin_x2; g[KDIR] = gg*x3/r; } else if (r < 1.0) { /* - Star interal gravity - */ g[IDIR] = g_in*x1 + Fin_x1; g[JDIR] = g_in*x2 + Fin_x2; g[KDIR] = g_in*x3; } } #endif /*================================================================================*/ double TwoDimensionalInterp(const Data *d, RBox *box, Grid *grid, int i, int j, int k, double *x1, double *x2, double r, double ddr) { /* * _____________________________ * j+1 | | | * | | | * | | * | * | | | * | | | * j |______________|______________| * | | | * | | | * | | | * | | | * | | | * j-1 |______________|______________| * * i - 1 i i + 1 * * * yb 3 4 * |```|`````````| * | | | * yI |___|_________| * | | | * | | | * |___|_________| * ya 1 xI 2 * xa xb * * The interpolation points are always between xa, xb and ya, yb. * * ddr is the distance forwards (backwards) from the point * that the velocity gradient is needed to give the place * to perform the interpolation. * * r -> r±ddr * * |'''''''''''''''''''''''''| * | | * | | * | * r+ddr | * | /| | * | / | | * | / | r+ddr*cos(theta) | * | / | | * | / | | * |/_____|__________________| * r r+ddr*sin(theta) * * xI and yI are the interpolation componets. * */ int u, s; double Ntot; // total volume of interpolation "space". double vrI; // final interpolated radial-velocity. double vI[2]; // interpolated velocity components. double N[4]; // Areas used to waight nearest neighbours (NN). double V[2][4]; // Array to hold velocity componants at NN. double xa, xb; // bracketing x values. double ya, yb; // bracketing y values. double theta = atan2(x1[i],x2[j]); // convert to polar from Cartesian. double xI = (r+ddr)*sin(theta); double yI = (r+ddr)*cos(theta); /* * Eath of the following if statments checks which quadrent * the interpolation point is in and gets the components * of the velocity and the bracketing x and y values. */ if (xI > x1[i] && yI > x2[j]){ xa = x1[i]; xb = x1[i+1]; ya = x2[j]; yb = x2[j+1]; for (u = VX1; u < VX2+1; u++) { V[u-1][0] = d->Vc[u][k][j][i]; V[u-1][1] = d->Vc[u][k][j][i+1]; V[u-1][2] = d->Vc[u][k][j+1][i]; V[u-1][3] = d->Vc[u][k][j+1][i+1]; } } else if (xI < x1[i] && yI > x2[j]){ xa = x1[i-1]; xb = x1[i]; ya = x2[j]; yb = x2[j+1]; for (u = VX1; u < VX2+1; u++) { V[u-1][0] = d->Vc[u][k][j][i-1]; V[u-1][1] = d->Vc[u][k][j][i]; V[u-1][2] = d->Vc[u][k][j+1][i-1]; V[u-1][3] = d->Vc[u][k][j+1][i]; } } else if (xI < x1[i] && yI < x2[j]){ xa = x1[i-1]; xb = x1[i]; ya = x2[j-1]; yb = x2[j]; for (u = VX1; u < VX2+1; u++) { V[u-1][0] = d->Vc[u][k][j-1][i-1]; V[u-1][1] = d->Vc[u][k][j-1][i]; V[u-1][2] = d->Vc[u][k][j][i-1]; V[u-1][3] = d->Vc[u][k][j][i]; } } else if (xI > x1[i] && yI < x2[j]){ xa = x1[i]; xb = x1[i+1]; ya = x2[j-1]; yb = x2[j]; for (u = VX1; u < VX2+1; u++) { V[u-1][0] = d->Vc[u][k][j-1][i]; V[u-1][1] = d->Vc[u][k][j-1][i+1]; V[u-1][2] = d->Vc[u][k][j][i]; V[u-1][3] = d->Vc[u][k][j][i+1]; } } // Find total volume. N[0] = (xb - xI)*(yb - yI); N[1] = (xI - xa)*(yb - yI); N[2] = (xb - xI)*(yI - ya); N[3] = (xI - xa)*(yI - ya); Ntot = N[0] + N[1] + N[2] + N[3]; // Normalise volumes by total. N[0] /= Ntot; N[1] /= Ntot; N[2] /= Ntot; N[3] /= Ntot; // ========================================== // vI contains the interpolated velovities // // vI[0] = x velocity // vI[1] = y " // // V contains the velocity componants at // each of the sample points. // // V[0, :] = x velocity at each sample point. // V[1, :] = y velocity at each sample point. // // N contains the waighting volumes for the // the corner velocities. // ========================================== vI[0] = 0.0; vI[1] = 0.0; for (s = 0; s < 4; s++) { vI[0] += V[0][s]*N[s]; vI[1] += V[1][s]*N[s]; } vrI = (vI[0]*x1[i] + vI[1]*x2[j])/r; return vrI; } double ThreeDimensionalInterp(const Data *d, RBox *box, Grid *grid, int i, int j, int k, double *x1, double *x2, double *x3, double r, double ddr) { int u, s; double Ntot; double vrI; double vI[3]; double N[8]; double V[3][8]; double xa, xb; double ya, yb; double za, zb; double phi = atan2(x2[j],x1[i]); double theta = acos(x3[k]/r); double xI = (r+ddr)*sin(theta)*cos(phi); double yI = (r+ddr)*sin(theta)*sin(phi); double zI = (r+ddr)*cos(theta); int tag_if; if (xI > x1[i] && yI > x2[j] && zI > x3[k]){ tag_if = 1; xa = x1[i]; xb = x1[i+1]; ya = x2[j]; yb = x2[j+1]; za = x3[k]; zb = x3[k+1]; for (u = VX1; u < VX3+1; u++) { V[u-1][0] = d->Vc[u][k][j][i]; V[u-1][1] = d->Vc[u][k][j][i+1]; V[u-1][2] = d->Vc[u][k][j+1][i]; V[u-1][3] = d->Vc[u][k][j+1][i+1]; V[u-1][4] = d->Vc[u][k+1][j][i]; V[u-1][5] = d->Vc[u][k+1][j][i+1]; V[u-1][6] = d->Vc[u][k+1][j+1][i]; V[u-1][7] = d->Vc[u][k+1][j+1][i+1]; } } if (xI < x1[i] && yI > x2[j] && zI > x3[k]){ tag_if = 2; xa = x1[i-1]; xb = x1[i]; ya = x2[j]; yb = x2[j+1]; za = x3[k]; zb = x3[k+1]; for (u = VX1; u < VX3+1; u++) { V[u-1][0] = d->Vc[u][k][j][i-1]; V[u-1][1] = d->Vc[u][k][j][i]; V[u-1][2] = d->Vc[u][k][j+1][i-1]; V[u-1][3] = d->Vc[u][k][j+1][i]; V[u-1][4] = d->Vc[u][k+1][j][i-1]; V[u-1][5] = d->Vc[u][k+1][j][i]; V[u-1][6] = d->Vc[u][k+1][j+1][i-1]; V[u-1][7] = d->Vc[u][k+1][j+1][i]; } } if (xI > x1[i] && yI < x2[j] && zI > x3[k]){ tag_if = 3; xa = x1[i]; xb = x1[i+1]; ya = x2[j-1]; yb = x2[j]; za = x3[k]; zb = x3[k+1]; for (u = VX1; u < VX3+1; u++) { V[u-1][0] = d->Vc[u][k][j-1][i]; V[u-1][1] = d->Vc[u][k][j-1][i+1]; V[u-1][2] = d->Vc[u][k][j][i]; V[u-1][3] = d->Vc[u][k][j][i+1]; V[u-1][4] = d->Vc[u][k+1][j-1][i]; V[u-1][5] = d->Vc[u][k+1][j-1][i+1]; V[u-1][6] = d->Vc[u][k+1][j][i]; V[u-1][7] = d->Vc[u][k+1][j][i+1]; } } if (xI < x1[i] && yI < x2[j] && zI > x3[k]){ tag_if = 4; xa = x1[i-1]; xb = x1[i]; ya = x2[j-1]; yb = x2[j]; za = x3[k]; zb = x3[k+1]; for (u = VX1; u < VX3+1; u++) { V[u-1][0] = d->Vc[u][k][j-1][i-1]; V[u-1][1] = d->Vc[u][k][j-1][i]; V[u-1][2] = d->Vc[u][k][j][i-1]; V[u-1][3] = d->Vc[u][k][j][i]; V[u-1][4] = d->Vc[u][k+1][j-1][i-1]; V[u-1][5] = d->Vc[u][k+1][j-1][i]; V[u-1][6] = d->Vc[u][k+1][j][i-1]; V[u-1][7] = d->Vc[u][k+1][j][i]; } } // zI < zP if (xI > x1[i] && yI > x2[j] && zI < x3[k]){ tag_if = 5; xa = x1[i]; xb = x1[i+1]; ya = x2[j]; yb = x2[j+1]; za = x3[k-1]; zb = x3[k]; for (u = VX1; u < VX3+1; u++) { V[u-1][0] = d->Vc[u][k-1][j][i]; V[u-1][1] = d->Vc[u][k-1][j][i+1]; V[u-1][2] = d->Vc[u][k-1][j+1][i]; V[u-1][3] = d->Vc[u][k-1][j+1][i+1]; V[u-1][4] = d->Vc[u][k][j][i]; V[u-1][5] = d->Vc[u][k][j][i+1]; V[u-1][6] = d->Vc[u][k][j+1][i]; V[u-1][7] = d->Vc[u][k][j+1][i+1]; } } if (xI < x1[i] && yI > x2[j] && zI < x3[k]){ tag_if = 6; xa = x1[i-1]; xb = x1[i]; ya = x2[j]; yb = x2[j+1]; za = x3[k-1]; zb = x3[k]; for (u = VX1; u < VX3+1; u++) { V[u-1][0] = d->Vc[u][k-1][j][i-1]; V[u-1][1] = d->Vc[u][k-1][j][i]; V[u-1][2] = d->Vc[u][k-1][j+1][i-1]; V[u-1][3] = d->Vc[u][k-1][j+1][i]; V[u-1][4] = d->Vc[u][k][j][i-1]; V[u-1][5] = d->Vc[u][k][j][i]; V[u-1][6] = d->Vc[u][k][j+1][i-1]; V[u-1][7] = d->Vc[u][k][j+1][i]; } } if (xI > x2[i] && yI < x2[j] && zI < x3[k]){ tag_if = 7; xa = x1[i]; xb = x1[i+1]; ya = x2[j-1]; yb = x2[j]; za = x3[k-1]; zb = x3[k]; for (u = VX1; u < VX3+1; u++) { V[u-1][0] = d->Vc[u][k-1][j-1][i]; V[u-1][1] = d->Vc[u][k-1][j-1][i+1]; V[u-1][2] = d->Vc[u][k-1][j][i]; V[u-1][3] = d->Vc[u][k-1][j][i+1]; V[u-1][4] = d->Vc[u][k][j-1][i]; V[u-1][5] = d->Vc[u][k][j-1][i+1]; V[u-1][6] = d->Vc[u][k][j][i]; V[u-1][7] = d->Vc[u][k][j][i+1]; } } if (xI < x1[i] && yI < x2[j] && zI < x3[k]){ tag_if = 8; xa = x1[i-1]; xb = x1[i]; ya = x2[j-1]; yb = x2[j]; za = x3[k-1]; zb = x3[k]; for (u = VX1; u < VX3+1; u++) { V[u-1][0] = d->Vc[u][k-1][j-1][i-1]; V[u-1][1] = d->Vc[u][k-1][j-1][i]; V[u-1][2] = d->Vc[u][k-1][j][i-1]; V[u-1][3] = d->Vc[u][k-1][j][i]; V[u-1][4] = d->Vc[u][k][j-1][i-1]; V[u-1][5] = d->Vc[u][k][j-1][i]; V[u-1][6] = d->Vc[u][k][j][i-1]; V[u-1][7] = d->Vc[u][k][j][i]; } } // Find total volume. N[0] = (xb - xI)*(yb - yI)*(zb - zI); N[1] = (xI - xa)*(yb - yI)*(zb - zI); N[2] = (xb - xI)*(yI - ya)*(zb - zI); N[3] = (xI - xa)*(yI - ya)*(zb - zI); N[4] = (xb - xI)*(yb - yI)*(zI - za); N[5] = (xI - xa)*(yb - yI)*(zI - za); N[6] = (xb - xI)*(yI - ya)*(zI - za); N[7] = (xI - xa)*(yI - ya)*(zI - za); Ntot = N[0] + N[1] + N[2] + N[3] + N[4] + N[5] + N[6] + N[7]; // Normalise volumes by total. N[0] /= Ntot; N[1] /= Ntot; N[2] /= Ntot; N[3] /= Ntot; N[4] /= Ntot; N[5] /= Ntot; N[6] /= Ntot; N[7] /= Ntot; // ========================================== // vI contains the interpolated velovities // // vI[0] = x velocity // vI[1] = y " // vI[2] = z " // // V contains the velocity componants at // each of the sample points. // // V[0][:] = x velocity at each sample point. // V[1][:] = y velocity at each sample point. // V[2][:] = z velocity at each sample point. // // N contains the waighting volumes for the // the corner velocities. // ========================================== vI[0] = 0.0; vI[1] = 0.0; vI[2] = 0.0; for (s = 0; s < 8; s++) { vI[0] += V[0][s]*N[s]; vI[1] += V[1][s]*N[s]; vI[2] += V[2][s]*N[s]; } vrI = (vI[0]*x1[i] + vI[1]*x2[j] + vI[2]*x3[k])/r; if(isnan(vrI)){ printf("tag_if=%i \n",tag_if); printf("vrI=%f, vI[0]=%f, vI[1]=%f, vI[2]=%f Ntot=%f \n",vrI,vI[0],vI[1],vI[2],Ntot); printf("N0=%f, N1=%f, N2=%f, N3=%f, N4=%f, N5=%f, N6=%f, N7=%f \n",N[0], N[1], N[2], N[3], N[4], N[5], N[6], N[7]); printf("xa=%f, xI=%f, xb=%f \n", xa, xI, xb); printf("ya=%f, yI=%f, yb=%f \n", ya, yI, yb); printf("za=%f, zI=%f, zb=%f \n", za, zI, zb); printf("\n"); } return vrI; } double VelocityStellarSurface2D(const Data *d, RBox *box, Grid *grid, int i, int j, int k, double *x1, double *x2, double *x3, double r){ int l; double vel_x1, vel_x2, vel_x3; double r_testx, r_testy, r_testz, vel_mag; double dx, dy, dz, dr2, dr, ddr; dx = x1[i+1] - x1[i]; dy = x2[j+1] - x2[j]; dr2 = EXPAND(dx*dx,+dy*dy,+dz*dz); dr = sqrt(dr2); ddr = 0.9*dr; if (r < 1.0 && r + ddr > 1.0) { vel_mag = TwoDimensionalInterp(d, box, grid, i, j, k, x1, x2, r, ddr); } for (l=1; l<2; l++){ // Upper right. if (x1[i] > 0.0 && x2[j] > 0.0) { r_testx = D_EXPAND(x1[i+l]*x1[i+l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j+l]*x2[j+l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0)) { vel_mag = TwoDimensionalInterp(d, box, grid, i, j, k, x1, x2, r, ddr); } /* if (r < 1.0 && r_testx > 1.0 && r_testy > 1.0) { // these are the cells at the boundary. D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i+l];, vel_x2 = d->Vc[VX2][k][j+l][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } else if (r < 1.0 && r_testx < 1.0 && r_testy > 1.0) { D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i];, vel_x2 = d->Vc[VX2][k][j+l][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } else if (r < 1.0 && r_testx > 1.0 && r_testy < 1.0) { D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i+l];, vel_x2 = d->Vc[VX2][k][j][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } */ } // Lower right. else if (x1[i] > 0.0 && x2[j] < 0.0) { r_testx = D_EXPAND(x1[i+l]*x1[i+l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j-l]*x2[j-l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0)) { vel_mag = TwoDimensionalInterp(d, box, grid, i, j, k, x1, x2, r, ddr); } /* if (r < 1.0 && r_testx > 1.0 && r_testy > 1.0) { // these are the cells at the boundary. D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i+l];, vel_x2 = d->Vc[VX2][k][j-l][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } else if (r < 1.0 && r_testx < 1.0 && r_testy > 1.0) { D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i];, vel_x2 = d->Vc[VX2][k][j-l][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } else if (r < 1.0 && r_testx > 1.0 && r_testy < 1.0) { D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i+l];, vel_x2 = d->Vc[VX2][k][j][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } */ } // lower left. else if (x1[i] < 0.0 && x2[j] < 0.0) { r_testx = D_EXPAND(x1[i-l]*x1[i-l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j-l]*x2[j-l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0)) { vel_mag = TwoDimensionalInterp(d, box, grid, i, j, k, x1, x2, r, ddr); } /* if (r < 1.0 && r_testx > 1.0 && r_testy > 1.0) { // these are the cells at the boundary. D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i-l];, vel_x2 = d->Vc[VX2][k][j-l][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } else if (r < 1.0 && r_testx < 1.0 && r_testy > 1.0) { D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i];, vel_x2 = d->Vc[VX2][k][j-l][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } else if (r < 1.0 && r_testx > 1.0 && r_testy < 1.0) { D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i-l];, vel_x2 = d->Vc[VX2][k][j][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } */ } // Upper left. else if (x1[i] < 0.0 && x2[j] > 0.0) { r_testx = D_EXPAND(x1[i-l]*x1[i-l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j+l]*x2[j+l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0)) { vel_mag = TwoDimensionalInterp(d, box, grid, i, j, k, x1, x2, r, ddr); } /* if (r < 1.0 && r_testx > 1.0 && r_testy > 1.0) { // these are the cells at the boundary. D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i-l];, vel_x2 = d->Vc[VX2][k][j+l][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } else if (r < 1.0 && r_testx < 1.0 && r_testy > 1.0) { D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i];, vel_x2 = d->Vc[VX2][k][j+l][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } else if (r < 1.0 && r_testx > 1.0 && r_testy < 1.0) { D_EXPAND(vel_x1 = d->Vc[VX1][k][j][i-l];, vel_x2 = d->Vc[VX2][k][j][i];, vel_x3 = d->Vc[VX3][k][j][i];) vel_mag = sqrt(vel_x1*vel_x1 + vel_x2*vel_x2); } */ } } return fabs(vel_mag); } double VelocityStellarSurface3D(const Data *d, RBox *box, Grid *grid, int i, int j, int k, double *x1, double *x2, double *x3, double r){ int l; double vel_x1, vel_x2, vel_x3; double r_testx, r_testy, r_testz, vel_mag; double dx, dy, dz, dr2, dr, ddr; dx = x1[i+1] - x1[i]; dy = x2[j+1] - x2[j]; dz = x3[k+1] - x3[k]; dr2 = EXPAND(dx*dx,+dy*dy,+dz*dz); dr = sqrt(dr2); ddr = 0.9*dr; for (l=1; l<2; l++){ // Top of sphere. if (x1[i] > 0.0 && x2[j] > 0.0 && x3[k] > 0.0) { r_testx = D_EXPAND(x1[i+l]*x1[i+l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j+l]*x2[j+l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); r_testz = D_EXPAND(x1[i]*x1[i], + x2[j]*x2[j], + x3[k+l]*x3[k+l]); r_testz = sqrt(r_testz); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0 || r_testz > 1.0)) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); } } else if (x1[i] > 0.0 && x2[j] < 0.0 && x3[k] > 0.0) { r_testx = D_EXPAND(x1[i+l]*x1[i+l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j-l]*x2[j-l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); r_testz = D_EXPAND(x1[i]*x1[i], + x2[j]*x2[j], + x3[k+l]*x3[k+l]); r_testz = sqrt(r_testz); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0 || r_testz > 1.0)) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); } } else if (x1[i] < 0.0 && x2[j] < 0.0 && x3[k] > 0.0) { r_testx = D_EXPAND(x1[i-l]*x1[i-l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j-l]*x2[j-l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); r_testz = D_EXPAND(x1[i]*x1[i], + x2[j]*x2[j], + x3[k+l]*x3[k+l]); r_testz = sqrt(r_testz); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0 || r_testz > 1.0)) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); } } else if (x1[i] < 0.0 && x2[j] > 0.0 && x3[k] > 0.0) { r_testx = D_EXPAND(x1[i-l]*x1[i-l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j+l]*x2[j+l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); r_testz = D_EXPAND(x1[i]*x1[i], + x2[j]*x2[j], + x3[k+l]*x3[k+l]); r_testz = sqrt(r_testz); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0 || r_testz > 1.0)) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); } } // Bottom of sphere. if (x1[i] > 0.0 && x2[j] > 0.0 && x3[k] < 0.0) { r_testx = D_EXPAND(x1[i+l]*x1[i+l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j+l]*x2[j+l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); r_testz = D_EXPAND(x1[i]*x1[i], + x2[j]*x2[j], + x3[k-l]*x3[k-l]); r_testz = sqrt(r_testz); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0 || r_testz > 1.0)) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); } } else if (x1[i] > 0.0 && x2[j] < 0.0 && x3[k] < 0.0) { r_testx = D_EXPAND(x1[i+l]*x1[i+l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j-l]*x2[j-l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); r_testz = D_EXPAND(x1[i]*x1[i], + x2[j]*x2[j], + x3[k-l]*x3[k-l]); r_testz = sqrt(r_testz); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0 || r_testz > 1.0)) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); } } else if (x1[i] < 0.0 && x2[j] < 0.0 && x3[k] < 0.0) { r_testx = D_EXPAND(x1[i-l]*x1[i-l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j-l]*x2[j-l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); r_testz = D_EXPAND(x1[i]*x1[i], + x2[j]*x2[j], + x3[k-l]*x3[k-l]); r_testz = sqrt(r_testz); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0 || r_testz > 1.0)) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); } } else if (x1[i] < 0.0 && x2[j] > 0.0 && x3[k] < 0.0) { r_testx = D_EXPAND(x1[i-l]*x1[i-l], + x2[j]*x2[j], + x3[k]*x3[k]); r_testx = sqrt(r_testx); r_testy = D_EXPAND(x1[i]*x1[i], + x2[j+l]*x2[j+l], + x3[k]*x3[k]); r_testy = sqrt(r_testy); r_testz = D_EXPAND(x1[i]*x1[i], + x2[j]*x2[j], + x3[k-l]*x3[k-l]); r_testz = sqrt(r_testz); if (r < 1.0 && (r_testx > 1.0 || r_testy > 1.0 || r_testz > 1.0)) { vel_mag = ThreeDimensionalInterp(d, box, grid, i, j, k, x1, x2, x3, r, ddr); } } } return vel_mag; }
32.959747
122
0.423707
[ "model", "3d" ]
47b65d343fcb09c4aa668f3a984ed99874dd2abc
2,980
c
C
ext/phalcon/mvc/model/messageinterface.zep.c
mruz/cphalcon
b2f58499cff762c70fcbd67b97585ff1e55b6f0f
[ "BSD-3-Clause" ]
null
null
null
ext/phalcon/mvc/model/messageinterface.zep.c
mruz/cphalcon
b2f58499cff762c70fcbd67b97585ff1e55b6f0f
[ "BSD-3-Clause" ]
null
null
null
ext/phalcon/mvc/model/messageinterface.zep.c
mruz/cphalcon
b2f58499cff762c70fcbd67b97585ff1e55b6f0f
[ "BSD-3-Clause" ]
null
null
null
#ifdef HAVE_CONFIG_H #include "../../../ext_config.h" #endif #include <php.h> #include "../../../php_ext.h" #include "../../../ext.h" #include <Zend/zend_exceptions.h> #include "kernel/main.h" /* +------------------------------------------------------------------------+ | Phalcon Framework | +------------------------------------------------------------------------+ | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com) | +------------------------------------------------------------------------+ | This source file is subject to the New BSD License that is bundled | | with this package in the file docs/LICENSE.txt. | | | | If you did not receive a copy of the license and are unable to | | obtain it through the world-wide-web, please send an email | | to license@phalconphp.com so we can send you a copy immediately. | +------------------------------------------------------------------------+ | Authors: Andres Gutierrez <andres@phalconphp.com> | | Eduar Carvajal <eduar@phalconphp.com> | +------------------------------------------------------------------------+ */ /** * Phalcon\Mvc\Model\Message * * Interface for Phalcon\Mvc\Model\Message */ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MessageInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, MessageInterface, phalcon, mvc_model_messageinterface, phalcon_mvc_model_messageinterface_method_entry); return SUCCESS; } /** * Phalcon\Mvc\Model\Message constructor * * @param string message * @param string field * @param string type */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, __construct); /** * Sets message type * * @param string type */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, setType); /** * Returns message type * * @return string */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, getType); /** * Sets verbose message * * @param string message */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, setMessage); /** * Returns verbose message * * @return string */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, getMessage); /** * Sets field name related to message * * @param string field */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, setField); /** * Returns field name related to message * * @return string */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, getField); /** * Magic __toString method returns verbose message * * @return string */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, __toString); /** * Magic __set_state helps to recover messsages from serialization * * @param array message * @return Phalcon\Mvc\Model\MessageInterface */ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, __set_state);
26.846847
152
0.59094
[ "model" ]
47b90c8b496c22f900b645ec09da9550569e33ca
2,798
h
C
Resources/CoreStructures/ShaderLoader.h
jSplunk/Village-Cycle
540b06d85feff0d831e8247473e5cf4d8beccbc8
[ "Apache-2.0" ]
1
2020-11-15T04:32:25.000Z
2020-11-15T04:32:25.000Z
Resources/CoreStructures/ShaderLoader.h
jSplunk/Village-Cycle
540b06d85feff0d831e8247473e5cf4d8beccbc8
[ "Apache-2.0" ]
null
null
null
Resources/CoreStructures/ShaderLoader.h
jSplunk/Village-Cycle
540b06d85feff0d831e8247473e5cf4d8beccbc8
[ "Apache-2.0" ]
1
2021-05-03T05:14:33.000Z
2021-05-03T05:14:33.000Z
// ShaderLoader.h - Methods to load and compile OpenGL shaders #ifndef SHADER_LOADER_H #define SHADER_LOADER_H #include <string> #include <glad/glad.h> // Declare GLSL setup return / error codes typedef enum GLSL_ERROR_CODES { GLSL_OK = 0, GLSL_VERTEX_SHADER_REQUIRED_ERROR, // returned if a geometry shader but no vertex shader is defined GLSL_SHADER_SOURCE_NOT_FOUND, // shader source string not found GLSL_SHADER_OBJECT_CREATION_ERROR, // shader object cannot be created by OpenGL GLSL_SHADER_COMPILE_ERROR, // shader object could not be compiled GLSL_VERTEX_SHADER_SOURCE_NOT_FOUND, GLSL_TESSELLATION_CONTROL_SHADER_SOURCE_NOT_FOUND, GLSL_TESSELLATION_EVALUATION_SHADER_SOURCE_NOT_FOUND, GLSL_GEOMETRY_SHADER_SOURCE_NOT_FOUND, GLSL_FRAGMENT_SHADER_SOURCE_NOT_FOUND, GLSL_VERTEX_SHADER_OBJECT_CREATION_ERROR, GLSL_TESSELLATION_CONTROL_SHADER_OBJECT_CREATION_ERROR, GLSL_TESSELLATION_EVALUATION_SHADER_OBJECT_CREATION_ERROR, GLSL_GEOMETRY_SHADER_OBJECT_CREATION_ERROR, GLSL_FRAGMENT_SHADER_OBJECT_CREATION_ERROR, GLSL_VERTEX_SHADER_COMPILE_ERROR, GLSL_TESSELLATION_CONTROL_SHADER_COMPILE_ERROR, GLSL_TESSELLATION_EVALUATION_SHADER_COMPILE_ERROR, GLSL_GEOMETRY_SHADER_COMPILE_ERROR, GLSL_FRAGMENT_SHADER_COMPILE_ERROR, GLSL_PROGRAM_OBJECT_CREATION_ERROR, GLSL_PROGRAM_OBJECT_LINK_ERROR } GLSL_ERROR; class ShaderLoader{ public: // Basic shader object creation function takes a path to a vertex shader file and fragment shader file and returns a bound and linked shader program object in *result. No attribute bindings are specified in this function so it is assumed 'in' variable declarations have associated location declarations in the shader source file static GLSL_ERROR createShaderProgram(const std::string& vsPath, const std::string& fsPath, GLuint *result); // Overload of createShaderProgram that allows vertex attribute locations to be declared in C/C++ and bound during shader creation. This avoids the need to specify the layout in the vertex shader 'in' variable declarations, but this is not as convinient! static GLSL_ERROR createShaderProgram(const std::string& vsPath, const std::string& fsPath, GLuint *result, int numAttributes, ...); // Overloaded version of createShaderProgram that takes a geometry shader filename as well as a vertex and fragment shader filename static GLSL_ERROR createShaderProgram(const std::string& vsPath, const std::string& gsPath, const std::string& fsPath, GLuint *result); // Overloaded version of createShaderProgram that takes a tessellation control and evaluation shader as well as a vertex and fragment shader filename static GLSL_ERROR createShaderProgram(const std::string& vsPath, const std::string& tcsPath, const std::string& tesPath, const std::string& fsPath, GLuint *result); }; #endif
46.633333
330
0.831665
[ "geometry", "object" ]
47bbc6582427b1331195e11a5b3c8230c19e80d9
9,191
h
C
include/o3d3xx/image.h
sgieseking/libo3d3xx
18abf3b7d38fff771cf42b40b44a17868e787a04
[ "Apache-2.0" ]
null
null
null
include/o3d3xx/image.h
sgieseking/libo3d3xx
18abf3b7d38fff771cf42b40b44a17868e787a04
[ "Apache-2.0" ]
null
null
null
include/o3d3xx/image.h
sgieseking/libo3d3xx
18abf3b7d38fff771cf42b40b44a17868e787a04
[ "Apache-2.0" ]
null
null
null
// -*- c++ -*- /* * Copyright (C) 2014 Love Park Robotics, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distribted on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __O3D3XX_IMAGE_H__ #define __O3D3XX_IMAGE_H__ #include <cstddef> #include <cstdint> #include <memory> #include <vector> #include <opencv2/core/core.hpp> #include <pcl/point_cloud.h> #include <pcl/point_types.h> namespace o3d3xx { using PointT = pcl::PointXYZI; extern const std::size_t IMG_TICKET_SZ; // bytes enum class pixel_format : std::uint8_t { FORMAT_8U = 0, FORMAT_8S = 1, FORMAT_16U = 2, FORMAT_16S = 3, FORMAT_32U = 4, FORMAT_32S = 5, FORMAT_32F = 6, FORMAT_64U = 7, FORMAT_64F = 8, FORMAT_16U2 = 9, FORMAT_32F3 = 10 }; enum class image_chunk : std::uint32_t { USERDATA = 0, RADIAL_DISTANCE = 100, AMPLITUDE = 101, // normalized amplitude RAW_AMPLITUDE = 103, CARTESIAN_X = 200, CARTESIAN_Y = 201, CARTESIAN_Z = 202, CARTESIAN_ALL = 203, UNIT_VECTOR_E1 = 220, UNIT_VECTOR_E2 = 221, UNIT_VECTOR_E3 = 222, UNIT_VECTOR_ALL = 223, CONFIDENCE = 300, DIAGNOSTIC_DATA = 302, EXTRINSIC_CALIBRATION = 400, JSON_MODEL = 500, SNAPSHOT_IMAGE = 600 }; /** * The ImageBuffer class is used to hold time synchronized images from the * camera. That is, to hold image data from a single buffer read off the * wire but organized into its component parts. * * NOTE: The ImageBuffer class is NOT thread safe! */ class ImageBuffer { public: using Ptr = std::shared_ptr<ImageBuffer>; /** * Allocates space for the individual component images */ ImageBuffer(); /** * RAII deallocations */ virtual ~ImageBuffer(); // disable move semantics (for now) ImageBuffer(ImageBuffer&&) = delete; ImageBuffer& operator=(ImageBuffer&&) = delete; // copy ctor/assignment operator ImageBuffer(const ImageBuffer& src_buff); ImageBuffer& operator=(const ImageBuffer& src_buff); /** * Returns the wrapped depth image. This does NOT make a copy of the data. * * NOTE: Since the depth image is a cv::Mat the correct thing to do here is * to return by value as cv::Mat does it's own memory management / * reference counting. */ cv::Mat DepthImage(); /** * Returns the wrapped amplitude image. This does NOT make a copy of the * data. * * It should be noted that this is the normalized (wrt, exposure time) * amplitude image. * * NOTE: Since the amplitude image is a cv::Mat the correct thing to do * here is to return by value as cv::Mat does it's own memory management / * reference counting. */ cv::Mat AmplitudeImage(); /** * Returns the wrapped (raw) amplitude image. This does NOT make a copy of * the data. * * It should be noted that this is the raw amplitude image. Per the IFM * docs: "In double exposure mode, the lack of normalization my lead * (depending on the chosen exposure times) to inhomogeneous amplitude * impression, if a certain pixel is taken from the short exposure time and * some of its neighbors are not." * * NOTE: Since the amplitude image is a cv::Mat the correct thing to do * here is to return by value as cv::Mat does it's own memory management / * reference counting. */ cv::Mat RawAmplitudeImage(); /** * Returns the wrapped confidence image. This does NOT make a copy of the * data. * * NOTE: Since the confidence image is a cv::Mat the correct thing to do * here is to return by value as cv::Mat does it's own memory management / * reference counting. */ cv::Mat ConfidenceImage(); /** * Returns the wrapped xyz_image. * * The xyz_image is a 3-channel OpenCV image encoding of the point cloud * where the three channels are spatial planes (x, y, z) as opposed to * color planes. It should be noted that while this encoding of the point * cloud contains the same data as the PCL encoded point cloud (for the * cartesian components) the data are kept in mm (as opposed to meters) and * the data types are int16_t as opposed to float. However, the coord frame * for this point cloud data is consistent with the PCL point cloud. */ cv::Mat XYZImage(); /** * Returns the shared pointer to the wrapped point cloud */ pcl::PointCloud<o3d3xx::PointT>::Ptr Cloud(); /** * Returns (a copy of) the underlying byte buffer read from the camera. */ std::vector<std::uint8_t> Bytes(); /** * Returns the state of the `dirty' flag */ bool Dirty() const noexcept; /** * Synchronizes the parsed out image data with the internally wrapped byte * buffer. This call has been separated out from `SetBytes' in order to * minimize mutex contention with the frame grabbers main thread. */ void Organize(); /** * Sets the data from the passed in `buff' to the internally wrapped byte * buffer. This function assumes the passed in `buff' is a valid byte * buffer from the camera. * * By default (see `copy' parameter below) this function will take in * `buff' and `swap' contents with its internal buffer so that the * operation is O(1). If you want copy behavior specify the copy flag and * complexity will be linear in the size of the byte buffer. * * @see o3d3xx::verify_image_buffer * * @param[in] buff Raw data bytes to copy to internal buffers * * @param[in] copy If true the data are copied from `buff' to the * internally wrapped buffer and `buff' will remain unchanged. */ void SetBytes(std::vector<std::uint8_t>& buff, bool copy = false); private: /** * Flag used to indicate if the wrapped byte buffer and the individual * component images are in sync. */ bool dirty_; /** * Raw bytes read off the wire from the camera */ std::vector<std::uint8_t> bytes_; /** * Point cloud used to hold the cartesian xyz and amplitude data (intensity * channel). * * NOTE: Data in the point cloud are converted to meters and utilize a * right-handed coordinate frame. */ pcl::PointCloud<o3d3xx::PointT>::Ptr cloud_; /** * OpenCV image encoding of the radial image data * * NOTE: Unlike the point cloude, the data in the depth image remain in * millimeters. */ cv::Mat depth_; /** * OpenCV image encoding of the normalized amplitude data */ cv::Mat amp_; /** * OpenCV image encoding of the raw amplitude data */ cv::Mat raw_amp_; /** * OpenCV image encoding of the confidence data */ cv::Mat conf_; /** * OpenCV image encoding of the point cloud */ cv::Mat xyz_image_; /** * Mutates the `dirty' flag */ void _SetDirty(bool flg) noexcept; }; // end: class ImageBuffer /** * Verifies that the passed in buffer contains a valid "ticket" from the * sensor. * * @return true if the ticket buffer is valid */ bool verify_ticket_buffer(const std::vector<std::uint8_t>& buff); /** * Verifies that the passed in image buffer is valid. * * @return true if the image buffer is valid */ bool verify_image_buffer(const std::vector<std::uint8_t>& buff); /** * Extracts the image buffer size from a ticket buffer received from the * sensor. * * NOTE: The size of the passed in buffer is not checked here. It is assumed * that this buffer has already passed the `verify_ticket_buffer' check. An * exception may be thrown if an inappropriately sized buffer is passed in to * this function. * * @param[in] buff A ticket buffer * * @return The expected size of the image buffer. */ std::size_t get_image_buffer_size(const std::vector<std::uint8_t>& buff); /** * Finds the index into the image buffer of where the chunk of `chunk_type' * begins. * * @param[in] buff The image buffer to search * @param[in] chunk_type The type of chunk to look for * * @return The index into the buffer of where the chunk begins. * @throw o3d3xx::error_t If the chunk is not found */ std::size_t get_chunk_index(const std::vector<std::uint8_t>& buff, o3d3xx::image_chunk chunk_type); /** * Returns the number of bytes contained in the passed in pixel format. */ std::size_t get_num_bytes_in_pixel_format(o3d3xx::pixel_format f); } // end: namespace o3d3xx #endif // __O3D3XX_IMAGE_H__
29.840909
79
0.653248
[ "vector" ]
47bf42e6e389b5559d214d6d6951760597884a24
2,962
h
C
syn/core/cntptr.h
asmwarrior/syncpp
df34b95b308d7f2e6479087d629017efa7ab9f1f
[ "Apache-2.0" ]
1
2019-02-08T02:23:56.000Z
2019-02-08T02:23:56.000Z
syn/core/cntptr.h
asmwarrior/syncpp
df34b95b308d7f2e6479087d629017efa7ab9f1f
[ "Apache-2.0" ]
null
null
null
syn/core/cntptr.h
asmwarrior/syncpp
df34b95b308d7f2e6479087d629017efa7ab9f1f
[ "Apache-2.0" ]
1
2020-12-02T02:37:40.000Z
2020-12-02T02:37:40.000Z
/* * Copyright 2014 Anton Karmanov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //Fast and simple reference-counting smart pointer. #ifndef SYN_CORE_CNTPTR_H_INCLUDED #define SYN_CORE_CNTPTR_H_INCLUDED #include <cstddef> #include <iostream> #include "noncopyable.h" namespace synbin { template<class T> class CntPtr; // //RefCnt // //Contains the reference counter. Any class must derive from RefCnt in order to be used with CntPtr. class RefCnt { NONCOPYABLE(RefCnt); template<class T> friend class CntPtr; mutable std::size_t m_ref_cnt; protected: RefCnt() : m_ref_cnt(0){} }; // //CntPtr // //Reference-counting pointer. //1. Any class used with this pointer must be derived from RefCnt. //2. Not thread-safe. To be used in a single thread code. template<class T> class CntPtr { template<class P> friend class CntPtr; T* m_object; inline const RefCnt* chktype(){ return m_object; } inline void add_object() { if (m_object) ++m_object->m_ref_cnt; } inline void remove_object() { if (m_object) { if (!--m_object->m_ref_cnt) delete m_object; } } inline void change_object(T* object) { remove_object(); m_object = object; add_object(); } public: CntPtr(const CntPtr& ptr) : m_object(ptr.m_object){ chktype(); add_object(); } CntPtr(CntPtr&& ptr) : m_object(ptr.m_object){ ptr.m_object = nullptr; } CntPtr() : m_object(nullptr){} CntPtr(T* object) : m_object(object){ chktype(); add_object(); } template<class P> CntPtr(const CntPtr<P>& ptr) : m_object(ptr.m_object){ chktype(); add_object(); } template<class P> CntPtr(CntPtr<P>&& ptr) : m_object(ptr.m_object){ ptr.m_object = nullptr; } ~CntPtr(){ remove_object(); } CntPtr& operator=(const CntPtr& ptr) { change_object(ptr.m_object); return *this; } CntPtr& operator=(CntPtr&& ptr) { remove_object(); m_object = ptr.m_object; ptr.m_object = nullptr; return *this; } CntPtr& operator=(T* object) { change_object(object); return *this; } template<class P> CntPtr& operator=(const CntPtr<P>& ptr) { change_object(ptr.m_object); return *this; } template<class P> CntPtr& operator=(CntPtr<P>&& ptr) { m_object = ptr.m_object; ptr.m_object = nullptr; return *this; } T* get() const { return m_object; } T* operator->() const { return m_object; } T& operator*() const { return *m_object; } bool operator!() const { return !m_object; } }; } #endif//SYN_CORE_CNTPTR_H_INCLUDED
28.480769
122
0.698852
[ "object" ]
47c2163c785ea09a9c8530bc7a88a75b6efa0d84
4,212
h
C
src/Residue.h
yingyulou/PDBToolsCpp
61d0f72851d42b4f3b06931be4f47d393d82dd2b
[ "MIT" ]
5
2019-04-16T17:29:14.000Z
2020-07-03T05:19:41.000Z
src/Residue.h
yingyulou/PDBToolsCpp
61d0f72851d42b4f3b06931be4f47d393d82dd2b
[ "MIT" ]
null
null
null
src/Residue.h
yingyulou/PDBToolsCpp
61d0f72851d42b4f3b06931be4f47d393d82dd2b
[ "MIT" ]
2
2020-07-03T05:19:43.000Z
2021-04-15T08:16:55.000Z
/* Residue.h ========= Class Residue header. */ #pragma once #include <string> #include <vector> #include <unordered_map> #include <utility> #include <iostream> #include <Eigen/Dense> #include "NotAtom.h" #include "NotProtein.h" #include "Chain.h" #include "Atom.h" #include "Constants.hpp" namespace PDBTools { //////////////////////////////////////////////////////////////////////////////// // Using //////////////////////////////////////////////////////////////////////////////// using std::string; using std::vector; using std::unordered_map; using std::pair; using std::ostream; using Eigen::RowVector3d; using Eigen::Matrix3d; //////////////////////////////////////////////////////////////////////////////// // Class Residue //////////////////////////////////////////////////////////////////////////////// class Residue: public __NotAtom<Residue, Atom>, public __NotProtein<Residue, Chain> { // Friend friend ostream &operator<<(ostream &os, const Residue &resObj); public: // Constructor explicit Residue(const string &name = "", int num = 0, const string &ins = "", Chain *owner = nullptr); // Getter: __name string &name(); // Getter: __num int num(); // Getter: __ins string &ins(); // Getter: __owner Chain *owner(); // Getter: __sub vector<Atom *> &sub(); // Setter: __name Residue *name(const string &val); // Setter: __num Residue *num(int val); // Setter: __ins Residue *ins(const string &val); // Setter: __owner Residue *owner(Chain *val); // Setter: __sub Residue *sub(const vector<Atom *> &val); // Getter: compNum string compNum(); // Setter: compNum Residue *compNum(int num, const string &ins = ""); // Setter: compNum (by compNumPair) Residue *compNum(const pair<int, string> &compNumPair); // Copy Residue *copy(); // GetResidues vector<Residue *> getResidues(); // GetAtoms vector<Atom *> getAtoms(); // subMap unordered_map<string, Atom *> subMap(); // coordMap unordered_map<string, RowVector3d> coordMap(); // Calc Backbone Dihedral Angle double calcBBDihedralAngle(DIH dihedralEnum); // Calc Backbone Rotation Matrix By Delta Angle pair<RowVector3d, Matrix3d> calcBBRotationMatrixByDeltaAngle( DIH dihedralEnum, SIDE sideEnum, double deltaAngle); // Calc Backbone Rotation Matrix By Target Angle pair<RowVector3d, Matrix3d> calcBBRotationMatrixByTargetAngle( DIH dihedralEnum, SIDE sideEnum, double targetAngle); // Get Backbone Rotation Atom Pointer vector<Atom *> getBBRotationAtomPtr(DIH dihedralEnum, SIDE sideEnum); // Rotate Backbone Dihedral Angle By Delta Angle Residue *rotateBBDihedralAngleByDeltaAngle(DIH dihedralEnum, SIDE sideEnum, double deltaAngle); // Rotate Backbone Dihedral Angle By Target Angle Residue *rotateBBDihedralAngleByTargetAngle(DIH dihedralEnum, SIDE sideEnum, double targetAngle); // Calc Side Chain Dihedral Angle double calcSCDihedralAngle(int dihedralIdx); // Calc Side Chain Rotation Matrix By Delta Angle pair<RowVector3d, Matrix3d> calcSCRotationMatrixByDeltaAngle( int dihedralIdx, double deltaAngle); // Calc Side Chain Rotation Matrix By Target Angle pair<RowVector3d, Matrix3d> calcSCRotationMatrixByTargetAngle( int dihedralIdx, double targetAngle); // Get Side Chain Rotation Atom Pointer vector<Atom *> getSCRotationAtomPtr(int dihedralIdx); // Rotate Side Chain Dihedral Angle By Delta Angle Residue *rotateSCDihedralAngleByDeltaAngle(int dihedralIdx, double deltaAngle); // Rotate Side Chain Dihedral Angle By Target Angle Residue *rotateSCDihedralAngleByTargetAngle(int dihedralIdx, double targetAngle); // Dump Residue *dump(const string &dumpFilePath, const string &fileMode = "w"); // Destructor ~Residue(); private: // Attribute string __name; int __num; string __ins; Chain *__owner; vector<Atom *> __sub; // str string __str() const; }; } // End namespace PDBTools
20.546341
85
0.62037
[ "vector" ]
47c7b6eb4e9772a60099ac14410c9ccc5157e1d2
3,865
h
C
oneEngine/oneGame/source/after/terrain/generation/regions/CRegionGenerator.h
jonting/1Engine
f22ba31f08fa96fe6405ebecec4f374138283803
[ "BSD-3-Clause" ]
8
2017-12-08T02:59:31.000Z
2022-02-02T04:30:03.000Z
oneEngine/oneGame/source/after/terrain/generation/regions/CRegionGenerator.h
jonting/1Engine
f22ba31f08fa96fe6405ebecec4f374138283803
[ "BSD-3-Clause" ]
2
2021-04-16T03:44:42.000Z
2021-08-30T06:48:44.000Z
oneEngine/oneGame/source/after/terrain/generation/regions/CRegionGenerator.h
jonting/1Engine
f22ba31f08fa96fe6405ebecec4f374138283803
[ "BSD-3-Clause" ]
1
2021-04-16T02:09:54.000Z
2021-04-16T02:09:54.000Z
#ifndef _C_REGION_CONTROLLER_H_ #define _C_REGION_CONTROLLER_H_ #include <thread> #include <mutex> #include "core/containers/arstring.h" #include "engine/behavior/CGameBehavior.h" #include "after/types/WorldVector.h" #include "after/types/world/Resources.h" #include "after/types/world/Cultures.h" #include "after/types/world/Regions.h" class CBinaryFile; class CVoxelTerrain; namespace Terrain { struct quickAccessData; class CRegionGenerator : public CGameBehavior { public: CRegionGenerator ( CVoxelTerrain* n_terra ); ~CRegionGenerator( void ); // Step Update( ) : Engine call // Must be safe to call during the execution of this class's other properties // Performs simulation of regions. void Update ( void ) override; // Generate( ) : Thread-safe call to create or load region information void Generate ( const RangeVector& n_index ); private: CVoxelTerrain* m_terrain; // ==================================== // Region Generation // ==================================== public: // Region_ClosestValidToIndex ( ) : Finds the closest valid region to the index. // Validitiy is based on the XY coordinates. The Z coordinate comes into play when there are overlapping regions. uint32_t Region_ClosestValidToIndex ( const RangeVector& ); private: // Region_GenerateFloodfill ( ) : Generates a region using a floodfill algorithm. // Will swallow existing regions. uint32_t Region_GenerateFloodfill ( const RangeVector&, bool& o_isNewArea, std::vector<RangeVector>& o_sectorList ); // Region_GenerateProperties ( ) : Generates properties for the given region. // Will overwrite old properties. void Region_GenerateProperties ( const uint32_t n_region, const RangeVector& n_origin, const std::vector<RangeVector>& n_sectors ); // Region_ChangeRegionTo ( ) : Changes all positions with the given region into another region. void Region_ChangeRegionTo ( const uint32_t n_source_region, const uint32_t n_target_region ); // Region_AppendSectors ( ) : Appends the list of sectors to the existing region void Region_AppendSectors ( const uint32_t n_region, const std::vector<RangeVector>& n_sectors ); private: uint32_t m_gen_nextregion; std::mutex m_gen_floodfill_lock; // Needs to be locked so regions don't overlap private: // ==================================== // I/O // ==================================== struct io_intermediate_t { //uint32_t fp; uint32_t block; uint32_t block_indexer; World::regioninfo_t data; }; struct io_nodeset_t { uint32_t blocks [13]; World::regioninfo_t data [12]; uint32_t count; }; // 248 byte struct void IO_Start ( void ); void IO_End ( void ); void IO_SaveOpen ( void ); void IO_Open ( void ); void IO_Save ( void ); void IO_UpdateNext ( void ); void IO_SetRegion ( const World::regioninfo_t& n_index_data ); void IO_FindIndex ( const RangeVector& n_index, io_intermediate_t& o_findResult ); void IO_ReadBlock ( const uint32_t n_blockindex, io_nodeset_t* o_data ); void IO_WriteBlock( const uint32_t n_blockindex, const io_nodeset_t* n_data ); public: // IO_RegionGetSetHasTowns ( ) : Returns true if the region has not generated towns yet. // Marks the has_towns flag to true. bool IO_RegionGetSetHasTowns ( const uint32_t n_region ); void IO_RegionSaveInfo ( const uint32_t n_region, const World::regionproperties_t* n_data ); void IO_RegionSaveSectors ( const uint32_t n_region, const std::vector<RangeVector>& n_sectors ); void IO_RegionLoadInfo ( const uint32_t n_region, World::regionproperties_t* n_data ); void IO_RegionLoadSectors ( const uint32_t n_region, std::vector<RangeVector>& n_sectors ); private: uint32_t m_io_next_freeblock; int m_io_usecount; std::mutex m_io_lock_file; CBinaryFile* m_io; }; }; #endif//_C_REGION_CONTROLLER_H_
33.903509
133
0.719017
[ "vector" ]
47cc973c737a683a1fe21a22e4766a16f387d1f4
2,771
h
C
simulation/Simulation.h
Terae/3D_Langton_Ant
017dadbe2962018db043bf50e8a6dcd49ade0eac
[ "MIT" ]
null
null
null
simulation/Simulation.h
Terae/3D_Langton_Ant
017dadbe2962018db043bf50e8a6dcd49ade0eac
[ "MIT" ]
null
null
null
simulation/Simulation.h
Terae/3D_Langton_Ant
017dadbe2962018db043bf50e8a6dcd49ade0eac
[ "MIT" ]
null
null
null
// // Created by benji on 08/11/16. // #ifndef LANGTON3D_SIMULATION_H #define LANGTON3D_SIMULATION_H #include <unistd.h> #include <vector> #include "Elements/Ant.h" #include "Grid3D.h" #include "Message_Colors.h" #include "Rendering/Context.h" #include "Rendering/Scene.h" #include "Rendering/Window.h" #define DEFAULT_UPDATE_FREQUENCY 100 // Hz #define LIMIT_SIMULATION 1500 // divergence of the ant after class EventListener { public: void init(Window * mainWindow); virtual void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) = 0; virtual void scrollCallback(GLFWwindow* window, double xoffset, double yoffset) = 0; void setEventListener(EventListener* eventListener); static EventListener *listener; protected: void glfwKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); void glfwScrollCallback(GLFWwindow* window, double xoffset, double yoffset); }; class Simulation : public EventListener { public: /** * @param ruleID from 1 to PRE_CONFIGURED_RULES_NUMBER */ Simulation(int ruleID = 1); Simulation(RuleDefinition rules); ~Simulation(); void addAnt(int x, int y, int z); void addAnt(Vector3 position); void start(); void initialize(); void createRules(); void setRules(int ruleID); void setRules(RuleDefinition rules); void printHelp(); protected: void mainLoop(); void input(); void createWindow(); void createControlKeys(); void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) override; void scrollCallback(GLFWwindow* window, double xoffset, double yoffset) override; private: std::unique_ptr<Scene> _scene = nullptr; std::unique_ptr<Window> _window = nullptr; std::shared_ptr<Grid3D> _grid = nullptr; std::shared_ptr<Rules> _rules = nullptr; std::vector<Vector3> _antsPosition; std::vector<std::unique_ptr<Ant>> _listAnts; int _count = 0; int _currentPreConfiguredRules = 0; double _beginSimulation; double _beginSimulationPaused = 0; void pauseSimulation(bool desactivate); std::vector<int> _checkpointsList; void addCheckpoints(); bool _pauseSimulation = false; bool _pauseDisplaying = false; // Controls int _rightKey; int _leftKey; int _upKey; int _downKey; int _keyA; // +Y int _keyZ; // +Z int _keyE; // -Y int _keyQ; // -X int _keyS; // -Z int _keyD; // +X void centerCamera(); void emptyBuffer() { cin.clear(); cin.seekg(0, ios::end); if (cin.eof()) cin.ignore(numeric_limits<streamsize>::max()); else cin.clear(); } }; #endif //LANGTON3D_SIMULATION_H
22.900826
98
0.676651
[ "vector" ]
47dcb03b0f8c8d6f61e355a2a3646d14d34f9494
6,226
h
C
shared/SIDualCamOptions.h
TinyTheBrontosaurus/ScaleInvariantPtz
4b6975874e7f2995106b181baa84cbec2111ba89
[ "MIT" ]
null
null
null
shared/SIDualCamOptions.h
TinyTheBrontosaurus/ScaleInvariantPtz
4b6975874e7f2995106b181baa84cbec2111ba89
[ "MIT" ]
null
null
null
shared/SIDualCamOptions.h
TinyTheBrontosaurus/ScaleInvariantPtz
4b6975874e7f2995106b181baa84cbec2111ba89
[ "MIT" ]
null
null
null
#ifndef SIDUALCAMOPTIONS_H #define SIDUALCAMOPTIONS_H #include "types.h" /************************************************************** * * SIDualCamOptions class * Description: A collection of all the various options used by * the SIDualCam class. All options are public. ************************************************************** */ class SIDualCamOptions { public: /****************************************** * ctor * Description: Sets defaults for all options ****************************************** */ SIDualCamOptions(); /****************************************** * loadOptions * Description: Loads options from a file * Parameters: filename - the filename * Returns: Code returned by file I/O ****************************************** */ void loadOptions( CHAR *fileName ); /****************************************** * saveOptions * Description: Saves options to a file * Parameters: filename - the filename * Returns: Code returned by file I/O ****************************************** */ void saveOptions( CHAR *fileName ); /****************************************** * copy * Description: Copy from one object to "this" * Parameters: that - the object to be copied ****************************************** */ void copy(SIDualCamOptions const *that ); private: /****************************************** * setVariable * Description: Sets a variable, depicted by a string, * to a value, also a string. * Parameters: var - the variable * value - the value of that variable * newOptions - the object that should have its * variable set. * Returns: True if var and value both valid ****************************************** */ BOOL setVariable( CHAR *var, CHAR *value, SIDualCamOptions *newOptions ); public: //True when control should be coordinated between the panoramic and //zoomed cameras. BOOL arbitrateControl; //True when display should be coordinated between the panoramic and //zoomed cameras. BOOL arbitrateDisplay; //The minimum zoom level of zooming camera FLOAT minZoomMagZoomCam; //The options to be loaded for the panoramic camera when hybridly zooming CHAR panoramicCamOptions[CO_PATH_LENGTH]; //The options to be loaded for the zooming camera when hybridly zooming CHAR zoomCamOptions[CO_PATH_LENGTH]; // Video destination options ////////////////////// //The prefix to be tacked onto the beginning of the video file names CHAR vidDstDirectory[CO_PATH_LENGTH]; CHAR vidDstPrefix[CO_PATH_LENGTH]; //The suffix to be tacked onto the end of the video file names CHAR vidDstSuffix[CO_PATH_LENGTH]; //True when the original streams from the camera should be saved BOOL vidDstSaveOrigStream; //True when the digitally altered streams should be saved BOOL vidDstSaveDigStream; //True when the HZO stream should be saved BOOL vidDstSaveSplicedStream; // Logging options//////////////////////////////// BOOL saveStats; }; #endif // File: $Id: SIDualCamOptions.h,v 1.5 2005/09/12 23:40:20 edn2065 Exp $ // Author: Eric D Nelson // Description: The options for an object in the Controller class // Revisions: // $Log: SIDualCamOptions.h,v $ // Revision 1.5 2005/09/12 23:40:20 edn2065 // Renamed SIKernel and SIHzo to SISingleCam and SIDualCam // // Revision 1.4 2005/09/10 02:42:48 edn2065 // Added minimum zoom option. Added timer to apply in menu. // // Revision 1.3 2005/09/09 01:24:37 edn2065 // Added HZO logging // // Revision 1.2 2005/09/07 22:43:32 edn2065 // Added option to save spliced stream // // Revision 1.1 2005/08/25 22:12:23 edn2065 // Made commandLevel a class. Added HZO pickoff point in SIKernel // // Revision 1.22 2005/08/16 02:16:38 edn2065 // Added menu options for selecting digital zoom type and for easy image type switching // // Revision 1.21 2005/08/09 21:59:27 edn2065 // Added easy serialPort switching via SIKernelOptions files // // Revision 1.20 2005/08/03 02:34:54 edn2065 // Added tordoff psi and gammas to menu // // Revision 1.19 2005/07/29 00:11:14 edn2065 // Added menu options for Kalman filter and fixation gains // // Revision 1.18 2005/06/28 15:09:40 edn2065 // Added multiple tracker color option to kernel // // Revision 1.17 2005/06/09 20:51:22 edn2065 // Added pulsing to zoom and pt // // Revision 1.16 2005/06/09 13:48:03 edn2065 // Fixed synchronization errors caused by not initializing Barrier in SIKernal // // Revision 1.15 2005/06/07 16:55:57 edn2065 // Created SICameraComms thread, now tryin to test. // // Revision 1.14 2005/06/03 12:49:46 edn2065 // Changed Controller to SIKernel // // Revision 1.13 2005/05/27 13:20:53 edn2065 // Added ability to change number of ROIs in output // // Revision 1.12 2005/05/26 19:15:02 edn2065 // Added VideoStream. tested. Still need to get tracker working // // Revision 1.11 2005/05/25 15:58:46 edn2065 // Added option to prevent the horizontal line from appearing on the screen output // // Revision 1.10 2005/04/22 20:52:48 edn2065 // Implemented load and save of controller options // // Revision 1.6 2005/04/21 13:47:39 edn2065 // Added Menus and fully commented. commented ControllerOptions. // // Revision 1.5 2005/04/07 14:28:36 edn2065 // Implemented tester. untested tester. // // Revision 1.4 2005/04/06 21:21:09 edn2065 // Have number of bugs with threads. Revamping GUI to VideoSourceFile call // // Revision 1.3 2005/04/06 19:02:06 edn2065 // Added functionality for creation and destruction of input and output video streams. // // Revision 1.2 2005/04/02 13:45:27 edn2065 // Moved types to types.h // // Revision 1.1 2005/04/02 12:52:13 edn2065 // Adding file // ---------------------------------------------------------------------- //
34.782123
88
0.591873
[ "object" ]
fe6e7fb3832591820c79f81bb8be0749eee5c4fe
4,394
c
C
stm32f429_SDCard/sd2/file_command.c
james54068/stm32_learning
2214317240f4733f61b5e183c18a34a236f7b41d
[ "MIT" ]
null
null
null
stm32f429_SDCard/sd2/file_command.c
james54068/stm32_learning
2214317240f4733f61b5e183c18a34a236f7b41d
[ "MIT" ]
null
null
null
stm32f429_SDCard/sd2/file_command.c
james54068/stm32_learning
2214317240f4733f61b5e183c18a34a236f7b41d
[ "MIT" ]
null
null
null
#include "file_command.h" #include "ff.h" #include "main.h" #include <string.h> uint8_t ls(uint8_t *Directory) { /* Directory object structure (DIR) */ DIR dir; /*File status structure (FILINFO) */ FILINFO fileInfo; /* File function return code (FRESULT) */ FRESULT res; if(f_opendir(&dir,Directory)==FR_OK) { while(f_readdir(&dir,&fileInfo)==FR_OK) { if(!fileInfo.fname[0]) break; /*AM_ARC:read/write able file*/ if(fileInfo.fattrib==AM_ARC) printf("%s\r\n",fileInfo.fname); /*AM_DIR:Directory*/ if(fileInfo.fattrib==AM_DIR) printf("%s\r\n",fileInfo.fname); } f_readdir(&dir,NULL); return 0; } return 1; } uint8_t ls_all(uint8_t *Directory) { uint8_t next_folder[]=""; uint8_t current_folder[]=""; DIR dir_scan; /*File status structure (FILINFO) */ FILINFO fileInfo_scan; /* File function return code (FRESULT) */ // static uint8_t folder[]=""; //printf("%s\r\n",folder); uint8_t res; res = f_opendir(&dir_scan,Directory); printf("%d\r\n",res); if(res==FR_OK) { strcpy(current_folder,Directory); while(f_readdir(&dir_scan,&fileInfo_scan)==FR_OK) { if(!fileInfo_scan.fname[0]) break; if(fileInfo_scan.fname[0]=='.') continue; /*AM_ARC:read/write able file*/ if(fileInfo_scan.fattrib==AM_ARC) { //strcat(current_folder,"/"); printf("%s/",current_folder); printf("%s\r\n",fileInfo_scan.fname); //strcat(current_folder,fileInfo_scan.fname); //printf("%s\r\n",current_folder); } /*AM_DIR:Directory*/ if(fileInfo_scan.fattrib==AM_DIR) { //printf("%s\r\n",fileInfo_scan.fname); strcat(Directory,fileInfo_scan.fname); strcpy(next_folder,Directory); //printf("%s\r\n",next_folder); ls_all(&next_folder); } } f_readdir(&dir_scan,NULL); return 0; } return 1; } uint8_t read_file(uint8_t *Directory) { /* File object structure (FIL) */ FIL fsrc; /* Directory object structure (DIR) */ DIR dir; /*File status structure (FILINFO) */ FILINFO fileInfo; /* File function return code (FRESULT) */ FRESULT res; /* File read/write count*/ UINT br; /*Max file number in root is 50(no long name <= 8 byte)*/ uint8_t Block_Buffer[512]; res = f_opendir(&dir,Directory); printf("%d\r\n",res); if(res==FR_OK) { res = f_open(&fsrc, "5566", FA_READ); printf("%d\r\n",res); if(!res) { printf("open news.txt : %d\r\n",res); br=1; printf("File Content:\r\n"); for (;;) { int a=0; for(a=0; a<512; a++) Block_Buffer[a]=0; res = f_read(&fsrc, Block_Buffer, sizeof(Block_Buffer), &br); printf("%s\r\n",Block_Buffer); /**/ if (res || br < sizeof(Block_Buffer)) break; } } f_close(&fsrc); } } uint8_t write_file(void) { uint8_t Block_Buffer[512] = "FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. It can be incorporated into low cost microcontrollers, such as AVR, 8051, PIC, ARM, Z80, 68k and etc..., without any change. \r\n "; /* File object structure (FIL) */ FIL fsrc; /* File function return code (FRESULT) */ FRESULT res; /* File read/write count*/ UINT bw; res = f_open(&fsrc, "/new/data.txt", FA_CREATE_ALWAYS); printf("%d\r\n",res); res = f_open(&fsrc, "/new/data.txt", FA_WRITE); printf("%d\r\n",res); res = f_lseek (&fsrc ,fsrc.fsize); printf("%d\r\n",res); res = f_write (&fsrc ,"\r\n",2,&bw); printf("%d\r\n",res); printf("words:%d\r\n",strlen(Block_Buffer)); if (res == FR_OK) { printf("create file ok!\r\n"); printf("start write!\r\n"); res = f_printf(&fsrc,"123456789\r\n"); printf("%d\r\n",res); do { res = f_write(&fsrc,Block_Buffer,sizeof(Block_Buffer),&bw); printf("%d\r\n",bw); if(res) { printf("write error : %d\r\n",res); break; } printf("write ok!\r\n"); } while (bw < sizeof(Block_Buffer)); } f_close(&fsrc); }
27.4625
410
0.579199
[ "object" ]
fe7294e419af7da1ecafed83f07de6a2b2b99994
1,184
h
C
SpriteBuilder/ccBuilder/PolyDecomposition.h
andykorth/SpriteBuilder
cd8a5c8d4a25b66c74e7609682c95106095d0267
[ "MIT", "BSD-2-Clause", "BSD-3-Clause" ]
365
2015-01-02T17:15:39.000Z
2022-03-05T23:15:55.000Z
SpriteBuilder/ccBuilder/PolyDecomposition.h
andykorth/SpriteBuilder
cd8a5c8d4a25b66c74e7609682c95106095d0267
[ "MIT", "BSD-2-Clause", "BSD-3-Clause" ]
559
2015-01-01T16:23:13.000Z
2021-11-13T13:55:07.000Z
SpriteBuilder/ccBuilder/PolyDecomposition.h
andykorth/SpriteBuilder
cd8a5c8d4a25b66c74e7609682c95106095d0267
[ "MIT", "BSD-2-Clause", "BSD-3-Clause" ]
179
2015-01-01T02:22:15.000Z
2021-07-08T15:43:16.000Z
// // BayazitDecomposition.h // TestApp // // Created by John Twigg on 2/4/14. // Copyright (c) 2014 John Twigg. All rights reserved. // static const double kMinimumAcuteAngle = 5.0; //degrees @interface PolyDecomposition : NSObject //Decomps an input poly into convex sub polys. //Convex decomposition algorithm created by Mark Bayazit (http://mnbayazit.com/) //Return TRUE if operation was successful. //return FALSE if failure. Failure cases can be caused by intersecting segments or Acute Lines. +(BOOL)bayazitDecomposition:(NSArray *)inputPoly outputPoly:(NSArray **)outputPolys; //Does the poly possess any intersecting line segments. //outSegments array is [ seg1.A, seg1.B, seg2.A, seg2.B, ...] +(BOOL)intersectingLines:(NSArray*)inputPoly outputSegments:(NSArray**)outSegments; //Does the poly have any acute corner angles below the minimum acceptable. //returns TRUE is there are acute lines. //outSegments = [ pt1,pt2, pt3, ...] where (pt2-pt2) & (pt3 - pt2) form an acute angle < min. +(BOOL)acuteCorners:(NSArray*)inputPoly outputSegments:(NSArray**)outSegments; //turns a poly shape into a convex hull. +(NSArray*)makeConvexHull:(NSArray*)inputPoly; @end
32.888889
95
0.744932
[ "shape" ]
fe7b5a969c571bf34d34b7ca63e2f7444503e20e
4,225
h
C
DX12Lib/inc/dx12lib/Texture.h
DrLinnis/AdaptiveSampling
814f692b6b94247c68123da4a62086d10780d02b
[ "MIT" ]
null
null
null
DX12Lib/inc/dx12lib/Texture.h
DrLinnis/AdaptiveSampling
814f692b6b94247c68123da4a62086d10780d02b
[ "MIT" ]
null
null
null
DX12Lib/inc/dx12lib/Texture.h
DrLinnis/AdaptiveSampling
814f692b6b94247c68123da4a62086d10780d02b
[ "MIT" ]
null
null
null
#pragma once /* * Copyright(c) 2018 Jeremiah van Oosten * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files(the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions : * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ /** * @file Texture.h * @date October 24, 2018 * @author Jeremiah van Oosten * * @brief A wrapper for a DX12 Texture object. */ #include "DescriptorAllocation.h" #include "Resource.h" #include "d3dx12.h" #include <mutex> #include <unordered_map> namespace dx12lib { class Device; class Texture : public Resource { public: /** * Resize the texture. */ void Resize( uint32_t width, uint32_t height, uint32_t depthOrArraySize = 1 ); /** * Get the RTV for the texture. */ D3D12_CPU_DESCRIPTOR_HANDLE GetRenderTargetView() const; /** * Get the DSV for the texture. */ D3D12_CPU_DESCRIPTOR_HANDLE GetDepthStencilView() const; /** * Get the default SRV for the texture. */ D3D12_CPU_DESCRIPTOR_HANDLE GetShaderResourceView() const; /** * Get the UAV for the texture at a specific mip level. * Note: Only only supported for 1D and 2D textures. */ D3D12_CPU_DESCRIPTOR_HANDLE GetUnorderedAccessView( uint32_t mip ) const; bool CheckSRVSupport() const { return CheckFormatSupport( D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE ); } bool CheckRTVSupport() const { return CheckFormatSupport( D3D12_FORMAT_SUPPORT1_RENDER_TARGET ); } bool CheckUAVSupport() const { return CheckFormatSupport( D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW ) && CheckFormatSupport( D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD ) && CheckFormatSupport( D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE ); } bool CheckDSVSupport() const { return CheckFormatSupport( D3D12_FORMAT_SUPPORT1_DEPTH_STENCIL ); } /** * Check to see if the image format has an alpha channel. */ bool HasAlpha() const; /** * Check the number of bits per pixel. */ size_t BitsPerPixel() const; static bool IsUAVCompatibleFormat( DXGI_FORMAT format ); static bool IsSRGBFormat( DXGI_FORMAT format ); static bool IsBGRFormat( DXGI_FORMAT format ); static bool IsDepthFormat( DXGI_FORMAT format ); // Return a typeless format from the given format. static DXGI_FORMAT GetTypelessFormat( DXGI_FORMAT format ); // Return an sRGB format in the same format family. static DXGI_FORMAT GetSRGBFormat( DXGI_FORMAT format ); static DXGI_FORMAT GetUAVCompatableFormat( DXGI_FORMAT format ); protected: Texture( Device& device, const D3D12_RESOURCE_DESC& resourceDesc, const D3D12_CLEAR_VALUE* clearValue = nullptr, const D3D12_RESOURCE_STATES initState = D3D12_RESOURCE_STATE_COMMON ); Texture( Device& device, Microsoft::WRL::ComPtr<ID3D12Resource> resource, const D3D12_CLEAR_VALUE* clearValue = nullptr ); virtual ~Texture(); /** * Create SRV and UAVs for the resource. */ void CreateViews(); private: DescriptorAllocation m_RenderTargetView; DescriptorAllocation m_DepthStencilView; DescriptorAllocation m_ShaderResourceView; DescriptorAllocation m_UnorderedAccessView; }; } // namespace dx12lib
31.296296
187
0.71432
[ "object" ]
fe7e5ff692f17f06b232dd655d5162482c097896
5,173
h
C
src/avt/Filters/avtResampleFilter.h
eddieTest/visit
ae7bf6f5f16b01cf6b672d34e2d293fa7170616b
[ "BSD-3-Clause" ]
null
null
null
src/avt/Filters/avtResampleFilter.h
eddieTest/visit
ae7bf6f5f16b01cf6b672d34e2d293fa7170616b
[ "BSD-3-Clause" ]
null
null
null
src/avt/Filters/avtResampleFilter.h
eddieTest/visit
ae7bf6f5f16b01cf6b672d34e2d293fa7170616b
[ "BSD-3-Clause" ]
null
null
null
/***************************************************************************** * * Copyright (c) 2000 - 2019, Lawrence Livermore National Security, LLC * Produced at the Lawrence Livermore National Laboratory * LLNL-CODE-442911 * All rights reserved. * * This file is part of VisIt. For details, see https://visit.llnl.gov/. The * full copyright notice is contained in the file COPYRIGHT located at the root * of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the disclaimer below. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the disclaimer (as noted below) in the * documentation and/or other materials provided with the distribution. * - Neither the name of the LLNS/LLNL nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, * LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * *****************************************************************************/ // ************************************************************************* // // avtResampleFilter.h // // ************************************************************************* // #ifndef AVT_RESAMPLE_FILTER_H #define AVT_RESAMPLE_FILTER_H #include <filters_exports.h> #include <avtDatasetToDatasetFilter.h> #include <InternalResampleAttributes.h> // **************************************************************************** // Class: avtResampleFilter // // Purpose: // Resamples a dataset onto a rectilinear grid. // // Programmer: Hank Childs // Creation: March 26, 2001 // // Modifications: // // Hank Childs, Fri Apr 6 17:39:40 PDT 2001 // Added ability to bypass filter with already valid rectilinear grids. // // Mark C. Miller, Tue Sep 13 20:09:49 PDT 2005 // Added selID to support data selections // // Hank Childs, Sat Apr 29 15:53:13 PDT 2006 // Add argument to GetDimensions. // // Jeremy Meredith, Thu Feb 15 11:44:28 EST 2007 // Added support for rectilinear grids with an inherent transform. // // Hank Childs, Fri Jun 1 16:17:51 PDT 2007 // Added support for cell-centered output. // // Hank Childs, Wed Dec 31 13:45:03 PST 2008 // Change name of attributes from ResampleAtts to InternalResampleAtts. // // Tom Fogal, Tue Jun 23 20:28:01 MDT 2009 // Added GetBounds method. // // Hank Childs, Tue Nov 30 21:54:43 PST 2010 // Remove const qualification for GetBounds. // // **************************************************************************** class AVTFILTERS_API avtResampleFilter : public avtDatasetToDatasetFilter { public: avtResampleFilter(const AttributeGroup*); virtual ~avtResampleFilter(); static avtFilter *Create(const AttributeGroup*); virtual const char *GetType(void) { return "avtResampleFilter"; }; virtual const char *GetDescription(void) { return "Resampling"; }; void MakeOutputCellCentered(bool doIt) { cellCenteredOutput = doIt; }; void SetRayCasting(bool _rayCasting) { rayCasting = _rayCasting; } protected: InternalResampleAttributes atts; char *primaryVariable; int selID; bool cellCenteredOutput; bool rayCasting; virtual void Execute(void); virtual void UpdateDataObjectInfo(void); void GetDimensions(int &, int &, int &, const double *, bool); bool GetBounds(double[6]); void ResampleInput(void); virtual int AdditionalPipelineFilters(void) { return 2; }; virtual avtContract_p ModifyContract(avtContract_p); virtual bool FilterUnderstandsTransformedRectMesh(); }; #endif
38.318519
79
0.604292
[ "transform" ]
fe832c63d110a27126d4572ca83610235372fa9a
6,712
c
C
slrs/camlibs/stv0674/stv0674.c
milinddeore/360D-Sampler
a17df51aa3f1252274337c2421b90e4bd1c6b40e
[ "MIT" ]
null
null
null
slrs/camlibs/stv0674/stv0674.c
milinddeore/360D-Sampler
a17df51aa3f1252274337c2421b90e4bd1c6b40e
[ "MIT" ]
null
null
null
slrs/camlibs/stv0674/stv0674.c
milinddeore/360D-Sampler
a17df51aa3f1252274337c2421b90e4bd1c6b40e
[ "MIT" ]
null
null
null
/* * STV0674 Camera Chipset Driver * Copyright 2002 Vincent Sanders <vince@kyllikki.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ #include "config.h" #include <string.h> #include <stdlib.h> #include <stdio.h> #include <gphoto2/gphoto2.h> #include <gphoto2/gphoto2-port.h> #include <gphoto2/gphoto2-library.h> #ifdef ENABLE_NLS # include <libintl.h> # undef _ # define _(String) dgettext (GETTEXT_PACKAGE, String) # ifdef gettext_noop # define N_(String) gettext_noop (String) # else # define N_(String) (String) # endif #else # define _(String) (String) # define N_(String) (String) #endif #include "stv0674.h" #include "library.h" #define GP_MODULE "stv0674" static const struct camera_to_usb { char *name; unsigned short idVendor; unsigned short idProduct; } camera_to_usb[] = { /* http://www.digitaldreamco.com/shop/xtra.htm, SVGA */ { "DigitalDream:l'espion xtra", 0x05DA, 0x1020 }, { "Che-ez!:Splash", 0x0553, 0x1002 } }; int camera_id (CameraText *id) { strcpy(id->text, "STV0674"); return (GP_OK); } int camera_abilities (CameraAbilitiesList *list) { CameraAbilities a; unsigned int i; for(i = 0; i < (sizeof(camera_to_usb) / sizeof(struct camera_to_usb)); i++) { memset(&a, 0, sizeof(a)); strcpy(a.model, camera_to_usb[i].name); a.port = GP_PORT_USB; a.status = GP_DRIVER_STATUS_EXPERIMENTAL; a.operations = GP_OPERATION_CAPTURE_IMAGE | GP_OPERATION_CAPTURE_PREVIEW; a.file_operations = GP_FILE_OPERATION_PREVIEW; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; a.usb_vendor = camera_to_usb[i].idVendor; a.usb_product = camera_to_usb[i].idProduct; gp_abilities_list_append(list, a); } return (GP_OK); } static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { Camera *camera = data; int count, result; result = stv0674_file_count(camera->port, &count); if (result < GP_OK) { GP_DEBUG("file count returned %d\n",result); return result; } GP_DEBUG("count is %x\n",count); gp_list_populate(list, "image%03i.jpg", count); return (GP_OK); } static int get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *user_data, GPContext *context) { Camera *camera = user_data; int image_no, result; image_no = gp_filesystem_number(camera->fs, folder, filename, context); if(image_no < 0) return image_no; gp_file_set_mime_type (file, GP_MIME_JPEG); switch (type) { case GP_FILE_TYPE_NORMAL: result = stv0674_get_image (camera->port, image_no, file); break; case GP_FILE_TYPE_RAW: result = stv0674_get_image_raw (camera->port, image_no, file); break; case GP_FILE_TYPE_PREVIEW: result = stv0674_get_image_preview (camera->port, image_no, file); break; default: return (GP_ERROR_NOT_SUPPORTED); } return result; } static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { int result; int count,oldcount; if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); result = stv0674_file_count(camera->port,&oldcount); result = stv0674_capture(camera->port); if (result < 0) return result; /* Just added a new picture... */ result = stv0674_file_count(camera->port,&count); if (count == oldcount) return GP_ERROR; /* unclear what went wrong ... hmm */ strcpy(path->folder,"/"); sprintf(path->name,"image%03i.jpg",count); /* Tell the filesystem about it */ result = gp_filesystem_append (camera->fs, path->folder, path->name, context); if (result < 0) return (result); return (GP_OK); } static int camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context) { char *data; int size, result; result = stv0674_capture_preview (camera->port, &data, &size); if (result < 0) return result; gp_file_set_mime_type (file, GP_MIME_JPEG); return gp_file_set_data_and_size (file, data, size); } static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { stv0674_summary(camera->port,summary->text); return (GP_OK); } static int camera_about (Camera *camera, CameraText *about, GPContext *context) { strcpy (about->text, _("STV0674\n" "Vincent Sanders <vince@kyllikki.org>\n" "Driver for cameras using the STV0674 processor ASIC.\n" "Protocol reverse engineered using SnoopyPro\n")); return (GP_OK); } static int delete_all_func (CameraFilesystem *fs, const char* folder, void *data, GPContext *context) { Camera *camera = data; if (strcmp (folder, "/")) return (GP_ERROR_DIRECTORY_NOT_FOUND); return stv0674_delete_all(camera->port); } static CameraFilesystemFuncs fsfuncs = { .file_list_func = file_list_func, .get_file_func = get_file_func, .delete_all_func = delete_all_func }; int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; int ret; /* First, set up all the function pointers */ camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->capture_preview = camera_capture_preview; camera->functions->capture = camera_capture; gp_port_get_settings(camera->port, &settings); switch(camera->port->type) { case GP_PORT_USB: /* Modify the default settings the core parsed */ settings.usb.altsetting=1;/* we need to use interface 0 setting 1 */ settings.usb.inep=2; settings.usb.intep=3; settings.usb.outep=5; /* Use the defaults the core parsed */ break; default: return (GP_ERROR_UNKNOWN_PORT); break; } ret = gp_port_set_settings (camera->port, settings); if (ret != GP_OK) { gp_context_error (context, _("Could not apply USB settings")); return ret; } /* Set up the filesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* test camera */ return stv0674_ping(camera->port); }
25.915058
108
0.70888
[ "model" ]
fe83f9ea27a7e2732051ec66888ed29cbe43cfcd
6,034
h
C
Maybe/include/algorithm/algoritm.h
RedFree/Maybe
1592cb8b872be82fec6d35d593165a7a179fa8dd
[ "MIT" ]
2
2016-11-23T04:45:07.000Z
2016-12-28T14:46:55.000Z
Maybe/include/algorithm/algoritm.h
RedFree/Maybe
1592cb8b872be82fec6d35d593165a7a179fa8dd
[ "MIT" ]
null
null
null
Maybe/include/algorithm/algoritm.h
RedFree/Maybe
1592cb8b872be82fec6d35d593165a7a179fa8dd
[ "MIT" ]
2
2016-10-17T04:51:13.000Z
2019-11-16T12:23:08.000Z
//*********************************************************************************/ // MIT License // // Copyright (c) 2016 RedFree // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. //*********************************************************************************/ #ifndef _ALGORITHM_H #define _ALGORITHM_H #include "../sys_def.h" #include "../allocator.h" namespace maybe { using maybe::Allocator; template<typename _Ty> class Insertion { public: ///The default constructor Insertion(){} ///The constructor of copy Insertion(const Insertion& _insert){ this->list_ = _insert.list_; } Insertion(const vector<_Ty> _list) : list_(_list){} ~Insertion(){} void ascend(vector<_Ty>& _sortVec); void ascend_sort(vector<_Ty>& _sortVec); //************************************ // Method: insertion_sort // FullName: maybe::Insertion<_Ty>::insertion_sort // Access: public // Returns: void // Qualifier: standard insertion-sort // Parameter: const vector<_Ty> & _sort_vec //************************************ void insertion_sort( vector<_Ty>& _sort_vec); //************************************ // Method: bubble_sort // FullName: maybe::Insertion<_Ty>::bubble_sort // Access: public // Returns: void // Qualifier: standard bubble-sort // Parameter: vector<_Ty> & _sort_vec //************************************ void bubble_sort(vector<_Ty>& _sort_vec); protected: private: vector<_Ty> list_; }; template<typename _Ty> void maybe::Insertion<_Ty>::bubble_sort( vector<_Ty>& _sort_vec ) { for (size_t first = 0; first < _sort_vec.size(); ++first) { for (size_t scnd = _sort_vec.size() - 1; scnd > first; --scnd) { if (_sort_vec[scnd] < _sort_vec[scnd-1]) { _Ty tmp = _sort_vec[scnd]; _sort_vec[scnd] = _sort_vec[scnd-1]; _sort_vec[scnd-1] = tmp; } } } } template<typename _Ty> void maybe::Insertion<_Ty>::insertion_sort( vector<_Ty>& _sort_vec ) { for (size_t first = 1; first < _sort_vec.size(); ++first) { _Ty _key = _sort_vec[first]; int _prev = first - 1; while (_prev >= 0 && _sort_vec[_prev] > _key) { _sort_vec[_prev+1] = _sort_vec[_prev]; --_prev; } _sort_vec[_prev+1] = _key; } } template<typename _Ty> void Insertion<_Ty>::ascend(vector<_Ty>& _sortVec) { for (size_t i = 0; i < list_.size(); ++i) { size_t uRet = i; for (size_t dx = uRet; dx > 0; --dx) { if (list_[dx] < list_[dx-1]) { _Ty tp = list_[dx]; list_[dx] = list_[dx-1]; list_[dx-1] = tp; } else break; } } _sortVec = list_; } template<typename _Ty> void Insertion<_Ty>::ascend_sort(vector<_Ty>& _sortVec) { typename vector<_Ty>::iterator _itor = ++_sortVec.begin(); while (_itor != _sortVec.end()) { typename vector<_Ty>::iterator _secItor = _itor; typename vector<_Ty>::iterator _thdItor; while (_secItor !=_sortVec.begin() && (*(_thdItor = _secItor) ) < *--_secItor ) { _Ty _val = *_secItor; *_secItor = *_thdItor; *_thdItor = _val; } ++_itor; } } template <typename _Ty> void merge(_Ty& _coll, const size_t& _first, const size_t& _mid, const size_t& _last, const size_t& _size) { _Ty left; _Ty right; for (size_t idx=0; idx<=_mid-_first ; ++idx) { left.push_back(_coll[_first+idx]); } for (size_t idx=0; idx <= _last-_mid - 1; ++idx) { right.push_back(_coll[_mid+idx+1]); } for (size_t i=0, j=0, k=_first; k<=_last; k++) { if (i <= _mid) { if (j < _last - _mid) { if (left[i]<=right[j] && i <= _mid) { _coll[k] = left[i]; i++; }else{ _coll[k] = right[j]; j++; } } else { _coll[k] = left[i]; i++; } } else { if (j < _last - _mid) { _coll[k] = right[j]; j++; } } } } // [10/28/2016 wd] template<typename _Ty> void merge_sort1(_Ty& _coll, const size_t& _first, const size_t& _last) { if (_first < _last) { size_t _mid = (_first + _last)/2; merge_sort1(_coll, _first, _mid); merge_sort1(_coll, _mid+1, _last); size_t _size = _coll.size(); merge(_coll, _first, _mid, _last, _size); } } // [10/28/2016 wd] /* * // [11/3/2016 wd] */ template<typename _Ty> int partition(_Ty& _coll, int _left, int _right) { auto tmp = _coll[_right]; int i = _left - 1; for (int j = _left; j <= _right-1; ++j) { if (_coll[j] <= tmp) { i++; auto tmpval = _coll[j]; _coll[j] = _coll[i]; _coll[i] = tmpval; } } auto xx = _coll[i+1]; _coll[i+1] = _coll[_right]; _coll[_right] = xx; return i+1; } /* * // [11/3/2016 wd] * */ template<typename _Ty> void quick_sort(_Ty& _coll, const int& _left, const int& _right) { if (_left <= _right) { int q = partition(_coll, _left, _right); quick_sort(_coll, _left, q-1); quick_sort(_coll, q+1, _right); } } } #endif
23.207692
107
0.581704
[ "vector" ]
fe85cb188b8a684f703d69e4fb1430424f34c71a
1,953
h
C
extensions/azure/storage/BlobStorage.h
galshi/nifi-minifi-cpp
60905d30e926b5dac469dcdd27b24ac645d47519
[ "Apache-2.0", "OpenSSL" ]
null
null
null
extensions/azure/storage/BlobStorage.h
galshi/nifi-minifi-cpp
60905d30e926b5dac469dcdd27b24ac645d47519
[ "Apache-2.0", "OpenSSL" ]
null
null
null
extensions/azure/storage/BlobStorage.h
galshi/nifi-minifi-cpp
60905d30e926b5dac469dcdd27b24ac645d47519
[ "Apache-2.0", "OpenSSL" ]
null
null
null
/** * @file BlobStorage.h * BlobStorage class declaration * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <string> #include <vector> #include <utility> #include "utils/OptionalUtils.h" namespace org { namespace apache { namespace nifi { namespace minifi { namespace azure { namespace storage { struct UploadBlobResult { std::string primary_uri; std::string etag; std::size_t length; std::string timestamp; }; class BlobStorage { public: BlobStorage(std::string connection_string, std::string container_name) : connection_string_(std::move(connection_string)) , container_name_(std::move(container_name)) { } virtual void createContainer() = 0; virtual void resetClientIfNeeded(const std::string &connection_string, const std::string &container_name) = 0; virtual utils::optional<UploadBlobResult> uploadBlob(const std::string &blob_name, const uint8_t* buffer, std::size_t buffer_size) = 0; virtual ~BlobStorage() = default; protected: std::string connection_string_; std::string container_name_; }; } // namespace storage } // namespace azure } // namespace minifi } // namespace nifi } // namespace apache } // namespace org
30.046154
137
0.744496
[ "vector" ]
fe868b94bd74653a9fd2fc8d2829c346b99468d8
8,763
h
C
cpp/communication/cpp_interface/math/lin_alg/matrix_dynamic/matrix_math_functions.h
Danpihl/plot_tool
ca1aa422fb7db07cd557de102de253043ec49c2d
[ "MIT" ]
36
2020-05-17T16:43:42.000Z
2020-05-24T12:47:15.000Z
cpp/communication/cpp_interface/math/lin_alg/matrix_dynamic/matrix_math_functions.h
Danpihl/plot_tool
ca1aa422fb7db07cd557de102de253043ec49c2d
[ "MIT" ]
1
2020-05-18T04:11:26.000Z
2020-05-18T04:11:26.000Z
cpp/communication/cpp_interface/math/lin_alg/matrix_dynamic/matrix_math_functions.h
Danpihl/plot_tool
ca1aa422fb7db07cd557de102de253043ec49c2d
[ "MIT" ]
3
2020-05-19T10:03:22.000Z
2020-05-22T06:36:55.000Z
#ifndef PLOT_TOOL_MATRIX_MATH_FUNCTIONS_H_ #define PLOT_TOOL_MATRIX_MATH_FUNCTIONS_H_ #include <cmath> #include <cstdarg> #include <tuple> #include "logging.h" #include "math/math_core.h" namespace plot_tool { template <typename T> Vector<T> linspaceFromPointsAndCount(const T x0, const T x1, const size_t num_values); template <typename T> std::tuple<Matrix<T>, Matrix<T>> meshGrid( const T x0, const T x1, const T y0, const T y1, const size_t xn, const size_t yn) { const Vector<T> x_vec = linspaceFromPointsAndCount(x0, x1, xn); const Vector<T> y_vec = linspaceFromPointsAndCount(y0, y1, yn); Matrix<T> x_mat(yn, xn), y_mat(yn, xn); for (size_t r = 0; r < yn; r++) { for (size_t c = 0; c < xn; c++) { x_mat(r, c) = x_vec(c); y_mat(r, c) = y_vec(r); } } return std::tuple<Matrix<T>, Matrix<T>>(std::move(x_mat), std::move(y_mat)); } template <typename T> std::tuple<Matrix<T>, Matrix<T>> meshgrid(const Vector<T>& x_vec, const Vector<T>& y_vec) { Matrix<T> x_mat(y_vec.size(), x_vec.size()), y_mat(y_vec.size(), x_vec.size()); for (size_t r = 0; r < y_vec.size(); r++) { for (size_t c = 0; c < x_vec.size(); c++) { x_mat(r, c) = x_vec(c); y_mat(r, c) = y_vec(r); } } return std::tuple<Matrix<T>, Matrix<T>>(x_mat, y_mat); } template <typename T> Matrix<T> concatenateHorizontally(const std::initializer_list<Matrix<T>>& init_list) { size_t num_rows; size_t idx = 0; for (auto list_mat : init_list) { if (idx == 0) { num_rows = list_mat.rows(); assert(num_rows > 0); } else { assert(list_mat.rows() == num_rows); } assert(list_mat.isAllocated()); idx++; } size_t new_num_cols = 0; for (auto list_mat : init_list) { assert(list_mat.cols() > 0); new_num_cols = new_num_cols + list_mat.cols(); } Matrix<T> mres(num_rows, new_num_cols); size_t c_idx = 0; for (auto list_mat : init_list) { for (size_t c = 0; c < list_mat.cols(); c++) { for (size_t r = 0; r < list_mat.rows(); r++) { mres(r, c_idx) = list_mat(r, c); } c_idx++; } } return mres; } template <typename T> Matrix<T> concatenateVertically(const std::initializer_list<Matrix<T>>& init_list) { size_t num_cols; size_t idx = 0; for (auto list_mat : init_list) { if (idx == 0) { num_cols = list_mat.cols(); assert(num_cols > 0); } else { assert(list_mat.cols() == num_cols); } assert(list_mat.isAllocated()); idx++; } size_t new_num_rows = 0; for (auto list_mat : init_list) { assert(list_mat.rows() > 0); new_num_rows = new_num_rows + list_mat.rows(); } Matrix<T> mres(new_num_rows, num_cols); size_t r_idx = 0; for (auto list_mat : init_list) { for (size_t r = 0; r < list_mat.rows(); r++) { for (size_t c = 0; c < list_mat.cols(); c++) { mres(r_idx, c) = list_mat(r, c); } r_idx++; } } return mres; } template <typename T> Matrix<T> log10(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); Matrix<T> m(m_in.rows(), m_in.cols()); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { m(r, c) = std::log10(m_in(r, c)); } } return m; } template <typename T> Matrix<T> pow(const Matrix<T>& m_in, const T e) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); Matrix<T> m(m_in.rows(), m_in.cols()); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { m(r, c) = std::pow(m_in(r, c), e); } } return m; } template <typename T> Matrix<T> log(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); Matrix<T> m(m_in.rows(), m_in.cols()); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { m(r, c) = std::log(m_in(r, c)); } } return m; } template <typename T> Matrix<T> exp(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); Matrix<T> m(m_in.rows(), m_in.cols()); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { m(r, c) = std::exp(m_in(r, c)); } } return m; } template <typename T> Matrix<T> cos(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); Matrix<T> m(m_in.rows(), m_in.cols()); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { m(r, c) = std::cos(m_in(r, c)); } } return m; } template <typename T> Matrix<T> sin(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); Matrix<T> m(m_in.rows(), m_in.cols()); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { m(r, c) = std::sin(m_in(r, c)); } } return m; } template <typename T> Matrix<T> sqrt(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); Matrix<T> m(m_in.rows(), m_in.cols()); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { m(r, c) = std::sqrt(m_in(r, c)); } } return m; } template <typename T> T max(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); T max_val = m_in(0, 0); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { max_val = std::max(max_val, m_in(r, c)); } } return max_val; } template <typename T> T min(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); T min_val = m_in(0, 0); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { min_val = std::min(min_val, m_in(r, c)); } } return min_val; } template <typename T> T maxAbs(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); T max_val = m_in(0, 0); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { max_val = std::max(max_val, std::abs(m_in(r, c))); } } return max_val; } template <typename T> T minAbs(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); T min_val = m_in(0, 0); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { min_val = std::min(min_val, std::fabs(m_in(r, c))); } } return min_val; } template <typename T> Matrix<T> abs(const Matrix<T>& m_in) { assert((m_in.rows() > 0) && (m_in.cols() > 0) && (m_in.isAllocated())); Matrix<T> m(m_in.rows(), m_in.cols()); for (size_t r = 0; r < m_in.rows(); r++) { for (size_t c = 0; c < m_in.cols(); c++) { m(r, c) = std::fabs(m_in(r, c)); } } return m; } template <typename T> Matrix<T> linspaceFromPointsAndCountColMat(const T x0, const T x1, const size_t num_values) { assert(num_values > 0); Matrix<T> m(num_values, 1); const T dx = (x1 - x0) / static_cast<T>(num_values - 1); m(0, 0) = x0; for (size_t r = 1; r < num_values; r++) { m(r, 0) = m(r - 1, 0) + dx; } return m; } template <typename T> Matrix<T> linspaceFromPointIncAndCountColMat(const T x0, const T dx, const size_t num_values) { assert(num_values > 0); Matrix<T> m(num_values, 1); m(0, 0) = x0; for (size_t r = 1; r < num_values; r++) { m(r, 0) = m(r - 1, 0) + dx; } return m; } template <typename T> Matrix<T> linspaceFromPointsAndIncColMat(const T x0, const T x1, const T dx) { assert(dx > 0); assert(x1 > x0); const size_t num_values = (x1 - x0) / dx; return linspaceFromPointsAndCountColMat(x0, x1, num_values); } } // namespace plot_tool #endif
23.121372
98
0.5093
[ "vector" ]
fe9d928709f26350559a42b02a44c413d9464a36
926
h
C
twitter/Models/User.h
RiaVora/Twitter
82acf76c38af45afcb183baee5854442c7f215b0
[ "Apache-2.0" ]
null
null
null
twitter/Models/User.h
RiaVora/Twitter
82acf76c38af45afcb183baee5854442c7f215b0
[ "Apache-2.0" ]
2
2020-07-03T12:11:52.000Z
2020-07-09T07:20:09.000Z
twitter/Models/User.h
RiaVora/Twitter
82acf76c38af45afcb183baee5854442c7f215b0
[ "Apache-2.0" ]
null
null
null
// // User.h // twitter // // Created by Ria Vora on 6/29/20. // Copyright © 2020 Emerson Malca. All rights reserved. // /*The User model is used to represent a User object from Twitter's API, and stores the attributes of the User object as attributes of the class. The User object is initialized from the dictionary sent by Twitter's API that represents a User object.*/ #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface User : NSObject @property (nonatomic, strong) NSString *name; @property (nonatomic, strong) NSString *screenName; @property (nonatomic, strong) NSURL *profileImageURL; @property (nonatomic, strong) NSURL *profileBannerURL; @property (nonatomic) BOOL verified; @property (nonatomic) int followingCount; @property (nonatomic) int followersCount; @property (nonatomic) int tweetCount; - (instancetype)initWithDictionary:(NSDictionary *)dictionary; @end NS_ASSUME_NONNULL_END
28.9375
250
0.769978
[ "object", "model" ]
feac5c7c5fe4ee7fc8088aafcce2267904d2c7b3
692
h
C
tool_kits/duilib/Box/TileBox.h
nmgwddj/Logs-Manager
cb02ecd090a65df7b4e1b09bb1de704898137fdb
[ "BSD-2-Clause" ]
39
2018-10-19T03:41:32.000Z
2022-03-01T04:36:04.000Z
tool_kits/duilib/Box/TileBox.h
nmgwddj/Logs-Manager
cb02ecd090a65df7b4e1b09bb1de704898137fdb
[ "BSD-2-Clause" ]
3
2019-08-24T15:55:27.000Z
2021-12-10T08:05:01.000Z
tool_kits/duilib/Box/TileBox.h
nmgwddj/Logs-Manager
cb02ecd090a65df7b4e1b09bb1de704898137fdb
[ "BSD-2-Clause" ]
24
2018-11-09T13:29:44.000Z
2022-02-17T07:15:46.000Z
#ifndef UI_CORE_TILEBOX_H_ #define UI_CORE_TILEBOX_H_ #pragma once namespace ui { class UILIB_API TileLayout : public Layout { public: TileLayout(); virtual CSize ArrangeChild(const std::vector<Control*>& items, UiRect rc) override; virtual CSize AjustSizeByChild(const std::vector<Control*>& items, CSize szAvailable) override; virtual bool SetAttribute(const std::wstring& strName, const std::wstring& strValue) override; CSize GetItemSize() const; void SetItemSize(CSize szItem); int GetColumns() const; void SetColumns(int nCols); protected: int m_nColumns; CSize m_szItem; }; class UILIB_API TileBox : public Box { public: TileBox(); }; } #endif // UI_CORE_TILEBOX_H_
19.222222
96
0.764451
[ "vector" ]
feb23fc738343aeb1ed177b0b45316f945322913
4,216
h
C
frameworks/src/core/modules/presets/console_module.h
openharmony-gitee-mirror/ace_engine_lite
94ec4d9667f586888090342f231ae3c9294df621
[ "Apache-2.0" ]
5
2020-09-11T07:48:21.000Z
2021-10-21T23:43:59.000Z
src/core/modules/presets/console_module.h
OpenHarmony-mirror/ace_lite_jsfwk
45b0cacc94cf48fb140dcfd596a86890da3921f2
[ "Apache-2.0" ]
null
null
null
src/core/modules/presets/console_module.h
OpenHarmony-mirror/ace_lite_jsfwk
45b0cacc94cf48fb140dcfd596a86890da3921f2
[ "Apache-2.0" ]
1
2021-09-13T11:57:16.000Z
2021-09-13T11:57:16.000Z
/* * Copyright (c) 2020 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ACELITE_CONSOLE_MODULE_H #define OHOS_ACELITE_CONSOLE_MODULE_H #include "non_copyable.h" #include "presets/preset_module.h" namespace OHOS { namespace ACELite { static constexpr char console[] = "console"; class ConsoleModule final : public PresetModule { public: ACE_DISALLOW_COPY_AND_MOVE(ConsoleModule); /** * @fn ConsoleModule::ConsoleModule() * * @brief Constructor. */ ConsoleModule() : PresetModule(console) {} /** * @fn ConsoleModule::~ConsoleModule() * * @brief Constructor. */ ~ConsoleModule() = default; void Init() override; static void Load() { ConsoleModule consoleModule; consoleModule.Init(); } private: /** * @fn ConsoleModule::LogDebug() * * @brief Outputs a message to the console with the log level "debug". * @param func function object * @param context the context of function execution * @param args the list of arguments * @param length the length of arguments list */ static jerry_value_t LogDebug(const jerry_value_t func, const jerry_value_t context, const jerry_value_t* args, const jerry_length_t length); /** * @fn ConsoleModule::LogInfo() * * @brief Outputs a message to the console with the log level "info". * @param func function object * @param context the context of function execution * @param args the list of arguments * @param length the length of arguments list */ static jerry_value_t LogInfo(const jerry_value_t func, const jerry_value_t context, const jerry_value_t* args, const jerry_length_t length); /** * @fn ConsoleModule::LogWarn() * * @brief Outputs a message to the console with the log level "warn". * @param func function object * @param context the context of function execution * @param args the list of arguments * @param length the length of arguments list */ static jerry_value_t LogWarn(const jerry_value_t func, const jerry_value_t context, const jerry_value_t* args, const jerry_length_t length); /** * @fn ConsoleModule::Log() * * @brief Outputs a message to the console with the log level "log". * @param func function object * @param context the context of function execution * @param args the list of arguments * @param length the length of arguments list */ static jerry_value_t Log(const jerry_value_t func, const jerry_value_t context, const jerry_value_t* args, const jerry_length_t length); /** * @fn ConsoleModule::LogError() * * @brief Outputs a message to the console with the log level "error". * @param func function object * @param context the context of function execution * @param args the list of arguments * @param length the length of arguments list */ static jerry_value_t LogError(const jerry_value_t func, const jerry_value_t context, const jerry_value_t* args, const jerry_length_t length); }; } // namespace ACELite } // namespace OHOS #endif // OHOS_ACELITE_CONSOLE_MODULE_H
34
75
0.613852
[ "object" ]
fec9435b3b28b840bf752ed7f728b257f0a40b0d
21,687
h
C
src/seafile/seafile-object.h
mauz85/seafile-client
8080492507cd9371649973384aae075eed476e11
[ "Apache-2.0" ]
null
null
null
src/seafile/seafile-object.h
mauz85/seafile-client
8080492507cd9371649973384aae075eed476e11
[ "Apache-2.0" ]
null
null
null
src/seafile/seafile-object.h
mauz85/seafile-client
8080492507cd9371649973384aae075eed476e11
[ "Apache-2.0" ]
null
null
null
/* seafile-object.h generated by valac 0.40.8, the Vala compiler, do not modify */ #ifndef __SEAFILE_OBJECT_H__ #define __SEAFILE_OBJECT_H__ #include <glib.h> #include <glib-object.h> G_BEGIN_DECLS #define SEAFILE_TYPE_REPO (seafile_repo_get_type ()) #define SEAFILE_REPO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_REPO, SeafileRepo)) #define SEAFILE_REPO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_REPO, SeafileRepoClass)) #define SEAFILE_IS_REPO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_REPO)) #define SEAFILE_IS_REPO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_REPO)) #define SEAFILE_REPO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_REPO, SeafileRepoClass)) typedef struct _SeafileRepo SeafileRepo; typedef struct _SeafileRepoClass SeafileRepoClass; typedef struct _SeafileRepoPrivate SeafileRepoPrivate; #define SEAFILE_TYPE_SYNC_TASK (seafile_sync_task_get_type ()) #define SEAFILE_SYNC_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_SYNC_TASK, SeafileSyncTask)) #define SEAFILE_SYNC_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_SYNC_TASK, SeafileSyncTaskClass)) #define SEAFILE_IS_SYNC_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_SYNC_TASK)) #define SEAFILE_IS_SYNC_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_SYNC_TASK)) #define SEAFILE_SYNC_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_SYNC_TASK, SeafileSyncTaskClass)) typedef struct _SeafileSyncTask SeafileSyncTask; typedef struct _SeafileSyncTaskClass SeafileSyncTaskClass; typedef struct _SeafileSyncTaskPrivate SeafileSyncTaskPrivate; #define SEAFILE_TYPE_SESSION_INFO (seafile_session_info_get_type ()) #define SEAFILE_SESSION_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_SESSION_INFO, SeafileSessionInfo)) #define SEAFILE_SESSION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_SESSION_INFO, SeafileSessionInfoClass)) #define SEAFILE_IS_SESSION_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_SESSION_INFO)) #define SEAFILE_IS_SESSION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_SESSION_INFO)) #define SEAFILE_SESSION_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_SESSION_INFO, SeafileSessionInfoClass)) typedef struct _SeafileSessionInfo SeafileSessionInfo; typedef struct _SeafileSessionInfoClass SeafileSessionInfoClass; typedef struct _SeafileSessionInfoPrivate SeafileSessionInfoPrivate; #define SEAFILE_TYPE_DIFF_ENTRY (seafile_diff_entry_get_type ()) #define SEAFILE_DIFF_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_DIFF_ENTRY, SeafileDiffEntry)) #define SEAFILE_DIFF_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_DIFF_ENTRY, SeafileDiffEntryClass)) #define SEAFILE_IS_DIFF_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_DIFF_ENTRY)) #define SEAFILE_IS_DIFF_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_DIFF_ENTRY)) #define SEAFILE_DIFF_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_DIFF_ENTRY, SeafileDiffEntryClass)) typedef struct _SeafileDiffEntry SeafileDiffEntry; typedef struct _SeafileDiffEntryClass SeafileDiffEntryClass; typedef struct _SeafileDiffEntryPrivate SeafileDiffEntryPrivate; #define SEAFILE_TYPE_ENCRYPTION_INFO (seafile_encryption_info_get_type ()) #define SEAFILE_ENCRYPTION_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_ENCRYPTION_INFO, SeafileEncryptionInfo)) #define SEAFILE_ENCRYPTION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_ENCRYPTION_INFO, SeafileEncryptionInfoClass)) #define SEAFILE_IS_ENCRYPTION_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_ENCRYPTION_INFO)) #define SEAFILE_IS_ENCRYPTION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_ENCRYPTION_INFO)) #define SEAFILE_ENCRYPTION_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_ENCRYPTION_INFO, SeafileEncryptionInfoClass)) typedef struct _SeafileEncryptionInfo SeafileEncryptionInfo; typedef struct _SeafileEncryptionInfoClass SeafileEncryptionInfoClass; typedef struct _SeafileEncryptionInfoPrivate SeafileEncryptionInfoPrivate; #define SEAFILE_TYPE_FILE_SYNC_ERROR (seafile_file_sync_error_get_type ()) #define SEAFILE_FILE_SYNC_ERROR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_FILE_SYNC_ERROR, SeafileFileSyncError)) #define SEAFILE_FILE_SYNC_ERROR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_FILE_SYNC_ERROR, SeafileFileSyncErrorClass)) #define SEAFILE_IS_FILE_SYNC_ERROR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_FILE_SYNC_ERROR)) #define SEAFILE_IS_FILE_SYNC_ERROR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_FILE_SYNC_ERROR)) #define SEAFILE_FILE_SYNC_ERROR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_FILE_SYNC_ERROR, SeafileFileSyncErrorClass)) typedef struct _SeafileFileSyncError SeafileFileSyncError; typedef struct _SeafileFileSyncErrorClass SeafileFileSyncErrorClass; typedef struct _SeafileFileSyncErrorPrivate SeafileFileSyncErrorPrivate; #define SEAFILE_TYPE_TASK (seafile_task_get_type ()) #define SEAFILE_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_TASK, SeafileTask)) #define SEAFILE_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_TASK, SeafileTaskClass)) #define SEAFILE_IS_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_TASK)) #define SEAFILE_IS_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_TASK)) #define SEAFILE_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_TASK, SeafileTaskClass)) typedef struct _SeafileTask SeafileTask; typedef struct _SeafileTaskClass SeafileTaskClass; typedef struct _SeafileTaskPrivate SeafileTaskPrivate; #define SEAFILE_TYPE_CLONE_TASK (seafile_clone_task_get_type ()) #define SEAFILE_CLONE_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAFILE_TYPE_CLONE_TASK, SeafileCloneTask)) #define SEAFILE_CLONE_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAFILE_TYPE_CLONE_TASK, SeafileCloneTaskClass)) #define SEAFILE_IS_CLONE_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAFILE_TYPE_CLONE_TASK)) #define SEAFILE_IS_CLONE_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAFILE_TYPE_CLONE_TASK)) #define SEAFILE_CLONE_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAFILE_TYPE_CLONE_TASK, SeafileCloneTaskClass)) typedef struct _SeafileCloneTask SeafileCloneTask; typedef struct _SeafileCloneTaskClass SeafileCloneTaskClass; typedef struct _SeafileCloneTaskPrivate SeafileCloneTaskPrivate; struct _SeafileRepo { GObject parent_instance; SeafileRepoPrivate * priv; gchar _id[37]; gchar* _name; gchar* _desc; gchar* _worktree; gchar* _relay_id; }; struct _SeafileRepoClass { GObjectClass parent_class; }; struct _SeafileSyncTask { GObject parent_instance; SeafileSyncTaskPrivate * priv; }; struct _SeafileSyncTaskClass { GObjectClass parent_class; }; struct _SeafileSessionInfo { GObject parent_instance; SeafileSessionInfoPrivate * priv; }; struct _SeafileSessionInfoClass { GObjectClass parent_class; }; struct _SeafileDiffEntry { GObject parent_instance; SeafileDiffEntryPrivate * priv; }; struct _SeafileDiffEntryClass { GObjectClass parent_class; }; struct _SeafileEncryptionInfo { GObject parent_instance; SeafileEncryptionInfoPrivate * priv; }; struct _SeafileEncryptionInfoClass { GObjectClass parent_class; }; struct _SeafileFileSyncError { GObject parent_instance; SeafileFileSyncErrorPrivate * priv; }; struct _SeafileFileSyncErrorClass { GObjectClass parent_class; }; struct _SeafileTask { GObject parent_instance; SeafileTaskPrivate * priv; }; struct _SeafileTaskClass { GObjectClass parent_class; }; struct _SeafileCloneTask { GObject parent_instance; SeafileCloneTaskPrivate * priv; }; struct _SeafileCloneTaskClass { GObjectClass parent_class; }; GType seafile_repo_get_type (void) G_GNUC_CONST; SeafileRepo* seafile_repo_new (void); SeafileRepo* seafile_repo_construct (GType object_type); const gchar* seafile_repo_get_id (SeafileRepo* self); void seafile_repo_set_id (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_name (SeafileRepo* self); void seafile_repo_set_name (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_desc (SeafileRepo* self); void seafile_repo_set_desc (SeafileRepo* self, const gchar* value); gint seafile_repo_get_version (SeafileRepo* self); void seafile_repo_set_version (SeafileRepo* self, gint value); gint seafile_repo_get_last_modify (SeafileRepo* self); void seafile_repo_set_last_modify (SeafileRepo* self, gint value); gint64 seafile_repo_get_size (SeafileRepo* self); void seafile_repo_set_size (SeafileRepo* self, gint64 value); gint64 seafile_repo_get_file_count (SeafileRepo* self); void seafile_repo_set_file_count (SeafileRepo* self, gint64 value); const gchar* seafile_repo_get_head_cmmt_id (SeafileRepo* self); void seafile_repo_set_head_cmmt_id (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_root (SeafileRepo* self); void seafile_repo_set_root (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_repo_id (SeafileRepo* self); void seafile_repo_set_repo_id (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_repo_name (SeafileRepo* self); void seafile_repo_set_repo_name (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_repo_desc (SeafileRepo* self); void seafile_repo_set_repo_desc (SeafileRepo* self, const gchar* value); gint seafile_repo_get_last_modified (SeafileRepo* self); void seafile_repo_set_last_modified (SeafileRepo* self, gint value); gboolean seafile_repo_get_encrypted (SeafileRepo* self); void seafile_repo_set_encrypted (SeafileRepo* self, gboolean value); const gchar* seafile_repo_get_magic (SeafileRepo* self); void seafile_repo_set_magic (SeafileRepo* self, const gchar* value); gint seafile_repo_get_enc_version (SeafileRepo* self); void seafile_repo_set_enc_version (SeafileRepo* self, gint value); const gchar* seafile_repo_get_random_key (SeafileRepo* self); void seafile_repo_set_random_key (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_salt (SeafileRepo* self); void seafile_repo_set_salt (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_worktree (SeafileRepo* self); void seafile_repo_set_worktree (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_relay_id (SeafileRepo* self); void seafile_repo_set_relay_id (SeafileRepo* self, const gchar* value); gint seafile_repo_get_last_sync_time (SeafileRepo* self); void seafile_repo_set_last_sync_time (SeafileRepo* self, gint value); gboolean seafile_repo_get_auto_sync (SeafileRepo* self); void seafile_repo_set_auto_sync (SeafileRepo* self, gboolean value); gboolean seafile_repo_get_worktree_invalid (SeafileRepo* self); void seafile_repo_set_worktree_invalid (SeafileRepo* self, gboolean value); gboolean seafile_repo_get_is_virtual (SeafileRepo* self); void seafile_repo_set_is_virtual (SeafileRepo* self, gboolean value); const gchar* seafile_repo_get_origin_repo_id (SeafileRepo* self); void seafile_repo_set_origin_repo_id (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_origin_repo_name (SeafileRepo* self); void seafile_repo_set_origin_repo_name (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_origin_path (SeafileRepo* self); void seafile_repo_set_origin_path (SeafileRepo* self, const gchar* value); gboolean seafile_repo_get_is_original_owner (SeafileRepo* self); void seafile_repo_set_is_original_owner (SeafileRepo* self, gboolean value); const gchar* seafile_repo_get_virtual_perm (SeafileRepo* self); void seafile_repo_set_virtual_perm (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_store_id (SeafileRepo* self); void seafile_repo_set_store_id (SeafileRepo* self, const gchar* value); gboolean seafile_repo_get_is_corrupted (SeafileRepo* self); void seafile_repo_set_is_corrupted (SeafileRepo* self, gboolean value); gboolean seafile_repo_get_repaired (SeafileRepo* self); void seafile_repo_set_repaired (SeafileRepo* self, gboolean value); const gchar* seafile_repo_get_share_type (SeafileRepo* self); void seafile_repo_set_share_type (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_permission (SeafileRepo* self); void seafile_repo_set_permission (SeafileRepo* self, const gchar* value); const gchar* seafile_repo_get_user (SeafileRepo* self); void seafile_repo_set_user (SeafileRepo* self, const gchar* value); gint seafile_repo_get_group_id (SeafileRepo* self); void seafile_repo_set_group_id (SeafileRepo* self, gint value); gboolean seafile_repo_get_is_shared (SeafileRepo* self); void seafile_repo_set_is_shared (SeafileRepo* self, gboolean value); GType seafile_sync_task_get_type (void) G_GNUC_CONST; SeafileSyncTask* seafile_sync_task_new (void); SeafileSyncTask* seafile_sync_task_construct (GType object_type); gboolean seafile_sync_task_get_force_upload (SeafileSyncTask* self); void seafile_sync_task_set_force_upload (SeafileSyncTask* self, gboolean value); const gchar* seafile_sync_task_get_repo_id (SeafileSyncTask* self); void seafile_sync_task_set_repo_id (SeafileSyncTask* self, const gchar* value); const gchar* seafile_sync_task_get_state (SeafileSyncTask* self); void seafile_sync_task_set_state (SeafileSyncTask* self, const gchar* value); gint seafile_sync_task_get_error (SeafileSyncTask* self); void seafile_sync_task_set_error (SeafileSyncTask* self, gint value); GType seafile_session_info_get_type (void) G_GNUC_CONST; SeafileSessionInfo* seafile_session_info_new (void); SeafileSessionInfo* seafile_session_info_construct (GType object_type); const gchar* seafile_session_info_get_datadir (SeafileSessionInfo* self); void seafile_session_info_set_datadir (SeafileSessionInfo* self, const gchar* value); GType seafile_diff_entry_get_type (void) G_GNUC_CONST; SeafileDiffEntry* seafile_diff_entry_new (void); SeafileDiffEntry* seafile_diff_entry_construct (GType object_type); const gchar* seafile_diff_entry_get_status (SeafileDiffEntry* self); void seafile_diff_entry_set_status (SeafileDiffEntry* self, const gchar* value); const gchar* seafile_diff_entry_get_name (SeafileDiffEntry* self); void seafile_diff_entry_set_name (SeafileDiffEntry* self, const gchar* value); const gchar* seafile_diff_entry_get_new_name (SeafileDiffEntry* self); void seafile_diff_entry_set_new_name (SeafileDiffEntry* self, const gchar* value); GType seafile_encryption_info_get_type (void) G_GNUC_CONST; SeafileEncryptionInfo* seafile_encryption_info_new (void); SeafileEncryptionInfo* seafile_encryption_info_construct (GType object_type); const gchar* seafile_encryption_info_get_repo_id (SeafileEncryptionInfo* self); void seafile_encryption_info_set_repo_id (SeafileEncryptionInfo* self, const gchar* value); const gchar* seafile_encryption_info_get_passwd (SeafileEncryptionInfo* self); void seafile_encryption_info_set_passwd (SeafileEncryptionInfo* self, const gchar* value); gint seafile_encryption_info_get_enc_version (SeafileEncryptionInfo* self); void seafile_encryption_info_set_enc_version (SeafileEncryptionInfo* self, gint value); const gchar* seafile_encryption_info_get_magic (SeafileEncryptionInfo* self); void seafile_encryption_info_set_magic (SeafileEncryptionInfo* self, const gchar* value); const gchar* seafile_encryption_info_get_random_key (SeafileEncryptionInfo* self); void seafile_encryption_info_set_random_key (SeafileEncryptionInfo* self, const gchar* value); const gchar* seafile_encryption_info_get_salt (SeafileEncryptionInfo* self); void seafile_encryption_info_set_salt (SeafileEncryptionInfo* self, const gchar* value); GType seafile_file_sync_error_get_type (void) G_GNUC_CONST; SeafileFileSyncError* seafile_file_sync_error_new (void); SeafileFileSyncError* seafile_file_sync_error_construct (GType object_type); gint seafile_file_sync_error_get_id (SeafileFileSyncError* self); void seafile_file_sync_error_set_id (SeafileFileSyncError* self, gint value); const gchar* seafile_file_sync_error_get_repo_id (SeafileFileSyncError* self); void seafile_file_sync_error_set_repo_id (SeafileFileSyncError* self, const gchar* value); const gchar* seafile_file_sync_error_get_repo_name (SeafileFileSyncError* self); void seafile_file_sync_error_set_repo_name (SeafileFileSyncError* self, const gchar* value); const gchar* seafile_file_sync_error_get_path (SeafileFileSyncError* self); void seafile_file_sync_error_set_path (SeafileFileSyncError* self, const gchar* value); gint seafile_file_sync_error_get_err_id (SeafileFileSyncError* self); void seafile_file_sync_error_set_err_id (SeafileFileSyncError* self, gint value); gint64 seafile_file_sync_error_get_timestamp (SeafileFileSyncError* self); void seafile_file_sync_error_set_timestamp (SeafileFileSyncError* self, gint64 value); GType seafile_task_get_type (void) G_GNUC_CONST; SeafileTask* seafile_task_new (void); SeafileTask* seafile_task_construct (GType object_type); const gchar* seafile_task_get_ttype (SeafileTask* self); void seafile_task_set_ttype (SeafileTask* self, const gchar* value); const gchar* seafile_task_get_repo_id (SeafileTask* self); void seafile_task_set_repo_id (SeafileTask* self, const gchar* value); const gchar* seafile_task_get_state (SeafileTask* self); void seafile_task_set_state (SeafileTask* self, const gchar* value); const gchar* seafile_task_get_rt_state (SeafileTask* self); void seafile_task_set_rt_state (SeafileTask* self, const gchar* value); gint64 seafile_task_get_block_total (SeafileTask* self); void seafile_task_set_block_total (SeafileTask* self, gint64 value); gint64 seafile_task_get_block_done (SeafileTask* self); void seafile_task_set_block_done (SeafileTask* self, gint64 value); gint seafile_task_get_fs_objects_total (SeafileTask* self); void seafile_task_set_fs_objects_total (SeafileTask* self, gint value); gint seafile_task_get_fs_objects_done (SeafileTask* self); void seafile_task_set_fs_objects_done (SeafileTask* self, gint value); gint seafile_task_get_rate (SeafileTask* self); void seafile_task_set_rate (SeafileTask* self, gint value); GType seafile_clone_task_get_type (void) G_GNUC_CONST; SeafileCloneTask* seafile_clone_task_new (void); SeafileCloneTask* seafile_clone_task_construct (GType object_type); const gchar* seafile_clone_task_get_state (SeafileCloneTask* self); void seafile_clone_task_set_state (SeafileCloneTask* self, const gchar* value); gint seafile_clone_task_get_error (SeafileCloneTask* self); void seafile_clone_task_set_error (SeafileCloneTask* self, gint value); const gchar* seafile_clone_task_get_repo_id (SeafileCloneTask* self); void seafile_clone_task_set_repo_id (SeafileCloneTask* self, const gchar* value); const gchar* seafile_clone_task_get_repo_name (SeafileCloneTask* self); void seafile_clone_task_set_repo_name (SeafileCloneTask* self, const gchar* value); const gchar* seafile_clone_task_get_worktree (SeafileCloneTask* self); void seafile_clone_task_set_worktree (SeafileCloneTask* self, const gchar* value); G_END_DECLS #endif
51.390995
140
0.75211
[ "object" ]
e0b0531711d05ee147a897006166bba4ee1b4632
5,036
h
C
gamedata/shaders/r2/ogse_reflections.h
WarezzK/OGSE-WarezzKCZ-gamedata
37a767c9eb5de99ff6dd4e9f2562f43c98c5dbfb
[ "Apache-2.0" ]
3
2019-09-10T13:37:08.000Z
2021-05-18T14:53:29.000Z
gamedata/shaders/r2/ogse_reflections.h
WarezzK/OGSE-WarezzKCZ-gamedata
37a767c9eb5de99ff6dd4e9f2562f43c98c5dbfb
[ "Apache-2.0" ]
null
null
null
gamedata/shaders/r2/ogse_reflections.h
WarezzK/OGSE-WarezzKCZ-gamedata
37a767c9eb5de99ff6dd4e9f2562f43c98c5dbfb
[ "Apache-2.0" ]
2
2020-06-26T11:50:59.000Z
2020-12-30T11:07:31.000Z
#ifndef OGSE_REFLECTIONS_H #define OGSE_REFLECTIONS_H #ifndef REFLECTIONS_QUALITY #define REFLECTIONS_QUALITY 1 #endif #define EPS 0.001 //#ifdef USE_HQ_REFLECTIONS static const float2 resolution = ogse_c_resolution.xy; static const float2 inv_resolution = ogse_c_resolution.zw; /*#else static const float2 resolution = ogse_c_resolution.xy*0.5; static const float2 inv_resolution = ogse_c_resolution.zw*2; #endif*/ #define REFL_WATER 0 #define REFL_GROUND 1 #define REFL_BOTH 2 uniform samplerCUBE s_env0; uniform samplerCUBE s_env1; float4 get_reflection (float3 screen_pixel_pos, float3 next_screen_pixel_pos, float3 reflect) { float4 final_color = {1.0,1.0,1.0,1.0}; float2 factors = {1.f,1.f}; float3 main_vec = next_screen_pixel_pos - screen_pixel_pos; float3 grad_vec = main_vec / (max(abs(main_vec.x), abs(main_vec.y)) * 256); // handle case when reflect vector faces the camera factors.x = dot(eye_direction, reflect); [branch] if (factors.x < -0.5) return final_color; float3 curr_pixel = screen_pixel_pos; curr_pixel.xy += float2(0.5,0.5)*ogse_c_resolution.zw; float max_it = 140; #if (REFLECTIONS_QUALITY == 1) grad_vec *= 2; max_it *= 0.5; #endif float i = 0; while (i < max_it) { curr_pixel.xyz += grad_vec.xyz; /* if ((curr_pixel.x > 0.99) || (curr_pixel.y > 0.99) || (curr_pixel.x < 0.01) || (curr_pixel.y < 0.01)) { final_color.xyz = float3(1.0,0.0,0.0); break; }*/ float depth = get_depth_fast(curr_pixel.xy); depth = lerp(depth, 0.f, is_sky(depth)); // depth += 1000*step(depth, 1.0); float delta = step(depth, curr_pixel.z)*step(screen_pixel_pos.z, depth); if (delta > 0.5) // if ((depth < curr_pixel.z) && (screen_pixel_pos.z < depth)) { //#if (REFLECTIONS_QUALITY == 1) // float2 tc = floor(curr_pixel.xy*ogse_c_resolution.xy); // tc *= ogse_c_resolution.zw; // final_color.xyz = tex2Dlod(s_image, float4(tc.xy,0,0)).xyz; final_color.xyz = tex2Dlod(s_image, float4(curr_pixel.xy,0,0)).xyz; float2 temp = curr_pixel.xy; // make sure that there is no fade down the screen temp.y = lerp(temp.y, 0.5, step(0.5, temp.y)); float screendedgefact = saturate(distance(temp , float2(0.5, 0.5)) * 2.0); final_color.w = pow(screendedgefact,6);// * screendedgefact; //#endif break; } i += 1.0; } #if (REFLECTIONS_QUALITY == 2) if (i >= max_it) return final_color; curr_pixel.xyz -= grad_vec.xyz; grad_vec *= 0.125; for (int i = 0; i < 8; ++i) { curr_pixel.xyz += grad_vec.xyz; /* if ((curr_pixel.x > 1.0) || (curr_pixel.y > 1.0) || (curr_pixel.x < 0.0) || (curr_pixel.y < 0.0)) { final_color.xyz = float3(1.0,0.0,0.0); break; }*/ float depth = get_depth_fast(curr_pixel.xy); depth = lerp(depth, 0.f, is_sky(depth)); // depth += 1000*step(depth, 1.0); float delta = step(depth, curr_pixel.z)*step(screen_pixel_pos.z, depth); if (delta > 0.5) { // edge detect final_color.xyz = tex2Dlod(s_image, float4(curr_pixel.xy,0,0)).xyz; float2 temp = curr_pixel.xy; // make sure that there is no fade down the screen temp.y = lerp(temp.y, 0.5, step(0.5, temp.y)); float screendedgefact = saturate(distance(temp , float2(0.5, 0.5)) * 2.0); final_color.w = pow(screendedgefact,6);// * screendedgefact; break; } ++i; } #endif return final_color; } float3 calc_envmap(float3 vreflect) { // vreflect.y = vreflect.y*2-1; float3 env0 = texCUBElod (s_env0, float4(vreflect.xyz, 0)).xyz; float3 env1 = texCUBElod (s_env1, float4(vreflect.xyz, 0)).xyz; return lerp (env0,env1,L_ambient.w); } float4 calc_reflections(float4 pos, float3 vreflect) { float4 refl = {1.0,1.0,1.0,1.0}; #ifdef USE_REFLECTIONS float3 v_pixel_pos = mul((float3x4)m_V, pos); float4 p_pixel_pos = mul(m_VP, pos); float4 s_pixel_pos = proj_to_screen(p_pixel_pos); s_pixel_pos.xy /= s_pixel_pos.w; s_pixel_pos.z = v_pixel_pos.z; float3 reflect_vec = normalize(vreflect); float3 W_m_point = pos.xyz + reflect_vec; float3 V_m_point = mul((float3x4)m_V, float4(W_m_point, 1.0)); float4 P_m_point = mul(m_VP, float4(W_m_point, 1.0)); float4 S_m_point = proj_to_screen(P_m_point); S_m_point.xy /= S_m_point.w; S_m_point.z = V_m_point.z; refl = get_reflection(s_pixel_pos.xyz, S_m_point.xyz, reflect_vec); #endif return refl; } float4 calc_reflections_late_out(float4 pos, float3 vreflect, float sw) { float4 refl = {1.0,1.0,1.0,1.0}; #ifdef USE_REFLECTIONS float3 v_pixel_pos = mul((float3x4)m_V, pos); float4 p_pixel_pos = mul(m_VP, pos); float4 s_pixel_pos = proj_to_screen(p_pixel_pos); s_pixel_pos.xy /= s_pixel_pos.w; s_pixel_pos.z = v_pixel_pos.z; float3 reflect_vec = normalize(vreflect); float3 W_m_point = pos.xyz + reflect_vec; float3 V_m_point = mul((float3x4)m_V, float4(W_m_point, 1.0)); float4 P_m_point = mul(m_VP, float4(W_m_point, 1.0)); float4 S_m_point = proj_to_screen(P_m_point); S_m_point.xy /= S_m_point.w; S_m_point.z = V_m_point.z; if (sw > 0.01) refl = get_reflection(s_pixel_pos.xyz, S_m_point.xyz, reflect_vec); #endif return refl; } #endif
30.155689
106
0.696386
[ "vector" ]
e0bea2c367b6a6d517b6a17f7e951c8f5e438a86
13,423
h
C
src/core/lib/math/interface.h
marcelmon/PALISADE_capstone
2cfd1626b26576f8fe93bb3a424f934ef700c5b2
[ "BSD-2-Clause" ]
null
null
null
src/core/lib/math/interface.h
marcelmon/PALISADE_capstone
2cfd1626b26576f8fe93bb3a424f934ef700c5b2
[ "BSD-2-Clause" ]
null
null
null
src/core/lib/math/interface.h
marcelmon/PALISADE_capstone
2cfd1626b26576f8fe93bb3a424f934ef700c5b2
[ "BSD-2-Clause" ]
null
null
null
/** * @file interface.h This file contains the interfaces for math data types * @author TPOC: palisade@njit.edu * * @copyright Copyright (c) 2017, New Jersey Institute of Technology (NJIT) * All rights reserved. * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef LBCRYPTO_MATH_INTERFACE_H #define LBCRYPTO_MATH_INTERFACE_H namespace lbcrypto { template<typename BigInteger> class BigIntegerInterface { public: //Constructors - cannot be added to the Interface directly /** * Basic constructor. */ // BigInteger() = 0; /** * Basic constructor for initializing big binary integer from an unsigned integer. * * @param init is the initial integer. */ // explicit BigInteger(usint init); /** * Basic constructor for specifying the integer. * * @param str is the initial integer represented as a string. */ // explicit BigInteger(const std::string& str); /** * Basic constructor for copying a big binary integer * * @param bigInteger is the big binary integer to be copied. */ // explicit BigInteger(const BigInteger& bigInteger); /** * Basic constructor for move copying a big binary integer * * @param &&bigInteger is the big binary integer to be copied. */ // BigInteger(BigInteger &&bigInteger);//move copy constructor /** * ??? * * @param &rhs is the big binary integer to test equality with. * @return the return value. */ virtual BigInteger& operator=(const BigInteger &rhs) = 0; /** * ??? * * @param &&rhs is the big binary integer to test equality with. * @return the return value. */ virtual BigInteger& operator=(BigInteger &&rhs) = 0; /** * Destructor. */ // ~BigInteger(); //ACCESSORS /** * Basic set method for setting the value of a big binary integer * * @param str is the string representation of the big binary integer to be copied. */ virtual void SetValue(const std::string& str) = 0; //METHODS ////regular aritmethic operations /** * Addition operation. * * @param b is the value to add. * @return is the result of the addition operation. */ virtual BigInteger Plus(const BigInteger& b) const = 0; ///** // * Subtraction operation. // * // * @param b is the value to subtract. // * @return is the result of the subtraction operation. // */ virtual BigInteger Minus(const BigInteger& b) const = 0; ///** // * Multiplication operation. // * // * @param b is the value to multiply with. // * @return is the result of the multiplication operation. // */ virtual BigInteger Times(const BigInteger& b) const = 0; ///** // * Division operation. // * // * @param b is the value to divide by. // * @return is the result of the division operation. // */ virtual BigInteger DividedBy(const BigInteger& b) const = 0; //modular arithmetic operations /** * returns the modulus with respect to the input value. * * @param modulus is the modulus to perform. * @return is the result of the modulus operation. */ virtual BigInteger Mod(const BigInteger& modulus) const = 0; //Barrett modular reduction algorithm - used in NTT /** * returns the Barret modulus with respect to the input modulus and the Barrett value. * * @param modulus is the modulus to perform. * @param mu is the Barrett value. * @return is the result of the modulus operation. */ virtual BigInteger ModBarrett(const BigInteger& modulus, const BigInteger& mu) const = 0; /** * returns the modulus inverse with respect to the input value. * * @param modulus is the modulus to perform. * @return is the result of the modulus inverse operation. */ virtual BigInteger ModInverse(const BigInteger& modulus) const = 0; /** * Scalar modulus addition. * * @param &b is the scalar to add. * @param modulus is the modulus to perform operations with. * @return is the result of the modulus addition operation. */ virtual BigInteger ModAdd(const BigInteger& b, const BigInteger& modulus) const = 0; /** * Scalar modulus subtraction. * * @param &b is the scalar to subtract. * @param modulus is the modulus to perform operations with. * @return is the result of the modulus subtraction operation. */ virtual BigInteger ModSub(const BigInteger& b, const BigInteger& modulus) const = 0; /** * Scalar modulus multiplication. * * @param &b is the scalar to multiply. * @param modulus is the modulus to perform operations with. * @return is the result of the modulus multiplication operation. */ virtual BigInteger ModMul(const BigInteger& b, const BigInteger& modulus) const = 0; /** * Scalar Barrett modulus multiplication. * * @param &b is the scalar to multiply. * @param modulus is the modulus to perform operations with. * @param mu is the Barrett value. * @return is the result of the modulus multiplication operation. */ virtual BigInteger ModBarrettMul(const BigInteger& b, const BigInteger& modulus,const BigInteger& mu) const = 0; /** * Scalar modulus exponentiation. * * @param &b is the scalar to exponentiate at all locations. * @param modulus is the modulus to perform operations with. * @return is the result of the modulus exponentiation operation. */ virtual BigInteger ModExp(const BigInteger& b, const BigInteger& modulus) const = 0; /** * Addition accumulator. * * @param &b is the value to add. * @return is the result of the addition operation. */ virtual const BigInteger& operator+=(const BigInteger &b) = 0; /** * Subtraction accumulator. * * @param &b is the value to subtract. * @return is the result of the subtraction operation. */ virtual const BigInteger& operator-=(const BigInteger &b) = 0; ////bit shifting operators /** * Left shift operator and creates a new variable as output. * * @param shift is the amount to shift. * @return the result of the shift. */ virtual BigInteger operator<<(usshort shift) const = 0; /** * Right shift operator and creates a new variable as output. * * @param shift is the amount to shift. * @return the result of the shift. */ virtual BigInteger operator>>(usshort shift) const = 0; /** * Left shift operator uses in-place algorithm and operates on the same variable. It is used to reduce the copy constructor call. * * @param shift is the amount to shift. * @return the result of the shift. */ virtual const BigInteger& operator<<=(usshort shift) = 0; /** * Right shift operator uses in-place algorithm and operates on the same variable. It is used to reduce the copy constructor call. * * @param shift is the amount to shift. * @return the result of the shift. */ virtual const BigInteger& operator>>=(usshort shift) = 0; //virtual friend methods are not allowed in abstract classes //input/output operators /** * ??? * * @param os the output stream. * @param &ptr_obj ???. * @return the return value. */ //virtual friend std::ostream& operator<<(std::ostream& os, const BigInteger &ptr_obj); /** * Stores the value of this BigInteger in a string object and returns it. * Added by Arnab Deb Gupta <ad479@njit.edu> on 9/21/15. * * @return the value of this BigInteger as a string. */ virtual std::string ToString() const = 0; /** * Returns the MSB location of the value. * * @return the index of the most significant bit. */ virtual usint GetMSB()const = 0; /** * Get the number of digits using a specific base - support for arbitrary base may be needed. * * @param base is the base with which to determine length in. * @return the length of the representation in a specific base. */ virtual usint GetLengthForBase(usint base) const = 0; /** * Get the number of digits using a specific base - support for arbitrary base may be needed. * * @param index is the location to return value from in the specific base. * @param base is the base with which to determine length in. * @return the length of the representation in a specific base. */ virtual usint GetDigitAtIndexForBase(usint index, usint base) const = 0; /** * Convert the value to an int. * * @return the int representation of the value. */ virtual usint ConvertToInt() const = 0; //static methods cannot be added to the interface /** * Convert a value from an int to a BigInteger. * * @param the value to convert from. * @return the int represented as a big binary int. */ //static BigInteger intToBigIntegereger(usint m); ////constant definations /** * Constant zero. */ //const static BigInteger ZERO; /** * Constant one. */ //const static BigInteger ONE; /** * Constant two. */ //const static BigInteger TWO; /** * Test equality of the inputs. * * @param a first value to test. * @param b second value to test. * @return true if the inputs are equal. */ //friend bool operator==(const BigInteger& a, const BigInteger& b); /** * Test inequality of the inputs. * * @param a first value to test. * @param b second value to test. * @return true if the inputs are inequal. */ //friend bool operator!=(const BigInteger& a, const BigInteger& b); /** * Test if first input is great than the second input. * * @param a first value to test. * @param b second value to test. * @return true if the first inputs is greater. */ //friend bool operator> (const BigInteger& a, const BigInteger& b); /** * Test if first input is great than or equal to the second input. * * @param a first value to test. * @param b second value to test. * @return true if the first inputs is greater than or equal to the second input. */ //friend bool operator>=(const BigInteger& a, const BigInteger& b); /** * Test if first input is less than the second input. * * @param a first value to test. * @param b second value to test. * @return true if the first inputs is lesser. */ //friend bool operator< (const BigInteger& a, const BigInteger& b); /** * Test if first input is less than or equal to the second input. * * @param a first value to test. * @param b second value to test. * @return true if the first inputs is less than or equal to the second input. */ //friend bool operator<=(const BigInteger& a, const BigInteger& b); }; //overloaded binary operators based on integer arithmetic and comparison functions /** * Addition operation. * * @param a is the value to add. * @param b is the value to add. * @return is the result of the addition operation. */ //inline BigIntegeregerInterface operator+(const BigIntegeregerInterface &a, const BigIntegeregerInterface &b) {return a.Plus(b);} /** * Subtraction operation. * * @param a is the value to subtract from. * @param b is the value to subtract. * @return is the result of the subtraction operation. */ //inline BigIntegeregerInterface operator-(const BigIntegeregerInterface &a, const BigIntegeregerInterface &b) {return a.Minus(b);} /** * Multiplication operation. * * @param a is the value to multiply with. * @param b is the value to multiply with. * @return is the result of the multiplication operation. */ //inline BigIntegeregerInterface operator*(const BigIntegeregerInterface &a, const BigIntegeregerInterface &b) {return a.Times(b);} /** * Division operation. * * @param a is the value to divide. * @param b is the value to divide by. * @return is the result of the division operation. */ //inline BigIntegeregerInterface operator/(const BigIntegeregerInterface &a, const BigIntegeregerInterface &b) {return a.DividedBy(b);} class BigVectorInterface{}; //will be defined later; all methods will be pure virtual class BigMatrixInterface{}; //will be defined later; all methods will be pure virtual } // namespace lbcrypto ends #endif
30.437642
136
0.679431
[ "object" ]
e0c775d179bf8d21d6830cac557b444c07293c0a
7,090
h
C
src/extended/affinealign.h
satta/genometools
3955d63c95e142c2475e1436206fddf0eb29185d
[ "BSD-2-Clause" ]
202
2015-01-08T10:09:57.000Z
2022-03-31T09:45:44.000Z
src/extended/affinealign.h
satta/genometools
3955d63c95e142c2475e1436206fddf0eb29185d
[ "BSD-2-Clause" ]
286
2015-01-05T16:29:27.000Z
2022-03-30T21:19:03.000Z
src/extended/affinealign.h
satta/genometools
3955d63c95e142c2475e1436206fddf0eb29185d
[ "BSD-2-Clause" ]
56
2015-01-19T11:33:22.000Z
2022-03-21T21:47:05.000Z
/* Copyright (C) 2015 Annika Seidel <annika.seidel@studium.uni-hamburg.de> Copyright (c) 2007 Gordon Gremme <gordon@gremme.org> Copyright (c) 2007-2015 Center for Bioinformatics, University of Hamburg Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef AFFINEALIGN_H #define AFFINEALIGN_H #include "extended/alignment.h" #include "extended/linspace_management.h" #include "extended/scorehandler.h" typedef enum { Affine_R, Affine_D, Affine_I, Affine_X /* unknown */ } GtAffineAlignEdge; /* <AffinealignDPentry> objects describe the information of distance values and backtracing edges relating on last edit operation R,D,I. */ typedef struct { GtWord Rvalue, Dvalue, Ivalue, totalvalue; GtAffineAlignEdge Redge, Dedge, Iedge; } GtAffinealignDPentry; /* Computes a global alignment with affine gapcosts in square space and constant cost values. Use of this function requires input sequences <useq> and <vseq> and lengths <ulen> and <vlen>. The cost values are specified by <matchcost>, <mismatchcost>, <gap_opening_cost> and <gap_extension_cost>. Returns an object of the <GtAlignment> class. */ GtAlignment* gt_affinealign(const GtUchar *u, GtUword ulen, const GtUchar *v, GtUword vlen, GtUword matchcost, GtUword mismatchcost, GtUword gap_opening_cost, GtUword gap_extension_cost); /* Computes a global alignment with affine gapcosts in square space. Use of this function requires an initialised <scorehandler> with cost values an initialised <spacemanager>, the target alignment <align> and input sequences <useq> and <vseq> and lengths <ulen> and <vlen>. Returns affine cost value of global alignment. */ GtWord gt_affinealign_with_Management(GtLinspaceManagement *spacemanager, const GtScoreHandler *scorehandler, GtAlignment *align, const GtUchar *u, GtUword ulen, const GtUchar *v, GtUword vlen); GtWord gt_affinealign_traceback(GtAlignment *align, GtAffinealignDPentry * const *dptable, GtUword i, GtUword j); /* Computes crosspoints for a global alignment with affine gapcosts in square space. Use of this function requires an initialised <spacemanager> an initialised <scorehandler> with cost values, the target crosspoint table <Ctab> and input sequences <useq> and <vseq>, with the regions to align given by their start positions <ustart> and <vstart> and lengths <ulen> and <vlen>. If this function is used in linear context, <rowoffset> is the offset value of the subproblem and <from_edge> and <to_edge> are the in- and outcoming edge of this subproblem. Otherwise set default values 0 and Affine_X. Returns affine distance value of global alignment. */ void gt_affinealign_ctab(GtLinspaceManagement *spacemanager, const GtScoreHandler *scorehandler, GtUword *Ctab, const GtUchar *useq, GtUword ustart, GtUword ulen, const GtUchar *vseq, GtUword vstart, GtUword vlen, GtUword rowoffset, GtAffineAlignEdge from_edge, GtAffineAlignEdge to_edge); /* Computes a local alignment with linear gapcosts in square space. Use of this function requires an initialised <scorehandler> with score values, the target alignment <align> and input sequences <useq> and <vseq>, with the regions to align given by their start positions <ustart> and <vstart> and lengths <ulen> and <vlen>. An initialised <spacemanager> is required to use this function in linear space context, in any other case it can be NULL. Returns score value of local alignment. */ GtWord gt_affinealign_calculate_local_generic(GtLinspaceManagement *spacemanager, const GtScoreHandler *scorehandler, GtAlignment *align, const GtUchar *useq, GtUword ustart, GtUword ulen, const GtUchar *vseq, GtUword vstart, GtUword vlen); /* Computes a local alignment with affine gapcosts in square space and constant score values. Use of this function requires the target alignment <align> and input sequences <useq> and <vseq>, with the regions to align given by their start positions <ustart> and <vstart> and lengths <ulen> and <vlen>. The score values are specified by <matchscore>, <mismatchscore>, <gap_opening> and <gap_extension>. An initialised <spacemanager> is required to use this function in linear space context, in any other case it can be NULL. Returns affine score value of local alignment. */ GtWord gt_affinealign_calculate_local(GtLinspaceManagement *spacemanager, GtAlignment *align, const GtUchar *useq, GtUword ustart, GtUword ulen, const GtUchar *vseq, GtUword vstart, GtUword vlen, GtWord matchscore, GtWord mismatchscore, GtWord gap_opening, GtWord gap_extension); #endif
53.712121
80
0.577715
[ "object" ]
e0cd4042d8054c47a67df6df575aebb4d4cc16a3
738
h
C
src/vm/CallFrame.h
sdizdarevic/tmbasic
fac8edd931eb1a457b93a783bd43134fc76debc5
[ "MIT" ]
49
2020-11-26T10:50:04.000Z
2022-03-29T13:54:51.000Z
src/vm/CallFrame.h
sdizdarevic/tmbasic
fac8edd931eb1a457b93a783bd43134fc76debc5
[ "MIT" ]
5
2020-11-20T23:17:46.000Z
2022-03-31T04:50:03.000Z
src/vm/CallFrame.h
sdizdarevic/tmbasic
fac8edd931eb1a457b93a783bd43134fc76debc5
[ "MIT" ]
5
2021-06-29T13:48:29.000Z
2022-03-10T23:22:18.000Z
#pragma once #include "../common.h" #include "vm/Object.h" #include "vm/Procedure.h" #include "vm/Value.h" namespace vm { class CallFrame { public: const Procedure* const procedure; const size_t instructionIndex; const bool returnsValue; const bool returnsObject; const int numValueArgs; const int vsiArgsStart; const int numObjectArgs; const int osiArgsStart; const int vsiLocalsStart; const int osiLocalsStart; CallFrame( const Procedure* procedure, size_t instructionIndex, int numValueArgs, int numObjectArgs, int valueStackIndex, int objectStackIndex, bool returnsValue, bool returnsObject); }; } // namespace vm
19.421053
37
0.669377
[ "object" ]
e0e60bbf95eec3ac0a4f874bfaefc43e2bfc8bf6
5,486
h
C
Engine/Source/Runtime/Engine/Classes/Sound/DialogueWave.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
1
2022-01-29T18:36:12.000Z
2022-01-29T18:36:12.000Z
Engine/Source/Runtime/Engine/Classes/Sound/DialogueWave.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
Engine/Source/Runtime/Engine/Classes/Sound/DialogueWave.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once /** * Context to sound wave map for spoken dialogue */ #include "CoreMinimal.h" #include "UObject/ObjectMacros.h" #include "UObject/Object.h" #include "Misc/Guid.h" #include "Sound/DialogueTypes.h" #include "DialogueWave.generated.h" class UDialogueSoundWaveProxy; class UDialogueVoice; class USoundBase; class USoundWave; struct FPropertyChangedChainEvent; struct ENGINE_API FDialogueConstants { static const FString DialogueNamespace; static const FString DialogueNotesNamespace; static const FString SubtitleKeySuffix; #if WITH_EDITORONLY_DATA static const FString ActingDirectionKeySuffix; static const FString PropertyName_AudioFile; static const FString PropertyName_VoiceActorDirection; static const FString PropertyName_Speaker; static const FString PropertyName_Targets; static const FString PropertyName_GrammaticalGender; static const FString PropertyName_GrammaticalPlurality; static const FString PropertyName_TargetGrammaticalGender; static const FString PropertyName_TargetGrammaticalNumber; static const FString PropertyName_DialogueContext; static const FString PropertyName_IsMature; #endif //WITH_EDITORONLY_DATA }; USTRUCT() struct ENGINE_API FDialogueContextMapping { GENERATED_USTRUCT_BODY() FDialogueContextMapping(); /** The context of the dialogue. */ UPROPERTY(EditAnywhere, Category=DialogueContextMapping ) FDialogueContext Context; /** The soundwave to play for this dialogue. */ UPROPERTY(EditAnywhere, Category=DialogueContextMapping ) USoundWave* SoundWave; /** * The format string to use when generating the localization key for this context. This must be unique within the owner dialogue wave. * Available format markers: * * {ContextHash} - A hash generated from the speaker and target voices. */ UPROPERTY(EditAnywhere, Category=DialogueContextMapping ) FString LocalizationKeyFormat; /** Cached object for playing the soundwave with subtitle information included. */ UPROPERTY(Transient) UDialogueSoundWaveProxy* Proxy; /** Gets the localization key to use for this context mapping */ FString GetLocalizationKey() const; FString GetLocalizationKey(const FString& InOwnerDialogueWaveKey) const; }; ENGINE_API bool operator==(const FDialogueContextMapping& LHS, const FDialogueContextMapping& RHS); ENGINE_API bool operator!=(const FDialogueContextMapping& LHS, const FDialogueContextMapping& RHS); class UDialogueWaveFactory; UCLASS(hidecategories=Object, editinlinenew, MinimalAPI, BlueprintType) class UDialogueWave : public UObject { GENERATED_UCLASS_BODY() /** true if this dialogue is considered to contain mature/adult content. */ UPROPERTY(EditAnywhere, Category=Filter, AssetRegistrySearchable) uint32 bMature:1; /** */ UPROPERTY(EditAnywhere, Category=Script, meta=(InlineEditConditionToggle)) uint32 bOverride_SubtitleOverride : 1; /** A localized version of the text that is actually spoken phonetically in the audio. */ UPROPERTY(EditAnywhere, Category=Script) FString SpokenText; /** A localized version of the subtitle text that should be displayed for this audio. By default this will be the same as the Spoken Text. */ UPROPERTY(EditAnywhere, Category=Script, meta=(EditCondition="bOverride_SubtitleOverride")) FString SubtitleOverride; #if WITH_EDITORONLY_DATA /** Provides general notes to the voice actor intended to direct their performance, as well as contextual information to the translator. */ UPROPERTY(EditAnywhere, Category=Script) FString VoiceActorDirection; #endif // WITH_EDITORONLY_DATA /* Mappings between dialogue contexts and associated soundwaves. */ UPROPERTY(EditAnywhere, Category=DialogueContexts) TArray<FDialogueContextMapping> ContextMappings; UPROPERTY() FGuid LocalizationGUID; public: //~ Begin UObject Interface. virtual void Serialize( FArchive& Ar ) override; virtual bool IsReadyForFinishDestroy() override; virtual FString GetDesc() override; virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag>& OutTags) const override; virtual void PostDuplicate(bool bDuplicateForPIE) override; virtual void PostLoad() override; #if WITH_EDITOR virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override; #endif //~ End UObject Interface. //~ Begin UDialogueWave Interface. ENGINE_API bool SupportsContext(const FDialogueContext& Context) const; ENGINE_API USoundBase* GetWaveFromContext(const FDialogueContext& Context) const; ENGINE_API USoundBase* GetWaveFromContext(const FDialogueContextMapping& ContextMapping) const; ENGINE_API FString GetContextLocalizationKey(const FDialogueContext& Context) const; ENGINE_API FString GetContextLocalizationKey(const FDialogueContextMapping& ContextMapping) const; ENGINE_API FString GetContextRecordedAudioFilename(const FDialogueContext& Context) const; ENGINE_API FString GetContextRecordedAudioFilename(const FDialogueContextMapping& ContextMapping) const; ENGINE_API static FString BuildRecordedAudioFilename(const FString& FormatString, const FGuid& DialogueGuid, const FString& DialogueName, const FString& ContextId, const int32 ContextIndex); //~ End UDialogueWave Interface. ENGINE_API void UpdateContext(FDialogueContextMapping& ContextMapping, USoundWave* SoundWave, UDialogueVoice* Speaker, const TArray<UDialogueVoice*>& Targets); protected: void UpdateMappingProxy(FDialogueContextMapping& ContextMapping); };
37.067568
191
0.8179
[ "object" ]
e0e75394b4a8ad7b20f0ef126b54b99bb178e878
20,438
c
C
movie/View_Output.c
scattering-central/CCP13
e78440d34d0ac80d2294b131ca17dddcf7505b01
[ "BSD-3-Clause" ]
null
null
null
movie/View_Output.c
scattering-central/CCP13
e78440d34d0ac80d2294b131ca17dddcf7505b01
[ "BSD-3-Clause" ]
null
null
null
movie/View_Output.c
scattering-central/CCP13
e78440d34d0ac80d2294b131ca17dddcf7505b01
[ "BSD-3-Clause" ]
3
2017-09-05T15:15:22.000Z
2021-01-15T11:13:45.000Z
#define NRANSI #define DATA 1 #define FIELD 0 #define DCAD3 2 #define PDBFORM 3 #define PDBFILE 3 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include "constants.h" #include "structures.h" #include "prototypes.h" void View_Output() { extern struct Info *VAR; extern struct Myosin *MY; extern struct C_Protein *CP; extern struct Titin *TT; extern struct Constant Cnst; extern struct BackBone *BB; extern struct Tropomyosin *TR; extern struct Actin *AA; int fil,Colour,flag; int nSph,Hd,Lvl,Hd_St,Mol,SubU,i,j; int Dom,U_Fil,Points,Mod_Points,Mod_Points2,Step,reps,strand,Start,Finish; double MYCol1[3][5],MYCol2[3][5],MYCol3[3][5]; double AACol1[5],AACol2[5],AACol3[5]; double Col_1,Col_2,Col_3; double x_Fils[8],y_Fils[8]; FILE *BB_FP[3],*MY_FP[3],*CP_FP[3]; FILE *TT_FP[3],*TR_FP[3],*AA_FP[3]; char *MY_File[] = {"Myosin.fld","Myosin.asc","Myosin.bsc","Myosin.pdb"}; char *CP_File[] = {"C_Protein.fld","CProtein.asc","CProtein.bsc","CProtein.pdb"}; char *TT_File[] = {"Titin.fld","Titin.asc","Titin.bsc","Titin.pdb"}; char *TR_File[] = {"Tropomyosin.fld","Tropomyosin.asc","Tropomyosin.bsc","Tropomyosin.pdb"}; char *AA_File[] = {"Actin.fld","Actin.asc","Actin.bsc","Actin.pdb"}; char *BB_File[] = {"BackBone.fld","BackBone.asc","BackBone.bsc","BackBone.pdb"}; char *myo_chain[] = {"A","B","C","D"}; char *act_chain[] = {"E","F","G","H"}; char Vari_File[100]; time_t The_Time; time(&The_Time); x_Fils[1] = 0.0; y_Fils[1] = 0.0; x_Fils[2] = 1.0*VAR->U_Cl; y_Fils[2] = 0.0; x_Fils[3] = cos(60*Cnst.DTR)*VAR->U_Cl; y_Fils[3] = sin(60*Cnst.DTR)*VAR->U_Cl; x_Fils[4] = (1.0 + cos(60*Cnst.DTR))*VAR->U_Cl; y_Fils[4] = sin(60*Cnst.DTR)*VAR->U_Cl; x_Fils[5] = 2.0*VAR->U_Cl; y_Fils[5] = 0.0; x_Fils[6] = cos(60*Cnst.DTR)*VAR->U_Cl; y_Fils[6] = -sin(60*Cnst.DTR)*VAR->U_Cl; x_Fils[7] = (1.0 + cos(60*Cnst.DTR))*VAR->U_Cl; y_Fils[7] = -sin(60*Cnst.DTR)*VAR->U_Cl; printf("\n Writing Coordinates...................."); for(fil=1;fil<=VAR->No_Fils;fil++) { printf("\n Filament %d............................. ",fil); if(VAR->Myo) { /* Myosin Output Coordindates */ Points = 0; Mod_Points = 0; Step = MY->N_Hds*MY->N_Crwns*VAR->N_Strnds*(int)(VAR->Tot_Rep/MY->Repeat); Mod_Points2 = -Step+1; flag = 1; MYCol1[1][1] = MYCol3[1][1] = MYCol3[1][2] = MYCol1[1][3] = 0.0; MYCol2[1][1] = MYCol1[1][2] = MYCol2[1][2] = MYCol2[1][3] = 1.0; MYCol3[1][3] = MYCol2[2][1] = MYCol1[2][2] = MYCol3[2][3] = 1.0; MYCol1[1][4] = MYCol2[1][4] = MYCol3[1][4] = MYCol3[2][1] = 0.5; MYCol1[2][4] = MYCol2[2][4] = MYCol3[2][4] = MYCol1[2][1] = 0.9; MYCol2[2][2] = MYCol1[2][3] = MYCol2[2][3] = 0.5; MYCol3[2][2] = 0.0; printf(" Myosin "); if(fil == 1) { if(VAR->Avs) { for(i=0;i<=1;i++) { if( (MY_FP[i] = fopen(MY_File[i], "w") ) == NULL ) { printf("Could not create file %s, Exiting",MY_File[i]); CleanUp(); } } } if(VAR->DCad) { if( (MY_FP[DCAD3] = fopen(MY_File[DCAD3], "w") ) == NULL ) { printf("Could not create file %s, Exiting",MY_File[DCAD3]); CleanUp(); } } if(VAR->Pdb) { if( (MY_FP[PDBFILE] = fopen(MY_File[PDBFORM], "w") ) == NULL ) { printf("Could not create file %s, Exiting",MY_File[PDBFORM]); CleanUp(); } } } for(nSph=0;nSph<=MY->N_Pts;nSph++) { for(Hd=1;Hd<=MY->N_Hds;Hd++) { for(Lvl=1;Lvl<=MY->N_Crwns;Lvl++) { for(Hd_St = 1;Hd_St<=VAR->N_Strnds;Hd_St++) { for(reps = 1;reps<=(int)(VAR->Tot_Rep/MY->Repeat);reps++) { j = reps; while(j > VAR->N_Strnds) j -= VAR->N_Strnds; Colour = Hd_St - (j-1); if(Colour < 1) Colour += VAR->N_Strnds; if(Hd > 2) { printf("\nOops I seem to have 3 heads !!\n\n"); CleanUp(); } Points++; if(VAR->Avs) { /* Output Coordinate File For AVS */ fprintf(MY_FP[DATA],"%7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n", MY->X[Points] + x_Fils[fil], MY->Y[Points] + y_Fils[fil], MY->Z[Points],MY->Sph_Sz, MYCol1[Hd][Hd_St], MYCol2[Hd][Hd_St], MYCol3[Hd][Hd_St]); } if(VAR->DCad) { /* Output Macro File For DesignCAD 3D */ fprintf(MY_FP[DCAD3],">sphere\n"); fprintf(MY_FP[DCAD3],"{\n"); fprintf(MY_FP[DCAD3],"<color %d %d %d\n", (int)(255.0*MYCol1[Hd][Hd_St]), (int)(255.0*MYCol2[Hd][Hd_St]), (int)(255.0*MYCol3[Hd][Hd_St])); fprintf(MY_FP[DCAD3],"<pointxyz %f %f %f\n", MY->X[Points] + x_Fils[fil], MY->Y[Points] + y_Fils[fil], MY->Z[Points]); fprintf(MY_FP[DCAD3],"<pointxyz %f %f %f\n", MY->X[Points] + x_Fils[fil] + MY->Sph_Sz, MY->Y[Points] + y_Fils[fil], MY->Z[Points]); fprintf(MY_FP[DCAD3],"<longitude 20\n"); fprintf(MY_FP[DCAD3],"<latitude 20\n"); fprintf(MY_FP[DCAD3],"}\n"); } if(VAR->Pdb) { /* Output Coordinates In BrookeHaven Format */ if(VAR->BrookeHaven) { Mod_Points++; if(Mod_Points > MY->N_Pts+1) Mod_Points = 1; Mod_Points2 += Step; if(Mod_Points2 > Step*(MY->N_Pts+1)) Mod_Points2 = ++flag; fprintf(MY_FP[PDBFORM],"ATOM%7d %3s %3s %1s%4d %+8.3f%+8.3f%+8.3f %s\n", Points, MY->Type[Mod_Points-1], MY->Amino_Acid[Mod_Points-1], MY->Chain[Mod_Points-1], MY->Sequence[Mod_Points-1], MY->X[Mod_Points2] + x_Fils[fil], MY->Y[Mod_Points2] + y_Fils[fil], MY->Z[Mod_Points2], MY->Param[Mod_Points-1]); } else { fprintf(MY_FP[PDBFORM],"ATOM %5d CA VAL %s%4d %+8.3f%+8.3f%+8.3f 1.00 20.00\n", Points, myo_chain[Hd-1], Points, MY->X[Points] + x_Fils[fil], MY->Y[Points] + y_Fils[fil], MY->Z[Points]); } } } } } } } if(VAR->Avs) if(fil == VAR->No_Fils) Field_File(MY_FP[FIELD],MY_File[DATA],Points,"Myosin"); } if(VAR->Tropomyosin) { /* Tropomyosin Output Coordindates */ Points = 0; printf(" Tropomyosin "); if(fil == 1) { if(VAR->Avs) { for(i=0;i<=1;i++) { if( (TR_FP[i] = fopen(TR_File[i], "w+") ) == NULL ) { printf("Could not create file %s, Exiting",TR_File[i]); CleanUp(); } } } if(VAR->DCad) { if( (TR_FP[DCAD3] = fopen(TR_File[DCAD3], "w") ) == NULL ) { printf("Could not create file %s, Exiting",TR_File[DCAD3]); CleanUp(); } } if(VAR->Pdb) { if( (TR_FP[PDBFORM] = fopen(TR_File[PDBFORM], "w") ) == NULL ) { printf("Could not create file %s, Exiting",TR_File[PDBFORM]); CleanUp(); } } } for(reps = 1;reps<=(int)(VAR->Tot_Rep/TR->Repeat);reps++) { for(SubU=1;SubU<=TR->Tot_SubU;SubU++) { for(strand=0;strand<=1;strand++) { for(U_Fil=1;TR->N_Fil<=2;U_Fil++) { Points++; Col_1 = 1.0; Col_2 = 1.0; Col_3 = 0.2; if(VAR->Avs) { /* Output Coordinate File For AVS */ fprintf(TR_FP[DATA],"%7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n", TR->X[Points] + x_Fils[fil], TR->Y[Points] + y_Fils[fil], TR->Z[Points], TR->Sph_Sz, Col_1, Col_2, Col_3); } if(VAR->DCad) { /* Output Macro File For DesignCAD 3D */ fprintf(TR_FP[DCAD3],">sphere\n"); fprintf(TR_FP[DCAD3],"{\n"); fprintf(TR_FP[DCAD3],"<color %d %d %d\n", (int)(255.0*Col_1), (int)(255.0*Col_2), (int)(255.0*Col_3)); fprintf(TR_FP[DCAD3],"<pointxyz %f %f %f\n", TR->X[Points] + x_Fils[fil], TR->Y[Points] + y_Fils[fil], TR->Z[Points]); fprintf(TR_FP[DCAD3],"<pointxyz %f %f %f\n", TR->X[Points] + x_Fils[fil] + TR->Sph_Sz, TR->Y[Points] + y_Fils[fil], TR->Z[Points]); fprintf(TR_FP[DCAD3],"<longitude 20\n"); fprintf(TR_FP[DCAD3],"<latitude 20\n"); fprintf(TR_FP[DCAD3],"}\n"); } if(VAR->Pdb) { /* Output Coordinates In BrookeHaven Format */ fprintf(TR_FP[PDBFORM],"ATOM %4d CA VAL I%4d %+8.3f%+8.3f%+8.3f 1.00 20.00\n", Points, Points, TR->X[Points] + x_Fils[fil], TR->Y[Points] + y_Fils[fil], TR->Z[Points]); } } } } } if(VAR->Avs) if(fil == VAR->No_Fils) Field_File(TR_FP[FIELD],TR_File[DATA],Points,"Tropomyosin"); } if(VAR->Actin) { /* Actin Output Coordindates */ Points = 0; printf(" Actin "); if(fil == 1) { for(i=0;i<=1;i++) { if( (AA_FP[i] = fopen(AA_File[i], "w+") ) == NULL ) { printf("Could not create file %s, Exiting",AA_File[i]); CleanUp(); } } if(VAR->DCad) { if( (AA_FP[DCAD3] = fopen(AA_File[DCAD3], "w") ) == NULL ) { printf("Could not create file %s, Exiting",AA_File[DCAD3]); CleanUp(); } } if(VAR->Pdb) { if( (AA_FP[PDBFORM] = fopen(AA_File[PDBFORM], "w") ) == NULL ) { printf("Could not create file %s, Exiting",AA_File[PDBFORM]); CleanUp(); } } } AACol2[1] = AACol3[1] = 0.0; AACol2[2] = AACol3[2] = 0.0; AACol2[3] = AACol3[3] = 0.0; AACol1[3] = AACol1[4] = 1.0; AACol2[4] = AACol3[4] = 0.2; AACol1[2] = 0.75; AACol1[1] = 0.5; for(Dom=1;Dom<=AA->Tot_Dom;Dom++) { for(SubU=1;SubU<=AA->Tot_SubU;SubU++) { for(U_Fil=1;U_Fil<=AA->N_Fil;U_Fil++) { for(reps = 1;reps<=(int)(VAR->Tot_Rep/AA->Repeat);reps++) { Points++; if(VAR->Avs) { /* Output Coordinate File For AVS */ fprintf(AA_FP[DATA],"%7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n", AA->X[Points] + x_Fils[fil], AA->Y[Points] + y_Fils[fil], AA->Z[Points], AA->Sph_Sz[Dom], AACol1[Dom], AACol2[Dom], AACol3[Dom]); } if(VAR->DCad) { /* Output Macro File For DesignCAD 3D */ fprintf(AA_FP[DCAD3],">sphere\n"); fprintf(AA_FP[DCAD3],"{\n"); fprintf(AA_FP[DCAD3],"<color %d %d %d\n", (int)(255.0*AACol1[Dom]), (int)(255.0*AACol2[Dom]), (int)(255.0*AACol3[Dom])); fprintf(AA_FP[DCAD3],"<pointxyz %f %f %f\n", AA->X[Points] + x_Fils[fil], AA->Y[Points] + y_Fils[fil], AA->Z[Points]); fprintf(AA_FP[DCAD3],"<pointxyz %f %f %f\n", AA->X[Points] + x_Fils[fil] + AA->Sph_Sz[Dom], AA->Y[Points] + y_Fils[fil], AA->Z[Points]); fprintf(AA_FP[DCAD3],"<longitude 20\n"); fprintf(AA_FP[DCAD3],"<latitude 20\n"); fprintf(AA_FP[DCAD3],"}\n"); } if(VAR->Pdb) { /* Output Coordinates In BrookeHaven Format */ fprintf(AA_FP[PDBFORM],"ATOM %4d CA VAL %s%4d %+8.3f%+8.3f%+8.3f 1.00 20.00\n", Points, act_chain[Dom-1], Points, AA->X[Points] + x_Fils[fil], AA->Y[Points] + y_Fils[fil], AA->Z[Points]); } } } } } if(VAR->Avs) if(fil == VAR->No_Fils) Field_File(AA_FP[FIELD],AA_File[DATA],Points,"Actin"); } if(VAR->CPro) { /* C-Protein Output Coordindates */ Points = 0; printf(" C-Protein "); if(fil == 1) { for(i=0;i<=1;i++) { if( (CP_FP[i] = fopen(CP_File[i], "w+") ) == NULL ) { printf("Could not create file %s, Exiting",CP_File[i]); CleanUp(); } } if(VAR->DCad) { if( (CP_FP[DCAD3] = fopen(CP_File[DCAD3], "w") ) == NULL ) { printf("Could not create file %s, Exiting",CP_File[DCAD3]); CleanUp(); } } if(VAR->Pdb) { if( (CP_FP[PDBFORM] = fopen(CP_File[PDBFORM], "w") ) == NULL ) { printf("Could not create file %s, Exiting",CP_File[PDBFORM]); CleanUp(); } } } for(reps = 1;reps<=(int)(VAR->Tot_Rep/CP->Repeat);reps++) { for(Mol=1;Mol<=VAR->N_Strnds;Mol++) { for(SubU=1;SubU<=CP->Tot_SubU;SubU++) { if(Mol > 3) { printf("\nOops need colours for 4th strand\n\n"); CleanUp(); } if(Mol == 1) { Col_1=1.0; Col_2=1.0; Col_3=0.2; } if(Mol == 2) { Col_1=1.0; Col_2=1.0; Col_3=0.2; } if(Mol == 3) { Col_1=1.0; Col_2=1.0; Col_3=0.2; } Points++; if(VAR->Avs) { /* Output Coordinate File For AVS */ fprintf(CP_FP[DATA],"%7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n", CP->X[Points] + x_Fils[fil], CP->Y[Points] + y_Fils[fil], CP->Z[Points], CP->Sph_Sz, Col_1, Col_2, Col_3); } if(VAR->DCad) { /* Output Macro File For DesignCAD 3D */ fprintf(CP_FP[DCAD3],">sphere\n"); fprintf(CP_FP[DCAD3],"{\n"); fprintf(CP_FP[DCAD3],"<color %d %d %d\n", (int)(255.0*Col_1), (int)(255.0*Col_2), (int)(255.0*Col_3)); fprintf(CP_FP[DCAD3],"<pointxyz %f %f %f\n", CP->X[Points] + x_Fils[fil], CP->Y[Points] + y_Fils[fil], CP->Z[Points]); fprintf(CP_FP[DCAD3],"<pointxyz %f %f %f\n", CP->X[Points] + x_Fils[fil] + CP->Sph_Sz, CP->Y[Points] + y_Fils[fil], CP->Z[Points]); fprintf(CP_FP[DCAD3],"<longitude 20\n"); fprintf(CP_FP[DCAD3],"<latitude 20\n"); fprintf(CP_FP[DCAD3],"}\n"); } if(VAR->Pdb) { /* Output Coordinates In BrookeHaven Format */ fprintf(CP_FP[PDBFORM],"ATOM %4d CA VAL J%4d %+8.3f%+8.3f%+8.3f 1.00 20.00\n", Points,Points, CP->X[Points] + x_Fils[fil], CP->Y[Points] + y_Fils[fil], CP->Z[Points]); } } } } if(VAR->Avs) if(fil == VAR->No_Fils) Field_File(CP_FP[FIELD],CP_File[DATA],Points,"C-Protein"); } if(VAR->Titin) { /* Titin Output Coordindates */ Points = 0; printf(" Titin "); if(fil == 1) { for(i=0;i<=1;i++) { if( (TT_FP[i] = fopen(TT_File[i], "w+") ) == NULL ) { printf("Could not create file %s, Exiting",TT_File[i]); CleanUp(); } } if(VAR->DCad) { if( (TT_FP[DCAD3] = fopen(TT_File[DCAD3], "w") ) == NULL ) { printf("Could not create file %s, Exiting",TT_File[DCAD3]); CleanUp(); } } if(VAR->Pdb) { if( (TT_FP[PDBFORM] = fopen(TT_File[PDBFORM], "w") ) == NULL ) { printf("Could not create file %s, Exiting",TT_File[PDBFORM]); CleanUp(); } } } for(reps = 1;reps<=(int)(VAR->Tot_Rep/TT->Repeat);reps++) { for(Mol=1;Mol<=VAR->N_Strnds;Mol++) { for(SubU=1;SubU<=TT->Tot_SubU;SubU++) { if(Mol > 3) { printf("\nOops need colours for 4th strand\n\n"); CleanUp(); } if(Mol == 1) { Col_1=1.0; Col_2=0.5; Col_3=1.0; } if(Mol == 2) { Col_1=1.0; Col_2=0.5; Col_3=1.0; } if(Mol == 3) { Col_1=1.0; Col_2=0.5; Col_3=1.0; } Points++; if(VAR->Avs) { /* Output Coordinate File For AVS */ fprintf(TT_FP[DATA],"%7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n", TT->X[Points] + x_Fils[fil], TT->Y[Points] + y_Fils[fil], TT->Z[Points], TT->Sph_Sz, Col_1, Col_2, Col_3); } if(VAR->DCad) { /* Output Macro File For DesignCAD 3D */ fprintf(TT_FP[DCAD3],">sphere\n"); fprintf(TT_FP[DCAD3],"{\n"); fprintf(TT_FP[DCAD3],"<color %d %d %d\n", (int)(255.0*Col_1), (int)(255.0*Col_2), (int)(255.0*Col_3)); fprintf(TT_FP[DCAD3],"<pointxyz %f %f %f\n", TT->X[Points] + x_Fils[fil], TT->Y[Points] + y_Fils[fil], TT->Z[Points]); fprintf(TT_FP[DCAD3],"<pointxyz %f %f %f\n", TT->X[Points] + x_Fils[fil] + TT->Sph_Sz, TT->Y[Points] + y_Fils[fil], TT->Z[Points]); fprintf(TT_FP[DCAD3],"<longitude 20\n"); fprintf(TT_FP[DCAD3],"<latitude 20\n"); fprintf(TT_FP[DCAD3],"}\n"); } if(VAR->Pdb) { /* Output Coordinates In BrookeHaven Format */ fprintf(TT_FP[PDBFORM],"ATOM %4d CA VAL K%4d %+8.3f%+8.3f%+8.3f 1.00 20.00\n", Points,Points, TT->X[Points] + x_Fils[fil], TT->Y[Points] + y_Fils[fil], TT->Z[Points]); } } } } if(VAR->Avs) if(fil == VAR->No_Fils) Field_File(TT_FP[FIELD],TT_File[DATA],Points,"Titin"); } if(VAR->BBone) { /* Backbone Output Coordindates */ Points = 0; printf(" BackBone "); if(fil == 1) { for(i=0;i<=1;i++) { if( (BB_FP[i] = fopen(BB_File[i], "w+") ) == NULL ) { printf("Could not create file %s, Exiting",BB_File[i]); CleanUp(); } } if(VAR->DCad) { if( (BB_FP[DCAD3] = fopen(BB_File[DCAD3], "w") ) == NULL ) { printf("Could not create file %s, Exiting",BB_File[DCAD3]); CleanUp(); } } if(VAR->Pdb) { if( (BB_FP[PDBFORM] = fopen(BB_File[PDBFORM], "w") ) == NULL ) { printf("Could not create file %s, Exiting",BB_File[PDBFORM]); CleanUp(); } } } if(BB->Model == 0) { Col_1 = 0.9; Col_2 = 0.9; Col_3 = 0.9; for(reps = 1;reps<=(int)(VAR->Tot_Rep/BB->Repeat);reps++) { for(j=0;j<=BB->N_Pts-1;j++) { Points++; if(VAR->Avs) { /* Output Coordinate File For AVS */ fprintf(BB_FP[DATA],"%7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n", BB->X[Points] + x_Fils[fil], BB->Y[Points] + y_Fils[fil], BB->Z[Points], BB->Sph_Sz, Col_1, Col_2, Col_3); } if(VAR->DCad) { /* Output Macro File For DesignCAD 3D */ fprintf(BB_FP[DCAD3],">sphere\n"); fprintf(BB_FP[DCAD3],"{\n"); fprintf(BB_FP[DCAD3],"<color %d %d %d\n", (int)(255.0*Col_1), (int)(255.0*Col_2), (int)(255.0*Col_3)); fprintf(BB_FP[DCAD3],"<pointxyz %f %f %f\n", BB->X[Points] + x_Fils[fil], BB->Y[Points] + y_Fils[fil], BB->Z[Points]); fprintf(BB_FP[DCAD3],"<pointxyz %f %f %f\n", BB->X[Points] + x_Fils[fil] + BB->Sph_Sz, BB->Y[Points] + y_Fils[fil], BB->Z[Points]); fprintf(BB_FP[DCAD3],"<longitude 20\n"); fprintf(BB_FP[DCAD3],"<latitude 20\n"); fprintf(BB_FP[DCAD3],"}\n"); } if(VAR->Pdb) { /* Output Coordinates In BrookeHaven Format */ fprintf(BB_FP[PDBFORM],"ATOM %4d CA VAL L%4d %+8.3f%+8.3f%+8.3f 1.00 20.00\n", Points,Points, BB->X[Points] + x_Fils[fil], BB->Y[Points] + y_Fils[fil], BB->Z[Points]); } } } } if(VAR->Avs) if(fil == VAR->No_Fils) Field_File(BB_FP[FIELD],BB_File[DATA],Points,"BackBone"); if(BB->Model == 1) { if(VAR->Avs) { /* Output Coordinate File For AVS */ fprintf(BB_FP[DATA],"%7.3f %7.3f %7.3f %7.3f %7.3f\n", x_Fils[fil], y_Fils[fil], VAR->Tot_Rep/2.0, BB->Rad, VAR->Tot_Rep); } if(VAR->DCad) { /* Output Macro File For DesignCAD 3D */ fprintf(BB_FP[DCAD3],">cylinder\n"); fprintf(BB_FP[DCAD3],"{\n"); fprintf(BB_FP[DCAD3],"<color 200 200 200\n"); fprintf(BB_FP[DCAD3],"<pointxyz %f %f %f\n", x_Fils[fil], y_Fils[fil], 0.0); fprintf(BB_FP[DCAD3],"<pointxyz %f %f %f\n", x_Fils[fil] + BB->Rad, y_Fils[fil], 0.0); fprintf(BB_FP[DCAD3],"<pointxyz %f %f %f\n", x_Fils[fil] + BB->Rad, y_Fils[fil], BB->Rad + VAR->Tot_Rep); fprintf(BB_FP[DCAD3],"<NFace 50\n"); fprintf(BB_FP[DCAD3],"}\n"); } } } } if(VAR->Avs) { Start = FIELD; Finish = DATA; } if(VAR->DCad) { Start = Finish = DCAD3; } if(VAR->Pdb) { Start = Finish = PDBFORM; } for(i=Start;i<=Finish;i++) { if(VAR->CPro) fclose(CP_FP[i]); if(VAR->Tropomyosin) fclose(TR_FP[i]); if(VAR->Actin) fclose(AA_FP[i]); if(VAR->Myo) fclose(MY_FP[i]); if(VAR->Titin) fclose(TT_FP[i]); if(VAR->BBone) fclose(BB_FP[i]); } printf("\n"); } void Field_File(FILE *output,char *data,int Points,char *protein) { extern struct Info *VAR; time_t The_Time; time(&The_Time); fprintf(output,"# AVS field header file \n"); fprintf(output,"# Created By L.Hudson with MOVIE at %s",ctime(&The_Time)); fprintf(output,"# This file is parsed by Avs and provides coordinates for %s\n",protein); fprintf(output,"ndim = 1\n"); fprintf(output,"dim1 = %d\n",Points*VAR->No_Fils); fprintf(output,"nspace = 3\nveclen = 4\ndata = float\nfield = irregular\n"); fprintf(output,"variable 1 file = ./%s filetype = ascii offset = 3 stride = 7\n",data); fprintf(output,"variable 2 file = ./%s filetype = ascii offset = 4 stride = 7\n",data); fprintf(output,"variable 3 file = ./%s filetype = ascii offset = 5 stride = 7\n",data); fprintf(output,"variable 4 file = ./%s filetype = ascii offset = 6 stride = 7\n",data); fprintf(output,"coord 1 file = ./%s filetype = ascii offset = 0 stride = 7\n",data); fprintf(output,"coord 2 file = ./%s filetype = ascii offset = 1 stride = 7\n",data); fprintf(output,"coord 3 file = ./%s filetype = ascii offset = 2 stride = 7\n",data); }
30.733835
103
0.541393
[ "model", "3d" ]
e0e7da2a91091834337223543eda63ed1ae48b52
2,275
h
C
glucose/glucose_impl.h
tzolkincz/fast-akima-interpolation
460149b45695c286a9e5911fe10228e35e5225d0
[ "WTFPL" ]
2
2019-11-07T07:04:44.000Z
2021-02-27T01:30:07.000Z
glucose/glucose_impl.h
tzolkincz/fast-akima-interpolation
460149b45695c286a9e5911fe10228e35e5225d0
[ "WTFPL" ]
null
null
null
glucose/glucose_impl.h
tzolkincz/fast-akima-interpolation
460149b45695c286a9e5911fe10228e35e5225d0
[ "WTFPL" ]
1
2016-11-23T02:41:13.000Z
2016-11-23T02:41:13.000Z
#include "../lib/glucose/iface/ApproxIface.h" #include "../lib/glucose/CommonApprox.h" #include <vector> #ifndef GLUCOSE_IMPL_H #define GLUCOSE_IMPL_H class GlucoseImplementation : public CCommonApprox { private: size_t count; std::vector<double> times; std::vector<double> levels; AlignedCoefficients coefficients; TGlucoseLevelBounds levelsBounds; bool isApproximed = false; public: GlucoseImplementation(IGlucoseLevels *levelsContainer) : CCommonApprox(levelsContainer) { levelsContainer->GetLevelsCount(&count); TGlucoseLevel *g_levels; levelsContainer->GetLevels(&g_levels); times = std::vector<double>(count); levels = std::vector<double>(count); for (int i = 0; i < count; i++) { times[i] = g_levels[i].datetime; levels[i] = g_levels[i].level; } levelsContainer->GetBounds(&levelsBounds); } virtual ~GlucoseImplementation() { }; //dctor has to be virtual, even if it is empty, due to the inheritance by dominance HRESULT IfaceCalling Approximate(TApproximationParams *params); //calls ILogical_Clock->Signal_Clock /** * time - time from which to calculate the approximation stepping - distance between two times count - the total number of times for which to get the approximation levels - the approximated levels, must be already allocated with size of count filled - the number of levels approximated * * * @param desired_time * @param stepping * @param count * @param levels * @param filled * @param derivationorder * @return */ HRESULT IfaceCalling GetLevels(floattype desired_time, floattype stepping, size_t count, floattype *levels, size_t *filled, size_t derivationorder); /** * times has size of count times holds time for which to calculate glucose level approximation levels has to be allocated with size of count levels will be filled with approximated glucose levels at respective indexes for respective times first *filled levels will be calculated * * * @param times * @param count * @param levels * @param filled * @return */ HRESULT IfaceCalling GetLevels(floattype* times, size_t count, floattype *levels, size_t *filled); HRESULT IfaceCalling GetBounds(TGlucoseLevelBounds *bounds); }; #endif /* GLUCOSE_IMPL_H */
23.697917
100
0.735385
[ "vector" ]
e0f064b3e38a123d4e858466826aefe9769f12b8
5,905
h
C
src/include/InterViews/transformer.h
emer/iv
e2ecb3acd834b8764c8582753cc86afcc4281af5
[ "BSD-3-Clause" ]
null
null
null
src/include/InterViews/transformer.h
emer/iv
e2ecb3acd834b8764c8582753cc86afcc4281af5
[ "BSD-3-Clause" ]
null
null
null
src/include/InterViews/transformer.h
emer/iv
e2ecb3acd834b8764c8582753cc86afcc4281af5
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University * Copyright (c) 1991 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Stanford and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Stanford and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * Interface to transformation matrices. */ #ifndef iv_transformer_h #define iv_transformer_h #include <InterViews/coord.h> #include <InterViews/resource.h> #include <InterViews/_enter.h> class Transformer : public Resource { public: Transformer(); /* identity */ Transformer(const Transformer&); Transformer(const Transformer*); Transformer( float a00, float a01, float a10, float a11, float a20, float a21 ); virtual ~Transformer(); boolean identity() const; boolean invertible() const; boolean operator ==(const Transformer&) const; boolean operator !=(const Transformer&) const; Transformer& operator =(const Transformer&); virtual void premultiply(const Transformer&); virtual void postmultiply(const Transformer&); virtual void invert(); virtual void translate(float dx, float dy); virtual void scale(float sx, float sy); virtual void rotate(float angle); virtual void skew(float sx, float sy); virtual void transform(float& x, float& y) const; virtual void transform(float x, float y, float& tx, float& ty) const; virtual void inverse_transform(float& tx, float& ty) const; virtual void inverse_transform( float tx, float ty, float& x, float& y ) const; float det() const; virtual void matrix( float& a00, float& a01, float& a10, float& a11, float& a20, float& a21 ) const; private: boolean identity_; float mat00, mat01, mat10, mat11, mat20, mat21; void update(); public: /* * Old definitions for backward compatibility. */ void GetEntries( float& a00, float& a01, float& a10, float& a11, float& a20, float& a21 ) const; void Premultiply(Transformer* t); void Postmultiply(Transformer* t); void Invert(); void Translate(float dx, float dy); void Scale(float sx, float sy); void Rotate(float angle); boolean Translated(float = 1e-6) const; boolean Scaled(float = 1e-6) const; boolean Stretched (float = 1e-6) const; boolean Rotated(float = 1e-6) const; boolean Rotated90(float = 1e-6) const; void Transform(IntCoord& x, IntCoord& y) const; void Transform(IntCoord x, IntCoord y, IntCoord& tx, IntCoord& ty) const; void Transform(float x, float y, float& tx, float& ty) const; void TransformList(IntCoord x[], IntCoord y[], int n) const; void TransformList( IntCoord x[], IntCoord y[], int n, IntCoord tx[], IntCoord ty[] ) const; void TransformRect(IntCoord&, IntCoord&, IntCoord&, IntCoord&) const; void TransformRect(float&, float&, float&, float&) const; void InvTransform(IntCoord& tx, IntCoord& ty) const; void InvTransform( IntCoord tx, IntCoord ty, IntCoord& x, IntCoord& y ) const; void InvTransform(float tx, float ty, float& x, float& y) const; void InvTransformList(IntCoord tx[], IntCoord ty[], int n) const; void InvTransformList( IntCoord tx[], IntCoord ty[], int n, IntCoord x[], IntCoord y[] ) const; void InvTransformRect(IntCoord&, IntCoord&, IntCoord&, IntCoord&) const; void InvTransformRect(float&, float&, float&, float&) const; }; inline float Transformer::det() const { return mat00*mat11 - mat01*mat10; } inline boolean Transformer::identity() const { return identity_; } inline boolean Transformer::invertible() const { return det() != 0; } inline boolean Transformer::Translated(float tol) const { return -tol > mat20 || mat20 > tol || -tol > mat21 || mat21 > tol; } inline boolean Transformer::Scaled(float tol) const { float l = 1 - tol, u = 1 + tol; return l > mat00 || mat00 > u || l > mat11 || mat11 > u; } inline boolean Transformer::Stretched(float tol) const { float diff = mat00 - mat11; return -tol > diff || diff > tol; } inline boolean Transformer::Rotated(float tol) const { return -tol > mat01 || mat01 > tol || -tol > mat10 || mat10 > tol; } inline boolean Transformer::Rotated90(float tol) const { return Rotated(tol) && -tol <= mat00 && mat00 <= tol && -tol <= mat11 && mat11 <= tol; } inline void Transformer::GetEntries( float& a00, float& a01, float& a10, float& a11, float& a20, float& a21 ) const { matrix(a00, a01, a10, a11, a20, a21); } inline void Transformer::Translate(float dx, float dy) { translate(dx, dy); } inline void Transformer::Scale(float sx, float sy) { scale(sx, sy); } inline void Transformer::Rotate(float angle) { rotate(angle); } inline void Transformer::Premultiply(Transformer* t) { premultiply(*t); } inline void Transformer::Postmultiply(Transformer* t) { postmultiply(*t); } inline void Transformer::Invert() { invert(); } #include <InterViews/_leave.h> #endif
34.940828
78
0.693649
[ "transform" ]
46133278ccdd8ca2d8628c8226d35bc8e43231d9
3,514
h
C
features/emwin_demo/config/custom_config_qspi.h
aectaan/BLE_SDK10_examples
3d26e9bdf1b619939c6a73e781ed34fd89f3f4db
[ "MIT" ]
16
2021-04-01T07:58:22.000Z
2022-02-21T08:32:54.000Z
features/emwin_demo/config/custom_config_qspi.h
aectaan/BLE_SDK10_examples
3d26e9bdf1b619939c6a73e781ed34fd89f3f4db
[ "MIT" ]
7
2021-05-19T15:21:36.000Z
2022-03-30T07:29:48.000Z
features/emwin_demo/config/custom_config_qspi.h
aectaan/BLE_SDK10_examples
3d26e9bdf1b619939c6a73e781ed34fd89f3f4db
[ "MIT" ]
14
2021-04-01T07:58:29.000Z
2022-03-30T16:26:39.000Z
/** **************************************************************************************** * * @file custom_config_qspi.h * * @brief Board Support Package. User Configuration file for cached QSPI mode. * * Copyright (C) 2017-2019 Dialog Semiconductor. * This computer program includes Confidential, Proprietary Information * of Dialog Semiconductor. All Rights Reserved. * **************************************************************************************** */ #ifndef CUSTOM_CONFIG_QSPI_H_ #define CUSTOM_CONFIG_QSPI_H_ #include "bsp_definitions.h" #define CONFIG_RTT /*************************************************************************************************\ * System configuration */ #define dg_configUSE_LP_CLK ( LP_CLK_32768 ) #define dg_configEXEC_MODE ( MODE_IS_CACHED ) #define dg_configCODE_LOCATION ( NON_VOLATILE_IS_FLASH ) #define dg_configIMAGE_SETUP ( DEVELOPMENT_MODE ) #define dg_configUSE_WDOG ( 1 ) #define dg_configFLASH_CONNECTED_TO ( FLASH_CONNECTED_TO_1V8P ) #define dg_configFLASH_POWER_DOWN ( 1 ) #define dg_configPOWER_1V8P_ACTIVE ( 1 ) #define dg_configPOWER_1V8P_SLEEP ( 1 ) #define dg_configUSE_SW_CURSOR ( 1 ) #define dg_configENABLE_CMAC_DEBUGGER ( 0 ) /*************************************************************************************************\ * FreeRTOS configuration */ #define OS_FREERTOS /* Define this to use FreeRTOS */ #define configTOTAL_HEAP_SIZE ( 30000 ) /* FreeRTOS Total Heap Size */ /*************************************************************************************************\ * Peripherals configuration */ #define dg_configUSE_HW_QSPI2 ( 0 ) #define dg_configLCDC_ADAPTER ( 1 ) #define dg_configUSE_HW_LCDC ( 1 ) #define dg_configI2C_ADAPTER ( 1 ) #define dg_configUSE_HW_I2C ( 1 ) #define dg_configFLASH_ADAPTER ( 1 ) #define dg_configNVMS_ADAPTER ( 1 ) /*************************************************************************************************\ * Display model selection. Note that one display model can be selected at a time. */ #define dg_configUSE_DT280QV10CT ( 1 ) #define dg_configUSE_HM80160A090 ( 0 ) #define dg_configUSE_LPM012M134B ( 0 ) #define dg_configUSE_LPM013M091A ( 0 ) #define dg_configUSE_NHD43480272EFASXN ( 0 ) #define dg_configUSE_MCT024L6W240320PML ( 0 ) #define dg_configUSE_PSP27801 ( 0 ) #define dg_configUSE_E1394AA65A ( 0 ) #define dg_configUSE_T1D3BP006 ( 0 ) #define dg_configUSE_T1D54BP002 ( 0 ) #define dg_configUSE_LS013B7DH06 ( 0 ) #define dg_configUSE_LS013B7DH03 ( 0 ) /*************************************************************************************************\ * Touch controller selection. Note that one touch driver can be selected at a time. */ #define dg_configUSE_FT6206 ( 1 ) #define dg_configUSE_FT5306 ( 0 ) /* Include bsp default values */ #include "bsp_defaults.h" /* Include middleware default values */ #include "middleware_defaults.h" #endif /* CUSTOM_CONFIG_QSPI_H_ */
41.833333
99
0.500285
[ "model" ]
461e18370954747a2a01eef07b053b3b7d36ad0a
694
h
C
src/ViewControllers/Grinding/TimedGrindViewController.h
magnusnordlander/fifty-fifty
4628cd19bbabd7dff08d83e0fab6dac301e382b7
[ "MIT" ]
4
2021-02-19T22:08:26.000Z
2022-01-17T20:27:22.000Z
src/ViewControllers/Grinding/TimedGrindViewController.h
magnusnordlander/fifty-fifty
4628cd19bbabd7dff08d83e0fab6dac301e382b7
[ "MIT" ]
null
null
null
src/ViewControllers/Grinding/TimedGrindViewController.h
magnusnordlander/fifty-fifty
4628cd19bbabd7dff08d83e0fab6dac301e382b7
[ "MIT" ]
2
2021-02-16T21:14:12.000Z
2021-05-12T06:51:08.000Z
// // Created by Magnus Nordlander on 2021-02-07. // #ifndef GRINDER_TIMEDGRINDVIEWCONTROLLER_H #define GRINDER_TIMEDGRINDVIEWCONTROLLER_H #include "BaseGrindViewController.h" #include <Settings.h> #include <types.h> class TimedGrindViewController: public BaseGrindViewController { public: TimedGrindViewController(SsrState *ssr, Settings *settings); void tick(U8G2 display) override; void viewWasPushed(NavigationController *controller) override; void viewWillBePopped(NavigationController *controller) override; void render(U8G2 display) override; protected: Settings* settings; millitime_t target_ms = 0; }; #endif //GRINDER_TIMEDGRINDVIEWCONTROLLER_H
21.6875
69
0.783862
[ "render" ]
46222c6111c6c04cd59b9b5cfe2b81bc03116fa8
530
c
C
d/dagger/phederia/obj/fountain.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/dagger/phederia/obj/fountain.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
4
2021-03-15T18:56:39.000Z
2021-08-17T17:08:22.000Z
d/dagger/phederia/obj/fountain.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
inherit "/std/Object"; void create(){ ::create(); set_name("fountain"); set_id(({ "fountain", })); set_short("Fountain"); set_long( " This large fountain is of nymph holding a bowl that pours water into a huge basin at its feet." " Its been carved out of rose quartz that seems to have faded to look more like granite soaked in dried blood." " In fact as you look closer you notice it has been splattered with blood, lots of it." ); set_weight(100000); set_value(0); set_property("no animate",1); }
29.444444
114
0.684906
[ "object" ]
46232791c8ba196324727db7fe7325409cc7e1ce
1,032
h
C
fk/hal/metal/metal_qspi.h
fieldkit/firmware
09df5c4c5c2f21865cfbb11c9cdc362bb8803ad6
[ "BSD-3-Clause" ]
10
2019-11-26T11:35:56.000Z
2021-07-03T07:21:38.000Z
fk/hal/metal/metal_qspi.h
fieldkit/firmware
09df5c4c5c2f21865cfbb11c9cdc362bb8803ad6
[ "BSD-3-Clause" ]
1
2019-07-03T06:27:21.000Z
2019-09-06T09:21:27.000Z
fk/hal/metal/metal_qspi.h
fieldkit/firmware
09df5c4c5c2f21865cfbb11c9cdc362bb8803ad6
[ "BSD-3-Clause" ]
1
2019-09-23T18:13:51.000Z
2019-09-23T18:13:51.000Z
#pragma once #if defined(__SAMD51__) #include "hal/memory.h" #include "hal/metal/metal_memory.h" #include <Adafruit_SPIFlash.h> namespace fk { class MetalQspiMemory : public ExecutableMemory { public: constexpr static uint32_t PageSize = 256; constexpr static uint32_t SectorSize = 4096; constexpr static uint32_t BlockSize = 64 * 1024; constexpr static uint32_t NumberOfBlocks = 128; private: Availability status_{ Availability::Unknown }; Adafruit_FlashTransport_QSPI transport_; Adafruit_SPIFlash flash_; public: MetalQspiMemory(); public: bool begin() override; FlashGeometry geometry() const override; int32_t read(uint32_t address, uint8_t *data, size_t length, MemoryReadFlags flags) override; int32_t write(uint32_t address, const uint8_t *data, size_t length, MemoryWriteFlags flags) override; int32_t erase(uint32_t address, size_t length); int32_t flush() override; public: int32_t execute(uint32_t *got, uint32_t *entry) override; }; } #endif
21.5
105
0.744186
[ "geometry" ]
46291b5c11cf9fa67a37dae6dea60978ca7e5234
4,419
h
C
frameworks/js/napi/http/include/napi_util.h
openharmony-gitee-mirror/communication_netstack
c0d7287181df7ae2507b9db2bd05ce98c94c119f
[ "Apache-2.0" ]
null
null
null
frameworks/js/napi/http/include/napi_util.h
openharmony-gitee-mirror/communication_netstack
c0d7287181df7ae2507b9db2bd05ce98c94c119f
[ "Apache-2.0" ]
null
null
null
frameworks/js/napi/http/include/napi_util.h
openharmony-gitee-mirror/communication_netstack
c0d7287181df7ae2507b9db2bd05ce98c94c119f
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef HTTP_NAPI_NAPI_UTIL_H #define HTTP_NAPI_NAPI_UTIL_H #include <string> #include <tuple> #include <type_traits> #include <vector> #include "napi/native_api.h" #include "napi/native_node_api.h" namespace OHOS { namespace NetManagerStandard { using vecNapiType = std::vector<napi_valuetype>; constexpr int32_t MAX_CHAR_LENGTH = 64; constexpr int32_t ERROR_DEFAULT = -1; constexpr int32_t maxUrlLength = 1024; constexpr int32_t SWITCH_PARAM_ZERO = 0; constexpr int32_t SWITCH_PARAM_ONE = 1; constexpr int32_t SWITCH_PARAM_TWO = 2; constexpr int32_t SWITCH_PARAM_THREE = 3; class NapiUtil { public: static const int32_t MAX_TEXT_LENGTH = 4096; static std::string ToUtf8(std::u16string str16); static std::u16string ToUtf16(std::string str); static napi_value CreateErrorMessage(napi_env env, std::string message, int32_t errorCode = ERROR_DEFAULT); static napi_value CreateUndefined(napi_env env); static bool MatchValueType(napi_env env, napi_value value, napi_valuetype targetType); static bool MatchParameters( napi_env env, const napi_value parameters[], std::initializer_list<napi_valuetype> valueTypes); static void SetPropertyInt32(napi_env env, napi_value object, std::string name, int32_t value); static void SetPropertyStringUtf8(napi_env env, napi_value object, std::string name, std::string value); static void SetPropertyBoolean(napi_env env, napi_value object, std::string name, bool value); static napi_value ToInt32Value(napi_env env, int value); static bool HasNamedProperty(napi_env env, napi_value object, std::string propertyName); static bool HasNamedTypeProperty( napi_env env, napi_value object, napi_valuetype type, std::string propertyName); static bool MatchObjectProperty( napi_env env, napi_value object, std::initializer_list<std::pair<std::string, napi_valuetype>> pairList); static bool MatchOptionPropertyType( napi_env env, napi_value object, napi_valuetype type, std::string propertyName); static std::string GetStringFromValue(napi_env env, napi_value value); static napi_value GetNamedProperty(napi_env env, napi_value object, std::string propertyName); static bool MatchHttpRequestDataParameters(napi_env env, const napi_value parameters[], size_t parameterCount); static bool MatchHttpOnDataParameters(napi_env env, const napi_value parameters[], size_t parameterCount); static bool MatchHttpOffDataParameters(napi_env env, const napi_value parameters[], size_t parameterCount); static void SetPropertyArray(napi_env env, napi_value object, std::string name, std::vector<std::string> pdu); static int32_t GetIntProperty(napi_env env, napi_value object, const std::string &propertyName); static std::string GetStringProperty(napi_env env, napi_value object, const std::string &propertyName); }; template<typename... Ts> bool MatchParameters( napi_env env, const napi_value argv[], size_t argc, std::tuple<Ts...> &theTuple, const vecNapiType &typeStd) { bool typeMatched = false; if (argc == typeStd.size()) { vecNapiType paraType; paraType.reserve(argc); for (size_t i = 0; i < argc; i++) { napi_valuetype valueType = napi_undefined; napi_typeof(env, argv[i], &valueType); paraType.emplace_back(valueType); } if (paraType == typeStd) { std::apply( [env, argc, &argv](Ts &...tupleArgs) { size_t index {0}; ((index < argc ? NapiValueConverted(env, argv[index++], tupleArgs) : napi_ok), ...); }, theTuple); typeMatched = true; } } return typeMatched; } } // namespace NetManagerStandard } // namespace OHOS #endif // NAPI_UTIL_H
45.556701
115
0.726182
[ "object", "vector" ]
463366cb8dfeae069d4524e8ab7c0670f49b0184
3,822
h
C
v3d_main/neuron_editing/apo_xforms.h
lens-biophotonics/v3d_external
44ff3b60a297a96eaa77ca092e0de9af5c990ed3
[ "MIT" ]
39
2015-05-10T23:23:03.000Z
2022-01-26T01:31:30.000Z
v3d_main/neuron_editing/apo_xforms.h
lens-biophotonics/v3d_external
44ff3b60a297a96eaa77ca092e0de9af5c990ed3
[ "MIT" ]
13
2016-03-04T05:29:23.000Z
2021-02-07T01:11:10.000Z
v3d_main/neuron_editing/apo_xforms.h
lens-biophotonics/v3d_external
44ff3b60a297a96eaa77ca092e0de9af5c990ed3
[ "MIT" ]
44
2015-11-11T07:30:59.000Z
2021-12-26T16:41:21.000Z
/* * Copyright (c)2006-2010 Hanchuan Peng (Janelia Farm, Howard Hughes Medical Institute). * All rights reserved. */ /************ ********* LICENSE NOTICE ************ This folder contains all source codes for the V3D project, which is subject to the following conditions if you want to use it. You will ***have to agree*** the following terms, *before* downloading/using/running/editing/changing any portion of codes in this package. 1. This package is free for non-profit research, but needs a special license for any commercial purpose. Please contact Hanchuan Peng for details. 2. You agree to appropriately cite this work in your related studies and publications. Peng, H., Ruan, Z., Long, F., Simpson, J.H., and Myers, E.W. (2010) “V3D enables real-time 3D visualization and quantitative analysis of large-scale biological image data sets,” Nature Biotechnology, Vol. 28, No. 4, pp. 348-353, DOI: 10.1038/nbt.1612. ( http://penglab.janelia.org/papersall/docpdf/2010_NBT_V3D.pdf ) Peng, H, Ruan, Z., Atasoy, D., and Sternson, S. (2010) “Automatic reconstruction of 3D neuron structures using a graph-augmented deformable model,” Bioinformatics, Vol. 26, pp. i38-i46, 2010. ( http://penglab.janelia.org/papersall/docpdf/2010_Bioinfo_GD_ISMB2010.pdf ) 3. This software is provided by the copyright holders (Hanchuan Peng), Howard Hughes Medical Institute, Janelia Farm Research Campus, and contributors "as is" and any express or implied warranties, including, but not limited to, any implied warranties of merchantability, non-infringement, or fitness for a particular purpose are disclaimed. In no event shall the copyright owner, Howard Hughes Medical Institute, Janelia Farm Research Campus, or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; reasonable royalties; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. 4. Neither the name of the Howard Hughes Medical Institute, Janelia Farm Research Campus, nor Hanchuan Peng, may be used to endorse or promote products derived from this software without specific prior written permission. *************/ //by Hanchuan Peng //090705 #ifndef __APO_XFORMS_H__ #define __APO_XFORMS_H__ #include "../basic_c_fun/basic_surf_objs.h" //some operations on apo' coordinate void proc_apo_add_offset(QList <CellAPO> *p, double xs, double ys, double zs); //add the offset to each node's coordinates void proc_apo_multiply_factor(QList <CellAPO> *p, double fx, double fy, double fz); //add the scaling factor sf to each node's coordinates without changing the center location void proc_apo_gmultiply_factor(QList <CellAPO> *p, double fx, double fy, double fz); //G-scaling, or global scaling that directly multiply a factor on each node's coordinates void proc_apo_mirror(QList <CellAPO> *p, bool b_flip_x, bool b_flip_y, bool b_flip_z); //flip the apo around its center for a dimension or all three dimensions void getAPOCellListCenter(QList <CellAPO> *p, double &cx, double &cy, double &cz); //get the center of the bounding box of a apo void proc_apo_affine(QList <CellAPO> *p, double afmatrix[16]); //affine transform using a 4x4 matrix void proc_apo_affine_around_center(QList <CellAPO> *p, double afmatrix[16], double cx, double cy, double cz); //affine transform using a 4x4 matrix, but affine-transfrom around the center void proc_apo_multiply_factor_radius(QList <CellAPO> *p, double sf); //scale the diameter of a apo #endif
76.44
941
0.762428
[ "model", "transform", "3d" ]
4640c5bdf9c77c98dfd03268eee45516c390aa8a
380
h
C
Net/Server.h
dllexport/cxxredis
91bebcea1c873b868a538742b17f3cf02f077de1
[ "BSD-3-Clause" ]
null
null
null
Net/Server.h
dllexport/cxxredis
91bebcea1c873b868a538742b17f3cf02f077de1
[ "BSD-3-Clause" ]
null
null
null
Net/Server.h
dllexport/cxxredis
91bebcea1c873b868a538742b17f3cf02f077de1
[ "BSD-3-Clause" ]
null
null
null
// // Created by Mario on 2020/5/17. // #pragma once #include <boost/asio/ip/tcp.hpp> #include "../Utils/Singleton.h" /* * impl socket related services */ class Server : public Singleton<Server> { public: Server() {} void Init(); private: using Acceptor = boost::asio::ip::tcp::acceptor; std::vector<Acceptor> acceptors; void runAccept(int which); };
14.074074
52
0.644737
[ "vector" ]
46413e0956eac7f78c7e2bc3579132a7da00e26b
5,453
c
C
sample/sgdk/src/main.c
superctr/MDSDRV
ab7eb00c370bcd794efbe9447bf60dd20cea9b5e
[ "Zlib" ]
34
2020-10-11T22:35:56.000Z
2022-02-23T07:53:37.000Z
sample/sgdk/src/main.c
superctr/MDSDRV
ab7eb00c370bcd794efbe9447bf60dd20cea9b5e
[ "Zlib" ]
5
2020-10-18T22:13:08.000Z
2022-02-22T14:42:25.000Z
sample/sgdk/src/main.c
superctr/MDSDRV
ab7eb00c370bcd794efbe9447bf60dd20cea9b5e
[ "Zlib" ]
1
2021-04-06T00:34:18.000Z
2021-04-06T00:34:18.000Z
#include <genesis.h> #include "menu.h" #include "mdsdrv.h" u16 cursor; #define ITEM_BGM 0 #define ITEM_VOLUME 1 #define ITEM_TEMPO 2 #define ITEM_BGMVOL 3 #define ITEM_SEVOL 4 #define ITEM_GTEMPO 5 #define ITEM_FTARGET 6 #define ITEM_FSPEED 7 #define ITEM_SE1 8 #define ITEM_SE2 9 #define ITEM_SE3 10 #define ITEM_MAX 10 /* Temp text buffer */ static char buf[40]; static bool pause = FALSE; void vbl_callback(); void init_menu(); void draw_instructions(); void draw_status(u16 x, u16 y); /* * MDSDRV must always run in vblank. */ void vbl_callback() { MDS_update(); } /* * Program entry */ int main(u16 hard) { JOY_init(); VDP_drawText("Initializing MDSDRV ...", 2, 2); /* * Initialize MDSDRV (done once) */ if(MDS_init(mdsseqdat, mdspcmdat)) { VDP_drawText("MDSDRV init failed!!!!!", 2, 2); VDP_drawText("Please make sure that the driver and", 2, 4); VDP_drawText("sequence data version matches.", 2, 5); return 0; } /* * run MDSDRV in callback */ SYS_setVIntCallback(vbl_callback); /* * Draw menu */ init_menu(); while(TRUE) { u16 action; menu_update_value(ITEM_VOLUME, MDS_command(MDS_CMD_GET_VOLUME, MDS_BGM)); menu_update_value(ITEM_TEMPO, MDS_command(MDS_CMD_GET_TEMPO, MDS_BGM)); menu_update_value(ITEM_GTEMPO, MDS_command(MDS_CMD_GET_GTEMPO, 0)); #if 0 // These values are normally not modified by the driver itself, so // there is no need to update the values continuously here. action = MDS_command(MDS_CMD_GET_GVOLUME, 0); menu_update_value(ITEM_BGMVOL, action >> 8); menu_update_value(ITEM_SEVOL, action & 0xff); #endif action = menu_update(); switch(action) { default: draw_status(10, 24); break; case MENU_ACTION_UD: // Update cursor draw_instructions(); break; case MENU_ACTION_LR: // Update value switch(menu_cursor) { case ITEM_VOLUME: MDS_command2(MDS_CMD_SET_VOLUME, MDS_BGM, menu_val[ITEM_VOLUME]); break; case ITEM_TEMPO: MDS_command2(MDS_CMD_SET_TEMPO, MDS_BGM, menu_val[ITEM_TEMPO]); break; case ITEM_GTEMPO: MDS_command(MDS_CMD_SET_GTEMPO, menu_val[ITEM_GTEMPO]); break; case ITEM_BGMVOL: case ITEM_SEVOL: MDS_command(MDS_CMD_SET_GVOLUME, (menu_val[ITEM_BGMVOL]<<8)|(menu_val[ITEM_SEVOL] & 0xff)); default: break; } break; case MENU_ACTION_A: // Play music if(menu_cursor < ITEM_FTARGET) MDS_request(MDS_BGM, menu_val[ITEM_BGM]), pause = FALSE; else if(menu_cursor < ITEM_SE1) MDS_fade(menu_val[ITEM_FTARGET], menu_val[ITEM_FSPEED], FALSE); else MDS_request(MDS_SE1, menu_val[ITEM_SE1]); break; case MENU_ACTION_B: // Stop music if(menu_cursor < ITEM_FTARGET) MDS_request(MDS_BGM, 0); else if(menu_cursor < ITEM_SE1) MDS_fade(0x00, menu_val[ITEM_FSPEED], FALSE); else MDS_request(MDS_SE2, menu_val[ITEM_SE2]); break; case MENU_ACTION_C: // Fade out music if(menu_cursor < ITEM_FTARGET) MDS_fade(0x50, 3, TRUE); else if(menu_cursor >= ITEM_SE1) MDS_request(MDS_SE3, menu_val[ITEM_SE3]); break; case MENU_ACTION_START: pause ^= 1; MDS_pause(MDS_BGM, pause); break; } /* * Print cpu load. Turns out that drawing the menu options consumes * a lot more cycles than actually running the sound driver... */ sprintf(buf, "%3d", SYS_getCPULoad()); VDP_drawText(buf, 35, 1); #if 0 /* SGDK < v1.60 */ VDP_waitVSync(); #else /* SGDK >= v1.60 */ SYS_doVBlankProcess(); #endif } return 0; } /* * Initializes the menu options and draws the static text */ void init_menu() { VDP_clearPlane(0, FALSE); menu_add_item(ITEM_BGM, "BGM", 1, 0, MDS_command(MDS_CMD_GET_SOUND_CNT, 0)); menu_add_item(ITEM_VOLUME, "BGM volume", 0, 0, 127); menu_add_item(ITEM_TEMPO, "BGM tempo", 0, 0, 511); menu_add_item(ITEM_BGMVOL, "Initial BGM vol", 0, 0, 127); menu_add_item(ITEM_SEVOL, "Initial SE vol", 0, 0, 127); menu_add_item(ITEM_GTEMPO, "Global tempo", 16, 16, 511); //lower values cause higher CPU load menu_add_item(ITEM_FTARGET, "Fade target", 20, 0, 127); menu_add_item(ITEM_FSPEED, "Fade speed", 5, 0, 7); menu_add_item(ITEM_SE1, "SE1", SE_BEEP3, SE_MIN, SE_MAX); menu_add_item(ITEM_SE2, "SE2", SE_NOISE1, SE_MIN, SE_MAX); menu_add_item(ITEM_SE3, "SE3", SE_EXPLOSION2, SE_MIN, SE_MAX); menu_init(ITEM_MAX); draw_instructions(); VDP_drawText("MDSDRV SGDK Test Program", 2, 2); VDP_drawText("Version", 2, 22); VDP_drawText(MDS_get_version_str(), 10, 22); VDP_drawText("Status", 2, 24); VDP_drawText("%", 38, 1); }; static const char* instruction_text[] = { // 0123456789012345678901234567890123456789 " A: Play, B: Stop, C: Fade out ", " A: Play SE1, B: Play SE2, C: Play SE3 ", " A: Fade out, B: Fade in " }; /* * Updates the A,B,C button instructions */ void draw_instructions() { const char* str = instruction_text[0]; if(menu_cursor >= ITEM_SE1) str = instruction_text[1]; else if(menu_cursor >= ITEM_FTARGET) str = instruction_text[2]; VDP_setTextPalette(0); VDP_drawText(str, 0, 26); } /* * Displays the currently used tracks for each request slot */ void draw_status(u16 x, u16 y) { sprintf(buf, "%04x %04x %04x %04x", MDS_command(MDS_CMD_GET_STATUS, 0), MDS_command(MDS_CMD_GET_STATUS, 1), MDS_command(MDS_CMD_GET_STATUS, 2), MDS_command(MDS_CMD_GET_STATUS, 3)); VDP_setTextPalette((pause) ? 1 : 0); VDP_drawText(buf, x, y); }
24.899543
97
0.689529
[ "3d" ]
dfac74678e708b3a61869db0ab2a562c1bf2523d
1,912
h
C
polyhedra/src/SpotLight.h
Ezia/IN55-Polyhedra
7d0c3e01cc30a728448a8c590eaca739b54a9b8e
[ "MIT" ]
null
null
null
polyhedra/src/SpotLight.h
Ezia/IN55-Polyhedra
7d0c3e01cc30a728448a8c590eaca739b54a9b8e
[ "MIT" ]
13
2017-04-18T17:48:34.000Z
2017-06-06T08:31:17.000Z
polyhedra/src/SpotLight.h
Ezia/IN55-Polyhedra
7d0c3e01cc30a728448a8c590eaca739b54a9b8e
[ "MIT" ]
null
null
null
#ifndef SPOTLIGHT_H #define SPOTLIGHT_H #include <QMatrix4x4> #include <QVector3D> #include "Types.h" class QOpenGLFramebufferObject; class QOpenGLShaderProgram; // Spot light based on a projective matrix class SpotLight { public: SpotLight(); virtual ~SpotLight(); QVector3D getSpecular() const; QVector3D getDiffuse() const; QVector3D getAmbient() const; QVector3D getDirection() const; QVector3D getPosition() const; QVector3D getUpDirection() const; float32 getVerticalAngle() const; float32 getHorizontalAngle() const; float32 getNearPlan() const; float32 getFarPlan() const; float32 getPixelPerDegree() const; float32 getShadowTextureBias() const; QMatrix4x4 getProjection(); QOpenGLFramebufferObject* getShadowTexture(); void setSpecular(QVector3D specular); void setAmbient(QVector3D ambient); void setDiffuse(QVector3D diffuse); void setDirection(QVector3D direction); void setUpDirection(QVector3D upDirection); void setPosition(QVector3D position); void setNearPlan(float32 nearPlan); void setFarPlan(float32 farPlan); void setVerticalAngle(float32 verticalAngle); void setHorizontalAngle(float32 horizontalAngle); void setPixelPerDegree(float32 pixelPerDegree); void setShadowTextureBias(float32 shadowTextureBias); private: void updateShadowTexture(); // transform from world ref to projected light ref QMatrix4x4 m_projection; QVector3D m_direction; QVector3D m_upDirection; QVector3D m_position; float32 m_verticalAngle; float32 m_horizontalAngle; float32 m_nearPlan; float32 m_farPlan; float32 m_pixelPerDegree; float32 m_shadowTextureBias; QOpenGLFramebufferObject* m_shadowTexture; bool m_shadowTextureUpToDate; QVector3D m_specular; QVector3D m_diffuse; QVector3D m_ambient; }; #endif // SPOTLIGHT_H
26.191781
57
0.751569
[ "transform" ]
dfb45be9b1bb704310d8198f16968d69d0377234
2,413
h
C
blades/xbmc/xbmc/osx/IOSEAGLView.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
4
2016-04-26T03:43:54.000Z
2016-11-17T08:09:04.000Z
blades/xbmc/xbmc/osx/IOSEAGLView.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
17
2015-01-05T21:06:22.000Z
2015-12-07T20:45:44.000Z
blades/xbmc/xbmc/osx/IOSEAGLView.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
3
2016-04-26T03:43:55.000Z
2020-11-06T11:02:08.000Z
/* * Copyright (C) 2010-2013 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XBMC; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. * */ #import <UIKit/UIKit.h> #import <OpenGLES/EAGL.h> #import <OpenGLES/ES2/gl.h> // This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. // The view content is basically an EAGL surface you render your OpenGL scene into. // Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. @interface IOSEAGLView : UIView { @private EAGLContext *context; // The pixel dimensions of the CAEAGLLayer. GLint framebufferWidth; GLint framebufferHeight; // The OpenGL ES names for the framebuffer and renderbuffer used to render to this view. GLuint defaultFramebuffer, colorRenderbuffer, depthRenderbuffer; // the shader program object GLuint program; // GLfloat rotz; BOOL animating; BOOL xbmcAlive; BOOL readyToRun; BOOL pause; NSConditionLock* animationThreadLock; NSThread* animationThread; UIScreen *currentScreen; BOOL framebufferResizeRequested; } @property (readonly, nonatomic, getter=isAnimating) BOOL animating; @property (readonly, nonatomic, getter=isXBMCAlive) BOOL xbmcAlive; @property (readonly, nonatomic, getter=isReadyToRun) BOOL readyToRun; @property (readonly, nonatomic, getter=isPause) BOOL pause; @property (readonly, getter=getCurrentScreen) UIScreen *currentScreen; @property BOOL framebufferResizeRequested; - (id)initWithFrame:(CGRect)frame withScreen:(UIScreen *)screen; - (void) pauseAnimation; - (void) resumeAnimation; - (void) startAnimation; - (void) stopAnimation; - (void) setFramebuffer; - (bool) presentFramebuffer; - (void) setScreen:(UIScreen *)screen withFrameBufferResize:(BOOL)resize; - (CGFloat) getScreenScale:(UIScreen *)screen; @end
34.971014
97
0.754662
[ "render", "object" ]
dfbca1076226acb5433b965ca0920363ffe4fca0
5,453
h
C
cdb/include/tencentcloud/cdb/v20170320/model/SwitchDBInstanceMasterSlaveRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
43
2019-08-14T08:14:12.000Z
2022-03-30T12:35:09.000Z
cdb/include/tencentcloud/cdb/v20170320/model/SwitchDBInstanceMasterSlaveRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
12
2019-07-15T10:44:59.000Z
2021-11-02T12:35:00.000Z
cdb/include/tencentcloud/cdb/v20170320/model/SwitchDBInstanceMasterSlaveRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
28
2019-07-12T09:06:22.000Z
2022-03-30T08:04:18.000Z
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TENCENTCLOUD_CDB_V20170320_MODEL_SWITCHDBINSTANCEMASTERSLAVEREQUEST_H_ #define TENCENTCLOUD_CDB_V20170320_MODEL_SWITCHDBINSTANCEMASTERSLAVEREQUEST_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/AbstractModel.h> namespace TencentCloud { namespace Cdb { namespace V20170320 { namespace Model { /** * SwitchDBInstanceMasterSlave请求参数结构体 */ class SwitchDBInstanceMasterSlaveRequest : public AbstractModel { public: SwitchDBInstanceMasterSlaveRequest(); ~SwitchDBInstanceMasterSlaveRequest() = default; std::string ToJsonString() const; /** * 获取实例 ID。 * @return InstanceId 实例 ID。 */ std::string GetInstanceId() const; /** * 设置实例 ID。 * @param InstanceId 实例 ID。 */ void SetInstanceId(const std::string& _instanceId); /** * 判断参数 InstanceId 是否已赋值 * @return InstanceId 是否已赋值 */ bool InstanceIdHasBeenSet() const; /** * 获取目标从实例。可选值:"first" - 第一备机;"second" - 第二备机。默认值为 "first",仅多可用区实例支持设置为 "second"。 * @return DstSlave 目标从实例。可选值:"first" - 第一备机;"second" - 第二备机。默认值为 "first",仅多可用区实例支持设置为 "second"。 */ std::string GetDstSlave() const; /** * 设置目标从实例。可选值:"first" - 第一备机;"second" - 第二备机。默认值为 "first",仅多可用区实例支持设置为 "second"。 * @param DstSlave 目标从实例。可选值:"first" - 第一备机;"second" - 第二备机。默认值为 "first",仅多可用区实例支持设置为 "second"。 */ void SetDstSlave(const std::string& _dstSlave); /** * 判断参数 DstSlave 是否已赋值 * @return DstSlave 是否已赋值 */ bool DstSlaveHasBeenSet() const; /** * 获取是否强制切换。默认为 False。注意,若设置强制切换为 True,实例存在丢失数据的风险,请谨慎使用。 * @return ForceSwitch 是否强制切换。默认为 False。注意,若设置强制切换为 True,实例存在丢失数据的风险,请谨慎使用。 */ bool GetForceSwitch() const; /** * 设置是否强制切换。默认为 False。注意,若设置强制切换为 True,实例存在丢失数据的风险,请谨慎使用。 * @param ForceSwitch 是否强制切换。默认为 False。注意,若设置强制切换为 True,实例存在丢失数据的风险,请谨慎使用。 */ void SetForceSwitch(const bool& _forceSwitch); /** * 判断参数 ForceSwitch 是否已赋值 * @return ForceSwitch 是否已赋值 */ bool ForceSwitchHasBeenSet() const; /** * 获取是否时间窗内切换。默认为 False,即不在时间窗内切换。注意,如果设置了 ForceSwitch 参数为 True,则该参数不生效。 * @return WaitSwitch 是否时间窗内切换。默认为 False,即不在时间窗内切换。注意,如果设置了 ForceSwitch 参数为 True,则该参数不生效。 */ bool GetWaitSwitch() const; /** * 设置是否时间窗内切换。默认为 False,即不在时间窗内切换。注意,如果设置了 ForceSwitch 参数为 True,则该参数不生效。 * @param WaitSwitch 是否时间窗内切换。默认为 False,即不在时间窗内切换。注意,如果设置了 ForceSwitch 参数为 True,则该参数不生效。 */ void SetWaitSwitch(const bool& _waitSwitch); /** * 判断参数 WaitSwitch 是否已赋值 * @return WaitSwitch 是否已赋值 */ bool WaitSwitchHasBeenSet() const; private: /** * 实例 ID。 */ std::string m_instanceId; bool m_instanceIdHasBeenSet; /** * 目标从实例。可选值:"first" - 第一备机;"second" - 第二备机。默认值为 "first",仅多可用区实例支持设置为 "second"。 */ std::string m_dstSlave; bool m_dstSlaveHasBeenSet; /** * 是否强制切换。默认为 False。注意,若设置强制切换为 True,实例存在丢失数据的风险,请谨慎使用。 */ bool m_forceSwitch; bool m_forceSwitchHasBeenSet; /** * 是否时间窗内切换。默认为 False,即不在时间窗内切换。注意,如果设置了 ForceSwitch 参数为 True,则该参数不生效。 */ bool m_waitSwitch; bool m_waitSwitchHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_CDB_V20170320_MODEL_SWITCHDBINSTANCEMASTERSLAVEREQUEST_H_
36.353333
116
0.49239
[ "vector", "model" ]
dfc0c01f446eb54a56642463c052ba0110016ac1
13,714
c
C
model/ezsigntemplate_response_compound.c
ezmaxinc/eZmax-SDK-c
725eab79d6311127a2d5bd731b978bce94142d69
[ "curl", "MIT" ]
null
null
null
model/ezsigntemplate_response_compound.c
ezmaxinc/eZmax-SDK-c
725eab79d6311127a2d5bd731b978bce94142d69
[ "curl", "MIT" ]
null
null
null
model/ezsigntemplate_response_compound.c
ezmaxinc/eZmax-SDK-c
725eab79d6311127a2d5bd731b978bce94142d69
[ "curl", "MIT" ]
null
null
null
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "ezsigntemplate_response_compound.h" ezsigntemplate_response_compound_t *ezsigntemplate_response_compound_create( int pki_ezsigntemplate_id, int fki_ezsigntemplatedocument_id, int fki_ezsignfoldertype_id, int fki_language_id, char *s_language_name_x, char *s_ezsigntemplate_description, int b_ezsigntemplate_adminonly, char *s_ezsignfoldertype_name_x, ezsigntemplatedocument_response_t *obj_ezsigntemplatedocument, list_t *a_obj_ezsigntemplatesigner ) { ezsigntemplate_response_compound_t *ezsigntemplate_response_compound_local_var = malloc(sizeof(ezsigntemplate_response_compound_t)); if (!ezsigntemplate_response_compound_local_var) { return NULL; } ezsigntemplate_response_compound_local_var->pki_ezsigntemplate_id = pki_ezsigntemplate_id; ezsigntemplate_response_compound_local_var->fki_ezsigntemplatedocument_id = fki_ezsigntemplatedocument_id; ezsigntemplate_response_compound_local_var->fki_ezsignfoldertype_id = fki_ezsignfoldertype_id; ezsigntemplate_response_compound_local_var->fki_language_id = fki_language_id; ezsigntemplate_response_compound_local_var->s_language_name_x = s_language_name_x; ezsigntemplate_response_compound_local_var->s_ezsigntemplate_description = s_ezsigntemplate_description; ezsigntemplate_response_compound_local_var->b_ezsigntemplate_adminonly = b_ezsigntemplate_adminonly; ezsigntemplate_response_compound_local_var->s_ezsignfoldertype_name_x = s_ezsignfoldertype_name_x; ezsigntemplate_response_compound_local_var->obj_ezsigntemplatedocument = obj_ezsigntemplatedocument; ezsigntemplate_response_compound_local_var->a_obj_ezsigntemplatesigner = a_obj_ezsigntemplatesigner; return ezsigntemplate_response_compound_local_var; } void ezsigntemplate_response_compound_free(ezsigntemplate_response_compound_t *ezsigntemplate_response_compound) { if(NULL == ezsigntemplate_response_compound){ return ; } listEntry_t *listEntry; if (ezsigntemplate_response_compound->s_language_name_x) { free(ezsigntemplate_response_compound->s_language_name_x); ezsigntemplate_response_compound->s_language_name_x = NULL; } if (ezsigntemplate_response_compound->s_ezsigntemplate_description) { free(ezsigntemplate_response_compound->s_ezsigntemplate_description); ezsigntemplate_response_compound->s_ezsigntemplate_description = NULL; } if (ezsigntemplate_response_compound->s_ezsignfoldertype_name_x) { free(ezsigntemplate_response_compound->s_ezsignfoldertype_name_x); ezsigntemplate_response_compound->s_ezsignfoldertype_name_x = NULL; } if (ezsigntemplate_response_compound->obj_ezsigntemplatedocument) { ezsigntemplatedocument_response_free(ezsigntemplate_response_compound->obj_ezsigntemplatedocument); ezsigntemplate_response_compound->obj_ezsigntemplatedocument = NULL; } if (ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner) { list_ForEach(listEntry, ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner) { ezsigntemplatesigner_response_compound_free(listEntry->data); } list_freeList(ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner); ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner = NULL; } free(ezsigntemplate_response_compound); } cJSON *ezsigntemplate_response_compound_convertToJSON(ezsigntemplate_response_compound_t *ezsigntemplate_response_compound) { cJSON *item = cJSON_CreateObject(); // ezsigntemplate_response_compound->pki_ezsigntemplate_id if (!ezsigntemplate_response_compound->pki_ezsigntemplate_id) { goto fail; } if(cJSON_AddNumberToObject(item, "pkiEzsigntemplateID", ezsigntemplate_response_compound->pki_ezsigntemplate_id) == NULL) { goto fail; //Numeric } // ezsigntemplate_response_compound->fki_ezsigntemplatedocument_id if(ezsigntemplate_response_compound->fki_ezsigntemplatedocument_id) { if(cJSON_AddNumberToObject(item, "fkiEzsigntemplatedocumentID", ezsigntemplate_response_compound->fki_ezsigntemplatedocument_id) == NULL) { goto fail; //Numeric } } // ezsigntemplate_response_compound->fki_ezsignfoldertype_id if (!ezsigntemplate_response_compound->fki_ezsignfoldertype_id) { goto fail; } if(cJSON_AddNumberToObject(item, "fkiEzsignfoldertypeID", ezsigntemplate_response_compound->fki_ezsignfoldertype_id) == NULL) { goto fail; //Numeric } // ezsigntemplate_response_compound->fki_language_id if (!ezsigntemplate_response_compound->fki_language_id) { goto fail; } if(cJSON_AddNumberToObject(item, "fkiLanguageID", ezsigntemplate_response_compound->fki_language_id) == NULL) { goto fail; //Numeric } // ezsigntemplate_response_compound->s_language_name_x if (!ezsigntemplate_response_compound->s_language_name_x) { goto fail; } if(cJSON_AddStringToObject(item, "sLanguageNameX", ezsigntemplate_response_compound->s_language_name_x) == NULL) { goto fail; //String } // ezsigntemplate_response_compound->s_ezsigntemplate_description if (!ezsigntemplate_response_compound->s_ezsigntemplate_description) { goto fail; } if(cJSON_AddStringToObject(item, "sEzsigntemplateDescription", ezsigntemplate_response_compound->s_ezsigntemplate_description) == NULL) { goto fail; //String } // ezsigntemplate_response_compound->b_ezsigntemplate_adminonly if (!ezsigntemplate_response_compound->b_ezsigntemplate_adminonly) { goto fail; } if(cJSON_AddBoolToObject(item, "bEzsigntemplateAdminonly", ezsigntemplate_response_compound->b_ezsigntemplate_adminonly) == NULL) { goto fail; //Bool } // ezsigntemplate_response_compound->s_ezsignfoldertype_name_x if (!ezsigntemplate_response_compound->s_ezsignfoldertype_name_x) { goto fail; } if(cJSON_AddStringToObject(item, "sEzsignfoldertypeNameX", ezsigntemplate_response_compound->s_ezsignfoldertype_name_x) == NULL) { goto fail; //String } // ezsigntemplate_response_compound->obj_ezsigntemplatedocument if(ezsigntemplate_response_compound->obj_ezsigntemplatedocument) { cJSON *obj_ezsigntemplatedocument_local_JSON = ezsigntemplatedocument_response_convertToJSON(ezsigntemplate_response_compound->obj_ezsigntemplatedocument); if(obj_ezsigntemplatedocument_local_JSON == NULL) { goto fail; //model } cJSON_AddItemToObject(item, "objEzsigntemplatedocument", obj_ezsigntemplatedocument_local_JSON); if(item->child == NULL) { goto fail; } } // ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner if (!ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner) { goto fail; } cJSON *a_obj_ezsigntemplatesigner = cJSON_AddArrayToObject(item, "a_objEzsigntemplatesigner"); if(a_obj_ezsigntemplatesigner == NULL) { goto fail; //nonprimitive container } listEntry_t *a_obj_ezsigntemplatesignerListEntry; if (ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner) { list_ForEach(a_obj_ezsigntemplatesignerListEntry, ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner) { cJSON *itemLocal = ezsigntemplatesigner_response_compound_convertToJSON(a_obj_ezsigntemplatesignerListEntry->data); if(itemLocal == NULL) { goto fail; } cJSON_AddItemToArray(a_obj_ezsigntemplatesigner, itemLocal); } } return item; fail: if (item) { cJSON_Delete(item); } return NULL; } ezsigntemplate_response_compound_t *ezsigntemplate_response_compound_parseFromJSON(cJSON *ezsigntemplate_response_compoundJSON){ ezsigntemplate_response_compound_t *ezsigntemplate_response_compound_local_var = NULL; // define the local variable for ezsigntemplate_response_compound->obj_ezsigntemplatedocument ezsigntemplatedocument_response_t *obj_ezsigntemplatedocument_local_nonprim = NULL; // define the local list for ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner list_t *a_obj_ezsigntemplatesignerList = NULL; // ezsigntemplate_response_compound->pki_ezsigntemplate_id cJSON *pki_ezsigntemplate_id = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "pkiEzsigntemplateID"); if (!pki_ezsigntemplate_id) { goto end; } if(!cJSON_IsNumber(pki_ezsigntemplate_id)) { goto end; //Numeric } // ezsigntemplate_response_compound->fki_ezsigntemplatedocument_id cJSON *fki_ezsigntemplatedocument_id = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "fkiEzsigntemplatedocumentID"); if (fki_ezsigntemplatedocument_id) { if(!cJSON_IsNumber(fki_ezsigntemplatedocument_id)) { goto end; //Numeric } } // ezsigntemplate_response_compound->fki_ezsignfoldertype_id cJSON *fki_ezsignfoldertype_id = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "fkiEzsignfoldertypeID"); if (!fki_ezsignfoldertype_id) { goto end; } if(!cJSON_IsNumber(fki_ezsignfoldertype_id)) { goto end; //Numeric } // ezsigntemplate_response_compound->fki_language_id cJSON *fki_language_id = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "fkiLanguageID"); if (!fki_language_id) { goto end; } if(!cJSON_IsNumber(fki_language_id)) { goto end; //Numeric } // ezsigntemplate_response_compound->s_language_name_x cJSON *s_language_name_x = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "sLanguageNameX"); if (!s_language_name_x) { goto end; } if(!cJSON_IsString(s_language_name_x)) { goto end; //String } // ezsigntemplate_response_compound->s_ezsigntemplate_description cJSON *s_ezsigntemplate_description = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "sEzsigntemplateDescription"); if (!s_ezsigntemplate_description) { goto end; } if(!cJSON_IsString(s_ezsigntemplate_description)) { goto end; //String } // ezsigntemplate_response_compound->b_ezsigntemplate_adminonly cJSON *b_ezsigntemplate_adminonly = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "bEzsigntemplateAdminonly"); if (!b_ezsigntemplate_adminonly) { goto end; } if(!cJSON_IsBool(b_ezsigntemplate_adminonly)) { goto end; //Bool } // ezsigntemplate_response_compound->s_ezsignfoldertype_name_x cJSON *s_ezsignfoldertype_name_x = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "sEzsignfoldertypeNameX"); if (!s_ezsignfoldertype_name_x) { goto end; } if(!cJSON_IsString(s_ezsignfoldertype_name_x)) { goto end; //String } // ezsigntemplate_response_compound->obj_ezsigntemplatedocument cJSON *obj_ezsigntemplatedocument = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "objEzsigntemplatedocument"); if (obj_ezsigntemplatedocument) { obj_ezsigntemplatedocument_local_nonprim = ezsigntemplatedocument_response_parseFromJSON(obj_ezsigntemplatedocument); //nonprimitive } // ezsigntemplate_response_compound->a_obj_ezsigntemplatesigner cJSON *a_obj_ezsigntemplatesigner = cJSON_GetObjectItemCaseSensitive(ezsigntemplate_response_compoundJSON, "a_objEzsigntemplatesigner"); if (!a_obj_ezsigntemplatesigner) { goto end; } cJSON *a_obj_ezsigntemplatesigner_local_nonprimitive = NULL; if(!cJSON_IsArray(a_obj_ezsigntemplatesigner)){ goto end; //nonprimitive container } a_obj_ezsigntemplatesignerList = list_createList(); cJSON_ArrayForEach(a_obj_ezsigntemplatesigner_local_nonprimitive,a_obj_ezsigntemplatesigner ) { if(!cJSON_IsObject(a_obj_ezsigntemplatesigner_local_nonprimitive)){ goto end; } ezsigntemplatesigner_response_compound_t *a_obj_ezsigntemplatesignerItem = ezsigntemplatesigner_response_compound_parseFromJSON(a_obj_ezsigntemplatesigner_local_nonprimitive); list_addElement(a_obj_ezsigntemplatesignerList, a_obj_ezsigntemplatesignerItem); } ezsigntemplate_response_compound_local_var = ezsigntemplate_response_compound_create ( pki_ezsigntemplate_id->valuedouble, fki_ezsigntemplatedocument_id ? fki_ezsigntemplatedocument_id->valuedouble : 0, fki_ezsignfoldertype_id->valuedouble, fki_language_id->valuedouble, strdup(s_language_name_x->valuestring), strdup(s_ezsigntemplate_description->valuestring), b_ezsigntemplate_adminonly->valueint, strdup(s_ezsignfoldertype_name_x->valuestring), obj_ezsigntemplatedocument ? obj_ezsigntemplatedocument_local_nonprim : NULL, a_obj_ezsigntemplatesignerList ); return ezsigntemplate_response_compound_local_var; end: if (obj_ezsigntemplatedocument_local_nonprim) { ezsigntemplatedocument_response_free(obj_ezsigntemplatedocument_local_nonprim); obj_ezsigntemplatedocument_local_nonprim = NULL; } if (a_obj_ezsigntemplatesignerList) { listEntry_t *listEntry = NULL; list_ForEach(listEntry, a_obj_ezsigntemplatesignerList) { ezsigntemplatesigner_response_compound_free(listEntry->data); listEntry->data = NULL; } list_freeList(a_obj_ezsigntemplatesignerList); a_obj_ezsigntemplatesignerList = NULL; } return NULL; }
39.182857
183
0.778839
[ "model" ]
dfd77bb9329069a9d37765ef7b350e71b4a86fc5
670
h
C
src/thememanager.h
latproc/humid
dfd111c74e6cedddff82e078faa1c507080d2529
[ "curl", "BSD-3-Clause" ]
1
2022-02-28T10:34:42.000Z
2022-02-28T10:34:42.000Z
src/thememanager.h
latproc/humid
dfd111c74e6cedddff82e078faa1c507080d2529
[ "curl", "BSD-3-Clause" ]
19
2019-07-04T23:18:42.000Z
2019-07-31T13:16:34.000Z
src/thememanager.h
latproc/humid
dfd111c74e6cedddff82e078faa1c507080d2529
[ "curl", "BSD-3-Clause" ]
null
null
null
#pragma once #include <string> #include <nanogui/object.h> #include <nanogui/theme.h> #include <nanogui/common.h> class Structure; class ThemeManager { public: static ThemeManager & instance(); void addTheme(const std::string &name, nanogui::Theme *theme); nanogui::Theme *findTheme(const std::string &name); // A context to create the theme in. void setContext(NVGcontext *context); // Construct a theme from a given structure definition. nanogui::Theme *createTheme(Structure *settings = nullptr); private: class Pimpl; Pimpl *impl = nullptr; ThemeManager(); ~ThemeManager(); static ThemeManager *theme_manager; };
23.928571
66
0.701493
[ "object" ]
dfdfc53d447df8ae8c5207c3a36e46ea8d98cef4
2,873
h
C
examples/uvmsc/simple/registers/models/aliasing/tb_test.h
stoitchog/uvm-systemc-1.0-beta2
67a445dc5f587d2fd16c5b5ee913d086b2242583
[ "ECL-2.0", "Apache-2.0" ]
4
2021-11-04T14:37:00.000Z
2022-03-14T12:57:50.000Z
examples/uvmsc/simple/registers/models/aliasing/tb_test.h
stoitchog/uvm-systemc-1.0-beta2
67a445dc5f587d2fd16c5b5ee913d086b2242583
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
examples/uvmsc/simple/registers/models/aliasing/tb_test.h
stoitchog/uvm-systemc-1.0-beta2
67a445dc5f587d2fd16c5b5ee913d086b2242583
[ "ECL-2.0", "Apache-2.0" ]
1
2021-02-22T05:46:04.000Z
2021-02-22T05:46:04.000Z
//---------------------------------------------------------------------- // Copyright 2013-2014 NXP B.V. // Copyright 2004-2011 Synopsys, Inc. // Copyright 2010 Mentor Graphics Corporation // Copyright 2010-2011 Cadence Design Systems, Inc. // All Rights Reserved Worldwide // // Licensed under the Apache License, Version 2.0 (the // "License"); you may not use this file except in // compliance with the License. You may obtain a copy of // the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in // writing, software distributed under the License is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See // the License for the specific language governing // permissions and limitations under the License. //---------------------------------------------------------------------- #ifndef TB_TEST_H_ #define TB_TEST_H_ #include <systemc> #include <uvm> #include "regmodel.h" #include "tb_env.h" class tb_test : public uvm::uvm_test { public: tb_env* env; uvm::uvm_reg_sequence<>* seq; tb_test( uvm::uvm_component_name name = "tb_test") : uvm::uvm_test(name), env(NULL), seq(NULL) {} UVM_COMPONENT_UTILS(tb_test); void build_phase(uvm::uvm_phase& phase) { uvm::uvm_test::build_phase(phase); env = tb_env::type_id::create("tb_env"); seq = uvm::uvm_reg_bit_bash_seq::type_id::create("seq"); } void run_phase(uvm::uvm_phase& phase) { /* TODO uvm::uvm_status_e status; */ phase.raise_objection(this); env->regmodel->reset(); seq->model = env->regmodel; seq->start(env->bus->sqr); seq->wait_for_sequence_state(uvm::UVM_FINISHED); /* TODO UVM_INFO("Test", "Verifying aliasing...", uvm::UVM_NONE); env->regmodel->Ra->write(status, 0xDEADBEEF, uvm::UVM_DEFAULT_PATH, NULL, seq); env->regmodel->mirror(status, uvm::UVM_CHECK, uvm::UVM_DEFAULT_PATH, seq); env->regmodel->Rb->write(status, 0x87654320, uvm::UVM_DEFAULT_PATH, NULL, seq); env->regmodel->mirror(status, uvm::UVM_CHECK, uvm::UVM_DEFAULT_PATH, seq); env->regmodel->Ra->F1->write(status, 0xA5, uvm::UVM_DEFAULT_PATH, NULL, seq); env->regmodel->mirror(status, uvm::UVM_CHECK, uvm::UVM_DEFAULT_PATH, seq); env->regmodel->Rb->F1->write(status, 0xC3, uvm::UVM_DEFAULT_PATH, NULL, seq); env->regmodel->mirror(status, uvm::UVM_CHECK, uvm::UVM_DEFAULT_PATH, seq); env->regmodel->Ra->F2->write(status, 0xBD, uvm::UVM_DEFAULT_PATH, NULL, seq); env->regmodel->mirror(status, uvm::UVM_CHECK, uvm::UVM_DEFAULT_PATH, seq); env->regmodel->Rb->F2->write(status, 0x2A, uvm::UVM_DEFAULT_PATH, NULL, seq); env->regmodel->mirror(status, uvm::UVM_CHECK, uvm::UVM_DEFAULT_PATH, seq); */ phase.drop_objection(this); } }; #endif // TB_TEST_H_
31.922222
83
0.656109
[ "model" ]
dfecd602964f7709f392cebc084f994adf238a6f
19,980
c
C
source/blender/python/mathutils/mathutils_Euler.c
wycivil08/blendocv
f6cce83e1f149fef39afa8043aade9c64378f33e
[ "Unlicense" ]
30
2015-01-29T14:06:05.000Z
2022-01-10T07:47:29.000Z
source/blender/python/mathutils/mathutils_Euler.c
ttagu99/blendocv
f6cce83e1f149fef39afa8043aade9c64378f33e
[ "Unlicense" ]
1
2017-02-20T20:57:48.000Z
2018-12-19T23:44:38.000Z
source/blender/python/mathutils/mathutils_Euler.c
ttagu99/blendocv
f6cce83e1f149fef39afa8043aade9c64378f33e
[ "Unlicense" ]
15
2015-04-23T02:38:36.000Z
2021-03-01T20:09:39.000Z
/* * $Id: mathutils_Euler.c 41078 2011-10-17 06:39:13Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. * * * Contributor(s): Joseph Gilbert * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/python/generic/mathutils_Euler.c * \ingroup pygen */ #include <Python.h> #include "mathutils.h" #include "BLI_math.h" #include "BLI_utildefines.h" #define EULER_SIZE 3 //----------------------------------mathutils.Euler() ------------------- //makes a new euler for you to play with static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *seq= NULL; const char *order_str= NULL; float eul[EULER_SIZE]= {0.0f, 0.0f, 0.0f}; short order= EULER_ORDER_XYZ; if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, "mathutils.Euler(): " "takes no keyword args"); return NULL; } if (!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str)) return NULL; switch(PyTuple_GET_SIZE(args)) { case 0: break; case 2: if ((order=euler_order_from_string(order_str, "mathutils.Euler()")) == -1) return NULL; /* intentionally pass through */ case 1: if (mathutils_array_parse(eul, EULER_SIZE, EULER_SIZE, seq, "mathutils.Euler()") == -1) return NULL; break; } return newEulerObject(eul, order, Py_NEW, type); } /* internal use, assume read callback is done */ static const char *euler_order_str(EulerObject *self) { static const char order[][4] = {"XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"}; return order[self->order-EULER_ORDER_XYZ]; } short euler_order_from_string(const char *str, const char *error_prefix) { if ((str[0] && str[1] && str[2] && str[3]=='\0')) { switch(*((PY_INT32_T *)str)) { case 'X'|'Y'<<8|'Z'<<16: return EULER_ORDER_XYZ; case 'X'|'Z'<<8|'Y'<<16: return EULER_ORDER_XZY; case 'Y'|'X'<<8|'Z'<<16: return EULER_ORDER_YXZ; case 'Y'|'Z'<<8|'X'<<16: return EULER_ORDER_YZX; case 'Z'|'X'<<8|'Y'<<16: return EULER_ORDER_ZXY; case 'Z'|'Y'<<8|'X'<<16: return EULER_ORDER_ZYX; } } PyErr_Format(PyExc_ValueError, "%s: invalid euler order '%s'", error_prefix, str); return -1; } /* note: BaseMath_ReadCallback must be called beforehand */ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits) { PyObject *ret; int i; ret= PyTuple_New(EULER_SIZE); if (ndigits >= 0) { for (i= 0; i < EULER_SIZE; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->eul[i], ndigits))); } } else { for (i= 0; i < EULER_SIZE; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->eul[i])); } } return ret; } //-----------------------------METHODS---------------------------- //return a quaternion representation of the euler PyDoc_STRVAR(Euler_to_quaternion_doc, ".. method:: to_quaternion()\n" "\n" " Return a quaternion representation of the euler.\n" "\n" " :return: Quaternion representation of the euler.\n" " :rtype: :class:`Quaternion`\n" ); static PyObject *Euler_to_quaternion(EulerObject * self) { float quat[4]; if (BaseMath_ReadCallback(self) == -1) return NULL; eulO_to_quat(quat, self->eul, self->order); return newQuaternionObject(quat, Py_NEW, NULL); } //return a matrix representation of the euler PyDoc_STRVAR(Euler_to_matrix_doc, ".. method:: to_matrix()\n" "\n" " Return a matrix representation of the euler.\n" "\n" " :return: A 3x3 roation matrix representation of the euler.\n" " :rtype: :class:`Matrix`\n" ); static PyObject *Euler_to_matrix(EulerObject * self) { float mat[9]; if (BaseMath_ReadCallback(self) == -1) return NULL; eulO_to_mat3((float (*)[3])mat, self->eul, self->order); return newMatrixObject(mat, 3, 3 , Py_NEW, NULL); } PyDoc_STRVAR(Euler_zero_doc, ".. method:: zero()\n" "\n" " Set all values to zero.\n" ); static PyObject *Euler_zero(EulerObject * self) { zero_v3(self->eul); if (BaseMath_WriteCallback(self) == -1) return NULL; Py_RETURN_NONE; } PyDoc_STRVAR(Euler_rotate_axis_doc, ".. method:: rotate_axis(axis, angle)\n" "\n" " Rotates the euler a certain amount and returning a unique euler rotation\n" " (no 720 degree pitches).\n" "\n" " :arg axis: single character in ['X, 'Y', 'Z'].\n" " :type axis: string\n" " :arg angle: angle in radians.\n" " :type angle: float\n" ); static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args) { float angle = 0.0f; int axis; /* actually a character */ if (!PyArg_ParseTuple(args, "Cf:rotate", &axis, &angle)) { PyErr_SetString(PyExc_TypeError, "Euler.rotate_axis(): " "expected an axis 'X', 'Y', 'Z' and an angle (float)"); return NULL; } if (!(ELEM3(axis, 'X', 'Y', 'Z'))) { PyErr_SetString(PyExc_ValueError, "Euler.rotate_axis(): " "expected axis to be 'X', 'Y' or 'Z'"); return NULL; } if (BaseMath_ReadCallback(self) == -1) return NULL; rotate_eulO(self->eul, self->order, (char)axis, angle); (void)BaseMath_WriteCallback(self); Py_RETURN_NONE; } PyDoc_STRVAR(Euler_rotate_doc, ".. method:: rotate(other)\n" "\n" " Rotates the euler a by another mathutils value.\n" "\n" " :arg other: rotation component of mathutils value\n" " :type other: :class:`Euler`, :class:`Quaternion` or :class:`Matrix`\n" ); static PyObject *Euler_rotate(EulerObject * self, PyObject *value) { float self_rmat[3][3], other_rmat[3][3], rmat[3][3]; if (BaseMath_ReadCallback(self) == -1) return NULL; if (mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1) return NULL; eulO_to_mat3(self_rmat, self->eul, self->order); mul_m3_m3m3(rmat, self_rmat, other_rmat); mat3_to_compatible_eulO(self->eul, self->eul, self->order, rmat); (void)BaseMath_WriteCallback(self); Py_RETURN_NONE; } PyDoc_STRVAR(Euler_make_compatible_doc, ".. method:: make_compatible(other)\n" "\n" " Make this euler compatible with another,\n" " so interpolating between them works as intended.\n" "\n" " .. note:: the rotation order is not taken into account for this function.\n" ); static PyObject *Euler_make_compatible(EulerObject * self, PyObject *value) { float teul[EULER_SIZE]; if (BaseMath_ReadCallback(self) == -1) return NULL; if (mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1) return NULL; compatible_eul(self->eul, teul); (void)BaseMath_WriteCallback(self); Py_RETURN_NONE; } //----------------------------Euler.rotate()----------------------- // return a copy of the euler PyDoc_STRVAR(Euler_copy_doc, ".. function:: copy()\n" "\n" " Returns a copy of this euler.\n" "\n" " :return: A copy of the euler.\n" " :rtype: :class:`Euler`\n" "\n" " .. note:: use this to get a copy of a wrapped euler with\n" " no reference to the original data.\n" ); static PyObject *Euler_copy(EulerObject *self) { if (BaseMath_ReadCallback(self) == -1) return NULL; return newEulerObject(self->eul, self->order, Py_NEW, Py_TYPE(self)); } //----------------------------print object (internal)-------------- //print the object to screen static PyObject *Euler_repr(EulerObject * self) { PyObject *ret, *tuple; if (BaseMath_ReadCallback(self) == -1) return NULL; tuple= Euler_ToTupleExt(self, -1); ret= PyUnicode_FromFormat("Euler(%R, '%s')", tuple, euler_order_str(self)); Py_DECREF(tuple); return ret; } static PyObject* Euler_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; int ok= -1; /* zero is true */ if (EulerObject_Check(a) && EulerObject_Check(b)) { EulerObject *eulA= (EulerObject*)a; EulerObject *eulB= (EulerObject*)b; if (BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1) return NULL; ok= ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1; } switch (op) { case Py_NE: ok = !ok; /* pass through */ case Py_EQ: res = ok ? Py_False : Py_True; break; case Py_LT: case Py_LE: case Py_GT: case Py_GE: res = Py_NotImplemented; break; default: PyErr_BadArgument(); return NULL; } return Py_INCREF(res), res; } //---------------------SEQUENCE PROTOCOLS------------------------ //----------------------------len(object)------------------------ //sequence length static int Euler_len(EulerObject *UNUSED(self)) { return EULER_SIZE; } //----------------------------object[]--------------------------- //sequence accessor (get) static PyObject *Euler_item(EulerObject * self, int i) { if (i<0) i= EULER_SIZE-i; if (i < 0 || i >= EULER_SIZE) { PyErr_SetString(PyExc_IndexError, "euler[attribute]: " "array index out of range"); return NULL; } if (BaseMath_ReadIndexCallback(self, i) == -1) return NULL; return PyFloat_FromDouble(self->eul[i]); } //----------------------------object[]------------------------- //sequence accessor (set) static int Euler_ass_item(EulerObject * self, int i, PyObject *value) { float f = PyFloat_AsDouble(value); if (f == -1 && PyErr_Occurred()) { // parsed item not a number PyErr_SetString(PyExc_TypeError, "euler[attribute] = x: " "argument not a number"); return -1; } if (i<0) i= EULER_SIZE-i; if (i < 0 || i >= EULER_SIZE) { PyErr_SetString(PyExc_IndexError, "euler[attribute] = x: " "array assignment index out of range"); return -1; } self->eul[i] = f; if (BaseMath_WriteIndexCallback(self, i) == -1) return -1; return 0; } //----------------------------object[z:y]------------------------ //sequence slice (get) static PyObject *Euler_slice(EulerObject * self, int begin, int end) { PyObject *tuple; int count; if (BaseMath_ReadCallback(self) == -1) return NULL; CLAMP(begin, 0, EULER_SIZE); if (end<0) end= (EULER_SIZE + 1) + end; CLAMP(end, 0, EULER_SIZE); begin= MIN2(begin, end); tuple= PyTuple_New(end - begin); for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->eul[count])); } return tuple; } //----------------------------object[z:y]------------------------ //sequence slice (set) static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) { int i, size; float eul[EULER_SIZE]; if (BaseMath_ReadCallback(self) == -1) return -1; CLAMP(begin, 0, EULER_SIZE); if (end<0) end= (EULER_SIZE + 1) + end; CLAMP(end, 0, EULER_SIZE); begin = MIN2(begin, end); if ((size=mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1) return -1; if (size != (end - begin)) { PyErr_SetString(PyExc_ValueError, "euler[begin:end] = []: " "size mismatch in slice assignment"); return -1; } for (i= 0; i < EULER_SIZE; i++) self->eul[begin + i] = eul[i]; (void)BaseMath_WriteCallback(self); return 0; } static PyObject *Euler_subscript(EulerObject *self, PyObject *item) { if (PyIndex_Check(item)) { Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) return NULL; if (i < 0) i += EULER_SIZE; return Euler_item(self, i); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((void *)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) return NULL; if (slicelength <= 0) { return PyTuple_New(0); } else if (step == 1) { return Euler_slice(self, start, stop); } else { PyErr_SetString(PyExc_IndexError, "slice steps not supported with eulers"); return NULL; } } else { PyErr_Format(PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name); return NULL; } } static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *value) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) return -1; if (i < 0) i += EULER_SIZE; return Euler_ass_item(self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((void *)item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) return -1; if (step == 1) return Euler_ass_slice(self, start, stop, value); else { PyErr_SetString(PyExc_IndexError, "slice steps not supported with euler"); return -1; } } else { PyErr_Format(PyExc_TypeError, "euler indices must be integers, not %.200s", Py_TYPE(item)->tp_name); return -1; } } //-----------------PROTCOL DECLARATIONS-------------------------- static PySequenceMethods Euler_SeqMethods = { (lenfunc) Euler_len, /* sq_length */ (binaryfunc) NULL, /* sq_concat */ (ssizeargfunc) NULL, /* sq_repeat */ (ssizeargfunc) Euler_item, /* sq_item */ (ssizessizeargfunc) NULL, /* sq_slice, deprecated */ (ssizeobjargproc) Euler_ass_item, /* sq_ass_item */ (ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */ (objobjproc) NULL, /* sq_contains */ (binaryfunc) NULL, /* sq_inplace_concat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; static PyMappingMethods Euler_AsMapping = { (lenfunc)Euler_len, (binaryfunc)Euler_subscript, (objobjargproc)Euler_ass_subscript }; /* * euler axis, euler.x/y/z */ static PyObject *Euler_getAxis(EulerObject *self, void *type) { return Euler_item(self, GET_INT_FROM_POINTER(type)); } static int Euler_setAxis(EulerObject *self, PyObject *value, void *type) { return Euler_ass_item(self, GET_INT_FROM_POINTER(type), value); } /* rotation order */ static PyObject *Euler_getOrder(EulerObject *self, void *UNUSED(closure)) { if (BaseMath_ReadCallback(self) == -1) /* can read order too */ return NULL; return PyUnicode_FromString(euler_order_str(self)); } static int Euler_setOrder(EulerObject *self, PyObject *value, void *UNUSED(closure)) { const char *order_str= _PyUnicode_AsString(value); short order= euler_order_from_string(order_str, "euler.order"); if (order == -1) return -1; self->order= order; (void)BaseMath_WriteCallback(self); /* order can be written back */ return 0; } /*****************************************************************************/ /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef Euler_getseters[] = { {(char *)"x", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler X axis in radians.\n\n:type: float", (void *)0}, {(char *)"y", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler Y axis in radians.\n\n:type: float", (void *)1}, {(char *)"z", (getter)Euler_getAxis, (setter)Euler_setAxis, (char *)"Euler Z axis in radians.\n\n:type: float", (void *)2}, {(char *)"order", (getter)Euler_getOrder, (setter)Euler_setOrder, (char *)"Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']", (void *)NULL}, {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; //-----------------------METHOD DEFINITIONS ---------------------- static struct PyMethodDef Euler_methods[] = { {"zero", (PyCFunction) Euler_zero, METH_NOARGS, Euler_zero_doc}, {"to_matrix", (PyCFunction) Euler_to_matrix, METH_NOARGS, Euler_to_matrix_doc}, {"to_quaternion", (PyCFunction) Euler_to_quaternion, METH_NOARGS, Euler_to_quaternion_doc}, {"rotate_axis", (PyCFunction) Euler_rotate_axis, METH_VARARGS, Euler_rotate_axis_doc}, {"rotate", (PyCFunction) Euler_rotate, METH_O, Euler_rotate_doc}, {"make_compatible", (PyCFunction) Euler_make_compatible, METH_O, Euler_make_compatible_doc}, {"__copy__", (PyCFunction) Euler_copy, METH_NOARGS, Euler_copy_doc}, {"copy", (PyCFunction) Euler_copy, METH_NOARGS, Euler_copy_doc}, {NULL, NULL, 0, NULL} }; //------------------PY_OBECT DEFINITION-------------------------- PyDoc_STRVAR(euler_doc, "This object gives access to Eulers in Blender." ); PyTypeObject euler_Type = { PyVarObject_HEAD_INIT(NULL, 0) "mathutils.Euler", //tp_name sizeof(EulerObject), //tp_basicsize 0, //tp_itemsize (destructor)BaseMathObject_dealloc, //tp_dealloc NULL, //tp_print NULL, //tp_getattr NULL, //tp_setattr NULL, //tp_compare (reprfunc) Euler_repr, //tp_repr NULL, //tp_as_number &Euler_SeqMethods, //tp_as_sequence &Euler_AsMapping, //tp_as_mapping NULL, //tp_hash NULL, //tp_call NULL, //tp_str NULL, //tp_getattro NULL, //tp_setattro NULL, //tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags euler_doc, //tp_doc (traverseproc)BaseMathObject_traverse, //tp_traverse (inquiry)BaseMathObject_clear, //tp_clear (richcmpfunc)Euler_richcmpr, //tp_richcompare 0, //tp_weaklistoffset NULL, //tp_iter NULL, //tp_iternext Euler_methods, //tp_methods NULL, //tp_members Euler_getseters, //tp_getset NULL, //tp_base NULL, //tp_dict NULL, //tp_descr_get NULL, //tp_descr_set 0, //tp_dictoffset NULL, //tp_init NULL, //tp_alloc Euler_new, //tp_new NULL, //tp_free NULL, //tp_is_gc NULL, //tp_bases NULL, //tp_mro NULL, //tp_cache NULL, //tp_subclasses NULL, //tp_weaklist NULL //tp_del }; //------------------------newEulerObject (internal)------------- //creates a new euler object /*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER (i.e. it was allocated elsewhere by MEM_mallocN()) pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON (i.e. it must be created here with PyMEM_malloc())*/ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_type) { EulerObject *self; self= base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) : (EulerObject *)PyObject_GC_New(EulerObject, &euler_Type); if (self) { /* init callbacks as NULL */ self->cb_user= NULL; self->cb_type= self->cb_subtype= 0; if (type == Py_WRAP) { self->eul = eul; self->wrapped = Py_WRAP; } else if (type == Py_NEW) { self->eul = PyMem_Malloc(EULER_SIZE * sizeof(float)); if (eul) { copy_v3_v3(self->eul, eul); } else { zero_v3(self->eul); } self->wrapped = Py_NEW; } else { Py_FatalError("Euler(): invalid type!"); } self->order= order; } return (PyObject *)self; } PyObject *newEulerObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype) { EulerObject *self= (EulerObject *)newEulerObject(NULL, order, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; self->cb_type= (unsigned char)cb_type; self->cb_subtype= (unsigned char)cb_subtype; PyObject_GC_Track(self); } return (PyObject *)self; }
27.596685
177
0.641141
[ "object", "vector" ]
dfede5267dc3f2c6873adaa7997c0cfb88ad504e
2,726
h
C
src/base58.h
tradecraftio/tradecraft
a014fea4d4656df67aef19e379f10322386cf6f8
[ "MIT" ]
10
2019-03-08T04:10:37.000Z
2021-08-20T11:55:14.000Z
src/base58.h
tradecraftio/tradecraft
a014fea4d4656df67aef19e379f10322386cf6f8
[ "MIT" ]
69
2018-11-09T20:29:29.000Z
2021-10-05T00:08:36.000Z
src/base58.h
tradecraftio/tradecraft
a014fea4d4656df67aef19e379f10322386cf6f8
[ "MIT" ]
7
2019-01-21T06:00:18.000Z
2021-12-19T16:18:00.000Z
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2018 The Bitcoin Core developers // Copyright (c) 2011-2021 The Freicoin Developers // // This program is free software: you can redistribute it and/or modify it under // the terms of version 3 of the GNU Affero General Public License as published // by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more // details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. /** * Why base-58 instead of standard base-64 encoding? * - Don't want 0OIl characters that look the same in some fonts and * could be used to create visually identical looking data. * - A string with non-alphanumeric characters is not as easily accepted as input. * - E-mail usually won't line-break if there's no punctuation to break at. * - Double-clicking selects the whole string as one word if it's all alphanumeric. */ #ifndef FREICOIN_BASE58_H #define FREICOIN_BASE58_H #include <attributes.h> #include <string> #include <vector> /** * Encode a byte sequence as a base58-encoded string. * pbegin and pend cannot be nullptr, unless both are. */ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend); /** * Encode a byte vector as a base58-encoded string */ std::string EncodeBase58(const std::vector<unsigned char>& vch); /** * Decode a base58-encoded string (psz) into a byte vector (vchRet). * return true if decoding is successful. * psz cannot be nullptr. */ NODISCARD bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet); /** * Decode a base58-encoded string (str) into a byte vector (vchRet). * return true if decoding is successful. */ NODISCARD bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet); /** * Encode a byte vector into a base58-encoded string, including checksum */ std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn); /** * Decode a base58-encoded string (psz) that includes a checksum into a byte * vector (vchRet), return true if decoding is successful */ NODISCARD bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet); /** * Decode a base58-encoded string (str) that includes a checksum into a byte * vector (vchRet), return true if decoding is successful */ NODISCARD bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet); #endif // FREICOIN_BASE58_H
36.346667
93
0.741746
[ "vector" ]
5f069fe14a7094c1fc16ed48b6708013898d5193
1,161
h
C
iOSOpenDev/frameworks/iWorkImport.framework/Headers/GQDTTable.h
bzxy/cydia
f8c838cdbd86e49dddf15792e7aa56e2af80548d
[ "MIT" ]
678
2017-11-17T08:33:19.000Z
2022-03-26T10:40:20.000Z
iOSOpenDev/frameworks/iWorkImport.framework/Headers/GQDTTable.h
chenfanfang/Cydia
5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0
[ "MIT" ]
22
2019-04-16T05:51:53.000Z
2021-11-08T06:18:45.000Z
iOSOpenDev/frameworks/iWorkImport.framework/Headers/GQDTTable.h
chenfanfang/Cydia
5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0
[ "MIT" ]
170
2018-06-10T07:59:20.000Z
2022-03-22T16:19:33.000Z
/** * This header is generated by class-dump-z 0.2b. * * Source: /System/Library/PrivateFrameworks/iWorkImport.framework/iWorkImport */ #import <iWorkImport/GQDGraphic.h> #import <iWorkImport/GQDNameMappable.h> #import <iWorkImport/iWorkImport-Structs.h> @class GQDTTableModel, GQDSStyle; __attribute__((visibility("hidden"))) @interface GQDTTable : GQDGraphic <GQDNameMappable> { @private GQDTTableModel *mModel; // 40 = 0x28 GQDSStyle *mStyle; // 44 = 0x2c BOOL mIsStreamed; // 48 = 0x30 } @property(retain) id model; // G=0x1be7d; S=0x1bead; converted property @property(retain) id tableStyle; // G=0x1be8d; S=0x1beed; converted property + (const StateSpec *)stateForReading; // 0x1be71 - (void)dealloc; // 0x1c179 // converted property getter: - (id)model; // 0x1be7d // converted property setter: - (void)setModel:(id)model; // 0x1bead // converted property getter: - (id)tableStyle; // 0x1be8d // converted property setter: - (void)setTableStyle:(id)style; // 0x1beed - (BOOL)isStreamed; // 0x1be9d - (id)defaultVectorStyleForVectorType:(int)vectorType; // 0x1bf2d - (int)walkTableWithGenerator:(Class)generator state:(id)state; // 0x1c071 @end
36.28125
78
0.739879
[ "model" ]
5f0d56f4803eb3431fa6d99163c872ea1196ab1c
2,311
h
C
framework/scene_graph/components/material.h
ohmaya/vulkan_best_practice_for_mobile_developers
356cf5229687346adcde2ca08875aa77a8bf530a
[ "MIT" ]
null
null
null
framework/scene_graph/components/material.h
ohmaya/vulkan_best_practice_for_mobile_developers
356cf5229687346adcde2ca08875aa77a8bf530a
[ "MIT" ]
null
null
null
framework/scene_graph/components/material.h
ohmaya/vulkan_best_practice_for_mobile_developers
356cf5229687346adcde2ca08875aa77a8bf530a
[ "MIT" ]
null
null
null
/* Copyright (c) 2018-2019, Arm Limited and Contributors * * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, * to any person obtaining a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include <memory> #include <string> #include <typeinfo> #include <unordered_map> #include <vector> #include "common/error.h" VKBP_DISABLE_WARNINGS() #include <glm/glm.hpp> VKBP_ENABLE_WARNINGS() #include "scene_graph/component.h" namespace vkb { namespace sg { class Texture; /** * @brief How the alpha value of the main factor and texture should be interpreted */ enum class AlphaMode { /// Alpha value is ignored Opaque, /// Either full opaque or fully transparent Mask, /// Output is combined with the background Blend }; class Material : public Component { public: Material(const std::string &name); Material(Material &&other) = default; virtual ~Material() = default; virtual std::type_index get_type() override; std::unordered_map<std::string, Texture *> textures; /// Emissive color of the material glm::vec3 emissive{0.0f, 0.0f, 0.0f}; /// Whether the material is double sided bool double_sided{false}; /// Cutoff threshold when in Mask mode float alpha_cutoff{0.5f}; /// Alpha rendering mode AlphaMode alpha_mode{AlphaMode::Opaque}; }; } // namespace sg } // namespace vkb
27.511905
129
0.740805
[ "vector" ]
7012dd0661562302c6b6f5ce3a109fd14cdf8ae6
1,147
h
C
chromeos/ime/input_method_config.h
nagineni/chromium-crosswalk
5725642f1c67d0f97e8613ec1c3e8107ab53fdf8
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
9
2018-09-21T05:36:12.000Z
2021-11-15T15:14:36.000Z
chromeos/ime/input_method_config.h
nagineni/chromium-crosswalk
5725642f1c67d0f97e8613ec1c3e8107ab53fdf8
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2021-12-13T19:44:12.000Z
2021-12-13T19:44:12.000Z
chromeos/ime/input_method_config.h
nagineni/chromium-crosswalk
5725642f1c67d0f97e8613ec1c3e8107ab53fdf8
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
4
2017-04-05T01:52:03.000Z
2022-02-13T17:58:45.000Z
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROMEOS_IME_INPUT_METHOD_CONFIG_H_ #define CHROMEOS_IME_INPUT_METHOD_CONFIG_H_ #include <string> #include <vector> #include "chromeos/chromeos_export.h" namespace chromeos { namespace input_method { // A structure which represents a value of an input method configuration item. // This struct is used by SetInputMethodConfig(). struct CHROMEOS_EXPORT InputMethodConfigValue { InputMethodConfigValue(); ~InputMethodConfigValue(); // Debug print function. std::string ToString() const; enum ValueType { kValueTypeString = 0, kValueTypeInt, kValueTypeBool, kValueTypeStringList, }; // A value is stored on |string_value| member if |type| is kValueTypeString. // The same is true for other enum values. ValueType type; std::string string_value; int int_value; bool bool_value; std::vector<std::string> string_list_value; }; } // namespace input_method } // namespace chromeos #endif // CHROMEOS_IME_INPUT_METHOD_CONFIG_H_
25.488889
78
0.757629
[ "vector" ]
70276ba53a1359a39d65ff61484d492a61b40aa9
2,043
h
C
src/CQIllustratorSizer.h
colinw7/CQIllustrator
4e730054353e62b111bbef38de5faf4e3eea7fbb
[ "MIT" ]
7
2016-04-24T23:15:34.000Z
2021-12-23T02:21:09.000Z
src/CQIllustratorSizer.h
colinw7/CQIllustrator
4e730054353e62b111bbef38de5faf4e3eea7fbb
[ "MIT" ]
1
2019-12-21T21:24:48.000Z
2019-12-22T00:32:25.000Z
src/CQIllustratorSizer.h
colinw7/CQIllustrator
4e730054353e62b111bbef38de5faf4e3eea7fbb
[ "MIT" ]
3
2019-04-01T13:19:42.000Z
2021-09-18T07:52:56.000Z
#ifndef CQIllustratorSizer_H #define CQIllustratorSizer_H #include <QPointF> #include <QTransform> #include <CBBox2D.h> class CQIllustrator; class CQIllustratorShape; class CQIllustratorHandle; class CQIllustratorShapeDrawer; class CQIllustratorSizer { public: enum HandleType { HANDLE_NONE = 0, HANDLE_L = (1<<0), HANDLE_B = (1<<1), HANDLE_R = (1<<2), HANDLE_T = (1<<3), HANDLE_RC = (1<<4), HANDLE_BL = (HANDLE_B | HANDLE_L), HANDLE_BR = (HANDLE_B | HANDLE_R), HANDLE_TL = (HANDLE_T | HANDLE_L), HANDLE_TR = (HANDLE_T | HANDLE_R) }; enum OpType { OP_RESIZE, OP_ROTATE }; public: CQIllustratorSizer(CQIllustrator *illustrator); HandleType getHandleType() const { return handle_; } HandleType getPressHandleType() const { return handle_; } void setPressHandleType () { press_handle_ = handle_; } void resetPressHandleType() { press_handle_ = HANDLE_NONE; } OpType getOpType() const { return op_; } bool mousePress (const QPointF &p); void mouseRelease(const QPointF &p); void updateShape(CQIllustratorShape *shape, const QPointF &oldPoint, const QPointF &newPoint, bool equal_scale=false); bool updateActive(const QPointF &p); void toggleOp(); void draw(CQIllustratorShapeDrawer *drawer, const CQIllustratorShape *shape); private: CQIllustrator *illustrator_; QTransform transform_; HandleType handle_; HandleType press_handle_; OpType op_; CQIllustratorHandle *bl_corner_handle_; CQIllustratorHandle *br_corner_handle_; CQIllustratorHandle *tl_corner_handle_; CQIllustratorHandle *tr_corner_handle_; CQIllustratorHandle *bl_rotate_handle_; CQIllustratorHandle *br_rotate_handle_; CQIllustratorHandle *tl_rotate_handle_; CQIllustratorHandle *tr_rotate_handle_; CQIllustratorHandle *l_side_handle_; CQIllustratorHandle *b_side_handle_; CQIllustratorHandle *r_side_handle_; CQIllustratorHandle *t_side_handle_; CQIllustratorHandle *rcenter_handle_; }; #endif
24.321429
79
0.734704
[ "shape" ]
702d2b0eaa48dfe5c7692147dd7f14f171999e48
25,724
c
C
libs/qmlglsink/gst-plugins-good/gst/rtp/gstrtpmparobustdepay.c
ant-nihil/routen-qgroundcontrol
0868aa1d6aba3f066dbaa55c53c943fc77eb8ff7
[ "Apache-2.0" ]
6
2020-09-22T18:07:15.000Z
2021-10-21T01:34:04.000Z
libs/qmlglsink/gst-plugins-good/gst/rtp/gstrtpmparobustdepay.c
ant-nihil/routen-qgroundcontrol
0868aa1d6aba3f066dbaa55c53c943fc77eb8ff7
[ "Apache-2.0" ]
2
2020-11-10T13:17:39.000Z
2022-03-30T11:22:14.000Z
libs/qmlglsink/gst-plugins-good/gst/rtp/gstrtpmparobustdepay.c
ant-nihil/routen-qgroundcontrol
0868aa1d6aba3f066dbaa55c53c943fc77eb8ff7
[ "Apache-2.0" ]
3
2020-09-26T08:40:35.000Z
2021-10-21T01:33:56.000Z
/* GStreamer * Copyright (C) <2010> Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> * Copyright (C) <2010> Nokia Corporation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <gst/rtp/gstrtpbuffer.h> #include <stdio.h> #include <string.h> #include "gstrtpmparobustdepay.h" GST_DEBUG_CATEGORY_STATIC (rtpmparobustdepay_debug); #define GST_CAT_DEFAULT (rtpmparobustdepay_debug) static GstStaticPadTemplate gst_rtp_mpa_robust_depay_src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/mpeg, " "mpegversion = (int) 1") ); static GstStaticPadTemplate gst_rtp_mpa_robust_depay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("application/x-rtp, " "media = (string) \"audio\", " "clock-rate = (int) 90000, " "encoding-name = (string) \"MPA-ROBUST\" " "; " /* draft versions appear still in use out there */ "application/x-rtp, " "media = (string) \"audio\", " "clock-rate = (int) [1, MAX], " "encoding-name = (string) { \"X-MP3-DRAFT-00\", \"X-MP3-DRAFT-01\", " " \"X-MP3-DRAFT-02\", \"X-MP3-DRAFT-03\", \"X-MP3-DRAFT-04\", " " \"X-MP3-DRAFT-05\", \"X-MP3-DRAFT-06\" }") ); typedef struct _GstADUFrame { guint32 header; gint size; gint side_info; gint data_size; gint layer; gint backpointer; GstBuffer *buffer; } GstADUFrame; #define gst_rtp_mpa_robust_depay_parent_class parent_class G_DEFINE_TYPE (GstRtpMPARobustDepay, gst_rtp_mpa_robust_depay, GST_TYPE_RTP_BASE_DEPAYLOAD); static GstStateChangeReturn gst_rtp_mpa_robust_change_state (GstElement * element, GstStateChange transition); static gboolean gst_rtp_mpa_robust_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps); static GstBuffer *gst_rtp_mpa_robust_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp); static void gst_rtp_mpa_robust_depay_finalize (GObject * object) { GstRtpMPARobustDepay *rtpmpadepay; rtpmpadepay = (GstRtpMPARobustDepay *) object; g_object_unref (rtpmpadepay->adapter); g_queue_free (rtpmpadepay->adu_frames); G_OBJECT_CLASS (parent_class)->finalize (object); } static void gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; GstRTPBaseDepayloadClass *gstrtpbasedepayload_class; GST_DEBUG_CATEGORY_INIT (rtpmparobustdepay_debug, "rtpmparobustdepay", 0, "Robust MPEG Audio RTP Depayloader"); gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass; gobject_class->finalize = gst_rtp_mpa_robust_depay_finalize; gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_mpa_robust_change_state); gst_element_class_add_static_pad_template (gstelement_class, &gst_rtp_mpa_robust_depay_src_template); gst_element_class_add_static_pad_template (gstelement_class, &gst_rtp_mpa_robust_depay_sink_template); gst_element_class_set_static_metadata (gstelement_class, "RTP MPEG audio depayloader", "Codec/Depayloader/Network/RTP", "Extracts MPEG audio from RTP packets (RFC 5219)", "Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>"); gstrtpbasedepayload_class->set_caps = gst_rtp_mpa_robust_depay_setcaps; gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_mpa_robust_depay_process; } static void gst_rtp_mpa_robust_depay_init (GstRtpMPARobustDepay * rtpmpadepay) { rtpmpadepay->adapter = gst_adapter_new (); rtpmpadepay->adu_frames = g_queue_new (); } static gboolean gst_rtp_mpa_robust_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) { GstRtpMPARobustDepay *rtpmpadepay; GstStructure *structure; GstCaps *outcaps; gint clock_rate, draft; gboolean res; const gchar *encoding; rtpmpadepay = GST_RTP_MPA_ROBUST_DEPAY (depayload); structure = gst_caps_get_structure (caps, 0); if (!gst_structure_get_int (structure, "clock-rate", &clock_rate)) clock_rate = 90000; depayload->clock_rate = clock_rate; rtpmpadepay->has_descriptor = TRUE; if ((encoding = gst_structure_get_string (structure, "encoding-name"))) { if (sscanf (encoding, "X-MP3-DRAFT-%d", &draft) && (draft == 0)) rtpmpadepay->has_descriptor = FALSE; } outcaps = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1, NULL); res = gst_pad_set_caps (depayload->srcpad, outcaps); gst_caps_unref (outcaps); return res; } /* thanks again go to mp3parse ... */ static const guint mp3types_bitrates[2][3][16] = { { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,}, {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,}, {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,} }, { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,}, {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}, {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,} }, }; static const guint mp3types_freqs[3][3] = { {44100, 48000, 32000}, {22050, 24000, 16000}, {11025, 12000, 8000} }; static inline guint mp3_type_frame_length_from_header (GstElement * mp3parse, guint32 header, guint * put_version, guint * put_layer, guint * put_channels, guint * put_bitrate, guint * put_samplerate, guint * put_mode, guint * put_crc) { guint length; gulong mode, samplerate, bitrate, layer, channels, padding, crc; gulong version; gint lsf, mpg25; if (header & (1 << 20)) { lsf = (header & (1 << 19)) ? 0 : 1; mpg25 = 0; } else { lsf = 1; mpg25 = 1; } version = 1 + lsf + mpg25; layer = 4 - ((header >> 17) & 0x3); crc = (header >> 16) & 0x1; bitrate = (header >> 12) & 0xF; bitrate = mp3types_bitrates[lsf][layer - 1][bitrate] * 1000; /* The caller has ensured we have a valid header, so bitrate can't be zero here. */ if (bitrate == 0) { GST_DEBUG_OBJECT (mp3parse, "invalid bitrate"); return 0; } samplerate = (header >> 10) & 0x3; samplerate = mp3types_freqs[lsf + mpg25][samplerate]; padding = (header >> 9) & 0x1; mode = (header >> 6) & 0x3; channels = (mode == 3) ? 1 : 2; switch (layer) { case 1: length = 4 * ((bitrate * 12) / samplerate + padding); break; case 2: length = (bitrate * 144) / samplerate + padding; break; default: case 3: length = (bitrate * 144) / (samplerate << lsf) + padding; break; } GST_LOG_OBJECT (mp3parse, "Calculated mp3 frame length of %u bytes", length); GST_LOG_OBJECT (mp3parse, "samplerate = %lu, bitrate = %lu, version = %lu, " "layer = %lu, channels = %lu, mode = %lu", samplerate, bitrate, version, layer, channels, mode); if (put_version) *put_version = version; if (put_layer) *put_layer = layer; if (put_channels) *put_channels = channels; if (put_bitrate) *put_bitrate = bitrate; if (put_samplerate) *put_samplerate = samplerate; if (put_mode) *put_mode = mode; if (put_crc) *put_crc = crc; GST_LOG_OBJECT (mp3parse, "size = %u", length); return length; } /* generate empty/silent/dummy frame that mimics @frame, * except for rate, where maximum possible is selected */ static GstADUFrame * gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay * rtpmpadepay, GstADUFrame * frame) { GstADUFrame *dummy; GstMapInfo map; dummy = g_slice_dup (GstADUFrame, frame); /* go for maximum bitrate */ dummy->header = (frame->header & ~(0xf << 12)) | (0xe << 12); dummy->size = mp3_type_frame_length_from_header (GST_ELEMENT_CAST (rtpmpadepay), dummy->header, NULL, NULL, NULL, NULL, NULL, NULL, NULL); dummy->data_size = dummy->size - 4 - dummy->side_info; dummy->backpointer = 0; dummy->buffer = gst_buffer_new_and_alloc (dummy->side_info + 4); gst_buffer_map (dummy->buffer, &map, GST_MAP_WRITE); memset (map.data, 0, map.size); GST_WRITE_UINT32_BE (map.data, dummy->header); gst_buffer_unmap (dummy->buffer, &map); GST_BUFFER_PTS (dummy->buffer) = GST_BUFFER_PTS (frame->buffer); return dummy; } /* validates and parses @buf, and queues for further transformation if valid, * otherwise discards @buf * Takes ownership of @buf. */ static gboolean gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay, GstBuffer * buf) { GstADUFrame *frame = NULL; guint version, layer, channels, size; guint crc; GstMapInfo map; g_return_val_if_fail (buf != NULL, FALSE); gst_buffer_map (buf, &map, GST_MAP_READ); if (map.size < 6) goto corrupt_frame; frame = g_slice_new0 (GstADUFrame); frame->header = GST_READ_UINT32_BE (map.data); size = mp3_type_frame_length_from_header (GST_ELEMENT_CAST (rtpmpadepay), frame->header, &version, &layer, &channels, NULL, NULL, NULL, &crc); if (!size) goto corrupt_frame; frame->size = size; frame->layer = layer; if (version == 1 && channels == 2) frame->side_info = 32; else if ((version == 1 && channels == 1) || (version >= 2 && channels == 2)) frame->side_info = 17; else if (version >= 2 && channels == 1) frame->side_info = 9; else { g_assert_not_reached (); goto corrupt_frame; } /* backpointer */ if (layer == 3) { frame->backpointer = GST_READ_UINT16_BE (map.data + 4); frame->backpointer >>= 7; GST_LOG_OBJECT (rtpmpadepay, "backpointer: %d", frame->backpointer); } if (!crc) frame->side_info += 2; GST_LOG_OBJECT (rtpmpadepay, "side info: %d", frame->side_info); frame->data_size = frame->size - 4 - frame->side_info; /* some size validation checks */ if (4 + frame->side_info > map.size) goto corrupt_frame; /* ADU data would then extend past MP3 frame, * even using past byte reservoir */ if (-frame->backpointer + (gint) (map.size) > frame->size) goto corrupt_frame; gst_buffer_unmap (buf, &map); /* ok, take buffer and queue */ frame->buffer = buf; g_queue_push_tail (rtpmpadepay->adu_frames, frame); return TRUE; /* ERRORS */ corrupt_frame: { GST_DEBUG_OBJECT (rtpmpadepay, "frame is corrupt"); gst_buffer_unmap (buf, &map); gst_buffer_unref (buf); if (frame) g_slice_free (GstADUFrame, frame); return FALSE; } } static inline void gst_rtp_mpa_robust_depay_free_frame (GstADUFrame * frame) { if (frame->buffer) gst_buffer_unref (frame->buffer); g_slice_free (GstADUFrame, frame); } static inline void gst_rtp_mpa_robust_depay_dequeue_frame (GstRtpMPARobustDepay * rtpmpadepay) { GstADUFrame *head; GST_LOG_OBJECT (rtpmpadepay, "dequeueing ADU frame"); if (rtpmpadepay->adu_frames->head == rtpmpadepay->cur_adu_frame) rtpmpadepay->cur_adu_frame = NULL; head = g_queue_pop_head (rtpmpadepay->adu_frames); g_assert (head->buffer); gst_rtp_mpa_robust_depay_free_frame (head); return; } /* returns TRUE if at least one new ADU frame was enqueued for MP3 conversion. * Takes ownership of @buf. */ static gboolean gst_rtp_mpa_robust_depay_deinterleave (GstRtpMPARobustDepay * rtpmpadepay, GstBuffer * buf) { gboolean ret = FALSE; GstMapInfo map; guint val, iindex, icc; gst_buffer_map (buf, &map, GST_MAP_READ); val = GST_READ_UINT16_BE (map.data) >> 5; gst_buffer_unmap (buf, &map); iindex = val >> 3; icc = val & 0x7; GST_LOG_OBJECT (rtpmpadepay, "sync: 0x%x, index: %u, cycle count: %u", val, iindex, icc); /* basic case; no interleaving ever seen */ if (val == 0x7ff && rtpmpadepay->last_icc < 0) { ret = gst_rtp_mpa_robust_depay_queue_frame (rtpmpadepay, buf); } else { if (G_UNLIKELY (rtpmpadepay->last_icc < 0)) { rtpmpadepay->last_icc = icc; rtpmpadepay->last_ii = iindex; } if (icc != rtpmpadepay->last_icc || iindex == rtpmpadepay->last_ii) { gint i; for (i = 0; i < 256; ++i) { if (rtpmpadepay->deinter[i] != NULL) { ret |= gst_rtp_mpa_robust_depay_queue_frame (rtpmpadepay, rtpmpadepay->deinter[i]); rtpmpadepay->deinter[i] = NULL; } } } /* rewrite buffer sync header */ gst_buffer_map (buf, &map, GST_MAP_READWRITE); val = GST_READ_UINT16_BE (map.data); val = (0x7ff << 5) | val; GST_WRITE_UINT16_BE (map.data, val); gst_buffer_unmap (buf, &map); /* store and keep track of last indices */ rtpmpadepay->last_icc = icc; rtpmpadepay->last_ii = iindex; rtpmpadepay->deinter[iindex] = buf; } return ret; } /* Head ADU frame corresponds to mp3_frame (i.e. in header in side-info) that * is currently being written * cur_adu_frame refers to ADU frame whose data should be bytewritten next * (possibly starting from offset rather than start 0) (and is typicall tail * at time of last push round). * If at start, position where it should start writing depends on (data) sizes * of previous mp3 frames (corresponding to foregoing ADU frames) kept in size, * and its backpointer */ static GstFlowReturn gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay) { GstBuffer *buf; GstADUFrame *frame, *head; gint av; GstFlowReturn ret = GST_FLOW_OK; while (1) { GstMapInfo map; if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) { rtpmpadepay->cur_adu_frame = rtpmpadepay->adu_frames->head; rtpmpadepay->offset = 0; rtpmpadepay->size = 0; } if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) break; frame = (GstADUFrame *) rtpmpadepay->cur_adu_frame->data; head = (GstADUFrame *) rtpmpadepay->adu_frames->head->data; /* special case: non-layer III are sent straight through */ if (G_UNLIKELY (frame->layer != 3)) { GST_DEBUG_OBJECT (rtpmpadepay, "layer %d frame, sending as-is", frame->layer); gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmpadepay), frame->buffer); frame->buffer = NULL; /* and remove it from any further consideration */ g_slice_free (GstADUFrame, frame); g_queue_delete_link (rtpmpadepay->adu_frames, rtpmpadepay->cur_adu_frame); rtpmpadepay->cur_adu_frame = NULL; continue; } if (rtpmpadepay->offset == gst_buffer_get_size (frame->buffer)) { if (g_list_next (rtpmpadepay->cur_adu_frame)) { rtpmpadepay->size += frame->data_size; rtpmpadepay->cur_adu_frame = g_list_next (rtpmpadepay->cur_adu_frame); frame = (GstADUFrame *) rtpmpadepay->cur_adu_frame->data; rtpmpadepay->offset = 0; GST_LOG_OBJECT (rtpmpadepay, "moving to next ADU frame, size %d, side_info %d, backpointer %d", frame->size, frame->side_info, frame->backpointer); /* layer I and II packets have no bitreservoir and must be sent as-is; * so flush any pending frame */ if (G_UNLIKELY (frame->layer != 3 && rtpmpadepay->mp3_frame)) goto flush; } else { break; } } if (G_UNLIKELY (!rtpmpadepay->mp3_frame)) { GST_LOG_OBJECT (rtpmpadepay, "setting up new MP3 frame of size %d, side_info %d", head->size, head->side_info); rtpmpadepay->mp3_frame = gst_byte_writer_new_with_size (head->size, TRUE); /* 0-fill possible gaps */ gst_byte_writer_fill_unchecked (rtpmpadepay->mp3_frame, 0, head->size); gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, 0); /* bytewriter corresponds to head frame, * i.e. the header and the side info must match */ g_assert (4 + head->side_info <= head->size); gst_buffer_map (head->buffer, &map, GST_MAP_READ); gst_byte_writer_put_data_unchecked (rtpmpadepay->mp3_frame, map.data, 4 + head->side_info); gst_buffer_unmap (head->buffer, &map); } buf = frame->buffer; av = gst_byte_writer_get_remaining (rtpmpadepay->mp3_frame); GST_LOG_OBJECT (rtpmpadepay, "current mp3 frame remaining: %d", av); GST_LOG_OBJECT (rtpmpadepay, "accumulated ADU frame data_size: %d", rtpmpadepay->size); if (rtpmpadepay->offset) { gst_buffer_map (buf, &map, GST_MAP_READ); /* no need to position, simply append */ g_assert (map.size > rtpmpadepay->offset); av = MIN (av, map.size - rtpmpadepay->offset); GST_LOG_OBJECT (rtpmpadepay, "appending %d bytes from ADU frame at offset %d", av, rtpmpadepay->offset); gst_byte_writer_put_data_unchecked (rtpmpadepay->mp3_frame, map.data + rtpmpadepay->offset, av); rtpmpadepay->offset += av; gst_buffer_unmap (buf, &map); } else { gint pos, tpos; /* position writing according to ADU frame backpointer */ pos = gst_byte_writer_get_pos (rtpmpadepay->mp3_frame); tpos = rtpmpadepay->size - frame->backpointer + 4 + head->side_info; GST_LOG_OBJECT (rtpmpadepay, "current MP3 frame at position %d, " "starting new ADU frame data at offset %d", pos, tpos); if (tpos < pos) { GstADUFrame *dummy; /* try to insert as few frames as possible, * so go for a reasonably large dummy frame size */ GST_LOG_OBJECT (rtpmpadepay, "overlapping previous data; inserting dummy frame"); dummy = gst_rtp_mpa_robust_depay_generate_dummy_frame (rtpmpadepay, frame); g_queue_insert_before (rtpmpadepay->adu_frames, rtpmpadepay->cur_adu_frame, dummy); /* offset is known to be zero, so we can shift current one */ rtpmpadepay->cur_adu_frame = rtpmpadepay->cur_adu_frame->prev; if (!rtpmpadepay->size) { g_assert (rtpmpadepay->cur_adu_frame == rtpmpadepay->adu_frames->head); GST_LOG_OBJECT (rtpmpadepay, "... which is new head frame"); gst_byte_writer_free (rtpmpadepay->mp3_frame); rtpmpadepay->mp3_frame = NULL; } /* ... and continue adding that empty one immediately, * and then see if that provided enough extra space */ continue; } else if (tpos >= pos + av) { /* ADU frame no longer needs current MP3 frame; move to its end */ GST_LOG_OBJECT (rtpmpadepay, "passed current MP3 frame"); gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, pos + av); } else { /* position and append */ gst_buffer_map (buf, &map, GST_MAP_READ); GST_LOG_OBJECT (rtpmpadepay, "adding to current MP3 frame"); gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, tpos); av -= (tpos - pos); g_assert (map.size >= 4 + frame->side_info); av = MIN (av, map.size - 4 - frame->side_info); gst_byte_writer_put_data_unchecked (rtpmpadepay->mp3_frame, map.data + 4 + frame->side_info, av); rtpmpadepay->offset += av + 4 + frame->side_info; gst_buffer_unmap (buf, &map); } } /* if mp3 frame filled, send on its way */ if (gst_byte_writer_get_remaining (rtpmpadepay->mp3_frame) == 0) { flush: buf = gst_byte_writer_free_and_get_buffer (rtpmpadepay->mp3_frame); rtpmpadepay->mp3_frame = NULL; GST_BUFFER_PTS (buf) = GST_BUFFER_PTS (head->buffer); /* no longer need head ADU frame header and side info */ /* NOTE maybe head == current, then size and offset go off a bit, * but current gets reset to NULL, and then also offset and size */ rtpmpadepay->size -= head->data_size; gst_rtp_mpa_robust_depay_dequeue_frame (rtpmpadepay); /* send */ ret = gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmpadepay), buf); } } return ret; } /* process ADU frame @buf through: * - deinterleaving * - converting to MP3 frames * Takes ownership of @buf. */ static GstFlowReturn gst_rtp_mpa_robust_depay_submit_adu (GstRtpMPARobustDepay * rtpmpadepay, GstBuffer * buf) { if (gst_rtp_mpa_robust_depay_deinterleave (rtpmpadepay, buf)) return gst_rtp_mpa_robust_depay_push_mp3_frames (rtpmpadepay); return GST_FLOW_OK; } static GstBuffer * gst_rtp_mpa_robust_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) { GstRtpMPARobustDepay *rtpmpadepay; gint payload_len, offset; guint8 *payload; gboolean cont, dtype; guint av, size; GstClockTime timestamp; GstBuffer *buf; rtpmpadepay = GST_RTP_MPA_ROBUST_DEPAY (depayload); timestamp = GST_BUFFER_PTS (rtp->buffer); payload_len = gst_rtp_buffer_get_payload_len (rtp); if (payload_len <= 1) goto short_read; payload = gst_rtp_buffer_get_payload (rtp); offset = 0; GST_LOG_OBJECT (rtpmpadepay, "payload_len: %d", payload_len); /* strip off descriptor * * 0 1 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |C|T| ADU size | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * * C: if 1, data is continuation * T: if 1, size is 14 bits, otherwise 6 bits * ADU size: size of following packet (not including descriptor) */ while (payload_len) { if (G_LIKELY (rtpmpadepay->has_descriptor)) { cont = ! !(payload[offset] & 0x80); dtype = ! !(payload[offset] & 0x40); if (dtype) { size = (payload[offset] & 0x3f) << 8 | payload[offset + 1]; payload_len--; offset++; } else if (payload_len >= 2) { size = (payload[offset] & 0x3f); payload_len -= 2; offset += 2; } else { goto short_read; } } else { cont = FALSE; dtype = -1; size = payload_len; } GST_LOG_OBJECT (rtpmpadepay, "offset %d has cont: %d, dtype: %d, size: %d", offset, cont, dtype, size); buf = gst_rtp_buffer_get_payload_subbuffer (rtp, offset, MIN (size, payload_len)); if (cont) { av = gst_adapter_available (rtpmpadepay->adapter); if (G_UNLIKELY (!av)) { GST_DEBUG_OBJECT (rtpmpadepay, "discarding continuation fragment without prior fragment"); gst_buffer_unref (buf); } else { av += gst_buffer_get_size (buf); gst_adapter_push (rtpmpadepay->adapter, buf); if (av == size) { timestamp = gst_adapter_prev_pts (rtpmpadepay->adapter, NULL); buf = gst_adapter_take_buffer (rtpmpadepay->adapter, size); GST_BUFFER_PTS (buf) = timestamp; gst_rtp_mpa_robust_depay_submit_adu (rtpmpadepay, buf); } else if (av > size) { GST_DEBUG_OBJECT (rtpmpadepay, "assembled ADU size %d larger than expected %d; discarding", av, size); gst_adapter_clear (rtpmpadepay->adapter); } } size = payload_len; } else { /* not continuation, first fragment or whole ADU */ if (payload_len == size) { /* whole ADU */ GST_BUFFER_PTS (buf) = timestamp; gst_rtp_mpa_robust_depay_submit_adu (rtpmpadepay, buf); } else if (payload_len < size) { /* first fragment */ gst_adapter_push (rtpmpadepay->adapter, buf); size = payload_len; } } offset += size; payload_len -= size; /* timestamp applies to first payload, no idea for subsequent ones */ timestamp = GST_CLOCK_TIME_NONE; } return NULL; /* ERRORS */ short_read: { GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE, (NULL), ("Packet contains invalid data")); return NULL; } } static GstStateChangeReturn gst_rtp_mpa_robust_change_state (GstElement * element, GstStateChange transition) { GstStateChangeReturn ret; GstRtpMPARobustDepay *rtpmpadepay; rtpmpadepay = GST_RTP_MPA_ROBUST_DEPAY (element); switch (transition) { case GST_STATE_CHANGE_READY_TO_PAUSED: rtpmpadepay->last_ii = -1; rtpmpadepay->last_icc = -1; rtpmpadepay->size = 0; rtpmpadepay->offset = 0; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); if (ret != GST_STATE_CHANGE_SUCCESS) return ret; switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: { gint i; gst_adapter_clear (rtpmpadepay->adapter); for (i = 0; i < G_N_ELEMENTS (rtpmpadepay->deinter); i++) { gst_buffer_replace (&rtpmpadepay->deinter[i], NULL); } rtpmpadepay->cur_adu_frame = NULL; g_queue_foreach (rtpmpadepay->adu_frames, (GFunc) gst_rtp_mpa_robust_depay_free_frame, NULL); g_queue_clear (rtpmpadepay->adu_frames); if (rtpmpadepay->mp3_frame) gst_byte_writer_free (rtpmpadepay->mp3_frame); break; } default: break; } return ret; } gboolean gst_rtp_mpa_robust_depay_plugin_init (GstPlugin * plugin) { return gst_element_register (plugin, "rtpmparobustdepay", GST_RANK_SECONDARY, GST_TYPE_RTP_MPA_ROBUST_DEPAY); }
31.679803
80
0.664205
[ "object" ]
703539ce81d7945b3be0b585921d81603127f7b9
1,711
h
C
src/MarkerDetection/Math/Quadrilateral.h
CircuitMess/Wheelson-Library
6317dab9c3d541f44bcec0657df4114807dfc84a
[ "MIT" ]
1
2021-08-05T14:23:49.000Z
2021-08-05T14:23:49.000Z
src/MarkerDetection/Math/Quadrilateral.h
CircuitMess/Wheelson-Library
6317dab9c3d541f44bcec0657df4114807dfc84a
[ "MIT" ]
null
null
null
src/MarkerDetection/Math/Quadrilateral.h
CircuitMess/Wheelson-Library
6317dab9c3d541f44bcec0657df4114807dfc84a
[ "MIT" ]
null
null
null
#ifndef TAGDETECTION_QUADRILATERAL_H #define TAGDETECTION_QUADRILATERAL_H #include <opencv2/core/types.hpp> #include <vector> /** * Used to represent and operate over quads. */ class Quadrilateral { public: /** * Vector of points that compose the quad. */ std::vector<cv::Point2f> points; /** * Quad constructor initializes 4 points. */ Quadrilateral(); /** * Quad contructor from a points. */ Quadrilateral(const cv::Point2f& a, const cv::Point2f& b, const cv::Point2f& c, const cv::Point2f& d); /** * Calculate Area of this quad. * * @return Area of this quad. */ float area() const; /** * Check if point is inside this quad. * * @param p Point to check. * @return true if point is inside this quad */ bool containsPoint(const cv::Point2f& p) const; /** * Draw quad lines to image. * * @param image Image where to draw line. * @param color Color of the lines to be drawn. * @param weight Weight of the lines. */ void draw(cv::Mat& image, const cv::Scalar& color, int weigth = 1) const; /** * Print quad info to cout. */ void print() const; /** * Get bigger square on a std::vector (caller have to check std::vector size). * * @param quad Vector of quads. * @return quad Bigger quad in the std::vector. */ Quadrilateral biggerQuadrilateral(const std::vector<Quadrilateral>& quads) const; /** * Draw all squares from std::vector to image. * * @param image Image where to draw. * @param quads Vector of quads to draw. * @param color Color used to draw the quads. */ void drawVector(cv::Mat& image, const std::vector<Quadrilateral>& quads, const cv::Scalar& color) const; }; #endif //TAGDETECTION_QUADRILATERAL_H
22.513158
105
0.671537
[ "vector" ]
703598bc3331b78b62046ff739555bfe6797c59c
567
h
C
include/face/personalized_blendshape.h
ycjungSubhuman/Kinect-Face
b582bd8572e998617b5a0d197b4ac9bd4a9b42be
[ "CNRI-Python" ]
7
2018-08-12T22:05:26.000Z
2021-05-14T08:39:32.000Z
include/face/personalized_blendshape.h
ycjungSubhuman/Kinect-Face
b582bd8572e998617b5a0d197b4ac9bd4a9b42be
[ "CNRI-Python" ]
null
null
null
include/face/personalized_blendshape.h
ycjungSubhuman/Kinect-Face
b582bd8572e998617b5a0d197b4ac9bd4a9b42be
[ "CNRI-Python" ]
2
2019-02-14T08:29:16.000Z
2019-03-01T07:11:17.000Z
#pragma once #include "face/mo" namespace telef::face { class PersonalizedBlendshape { public: PersonalizedBlendshape( Eigen::VectorXf neutral, Eigen::MatrixXf mean_exp_delta_matrix); ); /** * Neutral face vertex positions */ Eigen::VectorXf getNeutral() const; /** * Each column of this matrix is delta to each target shape * from neutral face */ Eigen::MatrixXf getDeltaMatrix() const; /** * Number of expression basis */ int getRank() const; private: Eigen::VectorXf m_neutral; Eigen::MatrixXf m_delta; }; }
16.2
61
0.677249
[ "shape" ]
7068e89421d640073e02d6df6636071f801710b6
5,963
h
C
include/module/WasmLinearMemory.h
tvanslyke/wasm-cpp
8a56c1706e2723ece36e3642bae9e36792dbd7b2
[ "MIT" ]
null
null
null
include/module/WasmLinearMemory.h
tvanslyke/wasm-cpp
8a56c1706e2723ece36e3642bae9e36792dbd7b2
[ "MIT" ]
null
null
null
include/module/WasmLinearMemory.h
tvanslyke/wasm-cpp
8a56c1706e2723ece36e3642bae9e36792dbd7b2
[ "MIT" ]
null
null
null
#ifndef MODULE_WASM_LINEAR_MEMORY_H #define MODULE_WASM_LINEAR_MEMORY_H #include <array> #include <vector> #include <algorithm> #include "wasm_base.h" #include "wasm_value.h" #include <stdexcept> #include <iostream> #include <cstring> #include <gsl/span> #include "utilities/endianness.h" namespace wasm { struct WasmLinearMemory { static constexpr const std::size_t page_size = 65536; using page_type = alignas(page_size) char[page_size]; private: using vector_type = wasm::SimpleVector<page_type>; public: using wasm_external_kind_type = parse::Memory; using page_iterator = page_type*; using const_page_iterator = const page_type*; using page_pointer = page_type*; using const_page_pointer = const page_type*; using page_reference = page_type&; using const_page_reference = const page_type&; using page_span = gsl::span<const page_type>; using const_page_span = gsl::span<const page_type>; using value_type = char; using iterator = value_type*; using const_iterator = const value_type*; using pointer = value_type*; using const_pointer = const value_type*; using reference = value_type&; using const_reference = const value_type&; using raw_span = gsl::span<const value_type>; using const_raw_span = gsl::span<const value_type>; using size_type = vector_type::size_type; using difference_type = vector_type::difference_type; WasmLinearMemory(const parse::Memory& def, const parse::DataSegment& seg); friend const_page_span pages(const WasmLinearMemory& self) { return const_page_span(self.memory_.data(), self.memory_.size()); } friend page_span pages(WasmLinearMemory& self) { return page_span(self.memory_.data(), self.memory_.size()); } friend const_raw_span data(const WasmLinearMemory& self) { return raw_span( static_cast<const_pointer>(self.vec_.data()), page_size * self.vec_.size() ); } friend raw_span data(WasmLinearMemory& self) { return raw_span( static_cast<pointer>(self.vec_.data()), page_size * self.vec_.size() ); } friend wasm_sint32_t grow_memory(WasmLinearMemory& self, wasm_uint32_t delta) { wasm_uint32_t prev = static_cast<wasm_uint32_t>(pages(self).size()); assert(prev == pages(self).size()); if(delta > 0u) { std::size_t new_size = self.vec_.size() + delta; if(new_size > maximum_) return -1; try { self.resize(self.vec_.size() + delta); } catch(std::bad_alloc& e) { return -1; } } return reinterpret_cast<const wasm_sint32_t&>(prev); } friend bool matches(const WasmLinearMemory& self, const parse::Memory& tp) { return self.memory_.size() >= tp.size() and ( self.maximum_ == tp.maximum.value_or(std::numeric_limits<std::size_t>::max()) ); } private: void resize(std::size_t n) { assert(n <= maximum_); using std::swap; vector_type tmp(n); swap(memory_, tmp); std::memcpy(v.data(), tmp.data(), tmp.size() * sizeof(tmp.front())); std::memset(v.data() + tmp.size(), 0, v.size() - tmp.size()); } vector_type memory_; const std::size_t maximum_ = std::numeric_limits<std::size_t>::max(); }; LanguageType index_type(const WasmLinearMemory& self) { return } WasmLinearMemory::size_type current_memory(const WasmLinearMemory& self) { return pages(self).size(); } WasmLinearMemory::size_type page_count(const WasmLinearMemory& self) { return current_memory(self); } WasmLinearMemory::size_type size(const WasmLinearMemory& self) { return data(self).size(); } WasmLinearMemory::WasmLinearMemory(const parse::Memory& def): memory_(def.initial), maximum_(def.maximum.value_or(std::numeric_limits<std::size_t>::max()) { auto bytes = data(*this); std::fill(bytes.begin(), bytes.end(), 0); } gsl::span<const char> compute_effective_address( const WasmLinearMemory& self, wasm_uint32_t base, wasm_uint32_t offset, std::size_t size ) { auto mem = data(self); if(mem.size() <= base) throw std::out_of_range("Base address is too large while computing linear memory effective address."); std::size_t effective_address = base; effective_address += offset; if(mem.size() <= effective_address) throw std::out_of_range("Computed effective address is too large for linear memory."); if(std::size_t remaining = mem.size() - effective_address; remaining < sizeof(Type)) throw std::out_of_range("Linear memory access partially acesses out-of-bounds memory."); return mem.subspan(effective_address, size); } gsl::span<char> compute_effective_address( WasmLinearMemory& self, wasm_uint32_t base, wasm_uint32_t offset, std::size_t size ) { auto addr = compute_effective_address(std::as_const(self), base, offset, size); const char* data = addr.data(); auto size = addr.data(); return gsl::span<char>(const_cast<char*>(data), size); } template <class Type> Type load_little_endian(const WasmLinearMemory& self, wasm_uint32_t base, wasm_uint32_t offset) { static_assert(std::is_trivially_copyable_v<Type>); static_assert(std::is_arithmetic_v<Type>); Type result; auto addr = compute_effective_address(self, base, offset, sizeof(Type)); assert(addr.size() == sizeof(result)); std::memcpy(&result, addr.data(), sizeof(result)); if(not system_is_little_endian()) { static_assert(std::is_same_v<decltype(byte_swap(value)), decltype(value)>); result = byte_swap(result); } return result; } template <class Type, class PassedType> void store_little_endian(const WasmLinearMemory& self, wasm_uint32_t base, wasm_uint32_t offset, PassedType value) { static_assert(std::is_trivially_copyable_v<Type>); static_assert(std::is_arithmetic_v<Type>); static_assert(std::is_same_v<Type, PassedType>); auto pos = compute_effective_address(self, base, offset, sizeof(Type)); assert(addr.size() == sizeof(value)); if(not system_is_little_endian()) { static_assert(std::is_same_v<decltype(byte_swap(value)), decltype(value)>); value = byte_swap(value); } std::memcpy(pos, &value, sizeof(value)); } } /* namespace wasm */ #endif /* MODULE_WASM_LINEAR_MEMORY_H */
28.806763
114
0.737548
[ "vector" ]
2474237b0c52c6bcee768bd1bd4a085da7f63dc4
3,526
h
C
headers/tools/cppunit/cppunit/CompilerOutputter.h
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
1,338
2015-01-03T20:06:56.000Z
2022-03-26T13:49:54.000Z
headers/tools/cppunit/cppunit/CompilerOutputter.h
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
15
2015-01-17T22:19:32.000Z
2021-12-20T12:35:00.000Z
headers/tools/cppunit/cppunit/CompilerOutputter.h
Kirishikesan/haiku
835565c55830f2dab01e6e332cc7e2d9c015b51e
[ "MIT" ]
350
2015-01-08T14:15:27.000Z
2022-03-21T18:14:35.000Z
#ifndef CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H #define CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H #include <cppunit/Portability.h> #include <cppunit/Outputter.h> #include <vector> #include <iostream> namespace CppUnit { class Exception; class SourceLine; class Test; class TestFailure; class TestResultCollector; /*! * \brief Outputs a TestResultCollector in a compiler compatible format. * \ingroup WritingTestResult * * Printing the test results in a compiler compatible format (assertion * location has the same format as compiler error), allow you to use your * IDE to jump to the assertion failure. * * For example, when running the test in a post-build with VC++, if an assertion * fails, you can jump to the assertion by pressing F4 (jump to next error). * * You should use defaultOutputter() to create an instance. * * Heres is an example of usage (from examples/cppunittest/CppUnitTestMain.cpp): * \code * int main( int argc, char* argv[] ) { * // if command line contains "-selftest" then this is the post build check * // => the output must be in the compiler error format. * bool selfTest = (argc > 1) && * (string("-selftest") == argv[1]); * * CppUnit::TextUi::TestRunner runner; * runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner * * if ( selfTest ) * { // Change the default outputter to a compiler error format outputter * // The test runner owns the new outputter. * runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( * &runner.result(), * cerr ) ); * } * * // Run the test and don't wait a key if post build check. * bool wasSucessful = runner.run( "", !selfTest ); * * // Return error code 1 if the one of test failed. * return wasSucessful ? 0 : 1; * } * \endcode */ class CPPUNIT_API CompilerOutputter : public Outputter { public: /*! Constructs a CompilerOutputter object. */ CompilerOutputter( TestResultCollector *result, std::ostream &stream ); /// Destructor. virtual ~CompilerOutputter(); /*! Creates an instance of an outputter that matches your current compiler. */ static CompilerOutputter *defaultOutputter( TestResultCollector *result, std::ostream &stream ); void write(); virtual void printSucess(); virtual void printFailureReport(); virtual void printFailuresList(); virtual void printStatistics(); virtual void printFailureDetail( TestFailure *failure ); virtual void printFailureLocation( SourceLine sourceLine ); virtual void printFailureType( TestFailure *failure ); virtual void printFailedTestName( TestFailure *failure ); virtual void printFailureMessage( TestFailure *failure ); virtual void printNotEqualMessage( Exception *thrownException ); virtual void printDefaultMessage( Exception *thrownException ); virtual std::string wrap( std::string message ); private: /// Prevents the use of the copy constructor. CompilerOutputter( const CompilerOutputter &copy ); /// Prevents the use of the copy operator. void operator =( const CompilerOutputter &copy ); typedef std::vector<std::string> Lines; static Lines splitMessageIntoLines( std::string message ); private: TestResultCollector *m_result; std::ostream &m_stream; }; } // namespace CppUnit #endif // CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H
32.054545
86
0.686897
[ "object", "vector" ]
24868bbc363e23dcd3ac8242f1644b063391e926
92,237
c
C
drv/mxfe/mxfe.c
gdamore/sol-enet
6b11bb76e94525b47516084be013897eb9d29100
[ "BSD-3-Clause" ]
null
null
null
drv/mxfe/mxfe.c
gdamore/sol-enet
6b11bb76e94525b47516084be013897eb9d29100
[ "BSD-3-Clause" ]
null
null
null
drv/mxfe/mxfe.c
gdamore/sol-enet
6b11bb76e94525b47516084be013897eb9d29100
[ "BSD-3-Clause" ]
null
null
null
/* * Solaris DLPI driver for ethernet cards based on the Macronix 98715 * * Copyright (c) 2001-2007 by Garrett D'Amore <garrett@damore.org>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ident "@(#)$Id: mxfe.c,v 1.10 2007/03/29 03:46:12 gdamore Exp $" #include <sys/varargs.h> #include <sys/types.h> #include <sys/modctl.h> #include <sys/conf.h> #include <sys/devops.h> #include <sys/stream.h> #include <sys/cmn_err.h> #include <sys/dlpi.h> #include <sys/ethernet.h> #include <sys/kmem.h> #include <sys/gld.h> #include <sys/ddi.h> #include <sys/sunddi.h> #include <sys/mii.h> #include <sys/mxfe.h> #include <sys/mxfeimpl.h> /* * Driver globals. */ /* patchable debug flag */ #ifdef DEBUG static unsigned mxfe_debug = MXFE_DWARN; #endif /* table of supported devices */ static mxfe_card_t mxfe_cards[] = { /* * Lite-On products */ { 0x11ad, 0xc115, 0, 0, "Lite-On LC82C115", MXFE_MODEL_PNICII }, /* * Macronix chips */ { 0x10d9, 0x0531, 0x25, 0xff, "Macronix MX98715AEC", MXFE_MODEL_98715AEC }, { 0x10d9, 0x0531, 0x20, 0xff, "Macronix MX98715A", MXFE_MODEL_98715A }, { 0x10d9, 0x0531, 0x60, 0xff, "Macronix MX98715B", MXFE_MODEL_98715B }, { 0x10d9, 0x0531, 0x30, 0xff, "Macronix MX98725", MXFE_MODEL_98725 }, { 0x10d9, 0x0531, 0x00, 0xff, "Macronix MX98715", MXFE_MODEL_98715 }, { 0x10d9, 0x0512, 0, 0, "Macronix MX98713", MXFE_MODEL_98713 }, /* * Compex (relabeled Macronix products) */ { 0x11fc, 0x9881, 0x00, 0x00, "Compex 9881", MXFE_MODEL_98713 }, { 0x11fc, 0x9881, 0x10, 0xff, "Compex 9881A", MXFE_MODEL_98713A }, /* * Models listed here */ { 0x11ad, 0xc001, 0, 0, "Linksys LNE100TX", MXFE_MODEL_PNICII }, { 0x2646, 0x000b, 0, 0, "Kingston KNE111TX", MXFE_MODEL_PNICII }, { 0x1154, 0x0308, 0, 0, "Buffalo LGY-PCI-TXL", MXFE_MODEL_98715AEC }, }; static uint32_t mxfe_txthresh[] = { MXFE_NAR_TR_72, /* 72 bytes (10Mbps), 128 bytes (100Mbps) */ MXFE_NAR_TR_96, /* 96 bytes (10Mbps), 256 bytes (100Mbps) */ MXFE_NAR_TR_128, /* 128 bytes (10Mbps), 512 bytes (100Mbps) */ MXFE_NAR_TR_160, /* 160 bytes (10Mbps), 1024 bytes (100Mbps) */ MXFE_NAR_SF /* store and forward */ }; #define MXFE_MAX_TXTHRESH (sizeof (mxfe_txthresh)/sizeof (uint32_t)) /* * Function prototypes */ static int mxfe_attach(dev_info_t *, ddi_attach_cmd_t); static int mxfe_detach(dev_info_t *, ddi_detach_cmd_t); static int mxfe_resume(gld_mac_info_t *); static int mxfe_set_mac_addr(gld_mac_info_t *, unsigned char *); static int mxfe_set_multicast(gld_mac_info_t *, unsigned char *, int); static int mxfe_set_promiscuous(gld_mac_info_t *, int); static int mxfe_send(gld_mac_info_t *, mblk_t *); static int mxfe_get_stats(gld_mac_info_t *, struct gld_stats *); static int mxfe_start(gld_mac_info_t *); static int mxfe_stop(gld_mac_info_t *); static int mxfe_ioctl(gld_mac_info_t *, queue_t *, mblk_t *); static unsigned mxfe_intr(gld_mac_info_t *); static int mxfe_reset(gld_mac_info_t *); static int mxfe_startmac(mxfe_t *); static int mxfe_stopmac(mxfe_t *); static int mxfe_mcadd(mxfe_t *, unsigned char *); static int mxfe_mcdelete(mxfe_t *, unsigned char *); static void mxfe_setrxfilt(mxfe_t *); static void mxfe_txreorder(mxfe_t *); static int mxfe_allocrings(mxfe_t *); static void mxfe_freerings(mxfe_t *); static int mxfe_allocsetup(mxfe_t *); static void mxfe_freesetup(mxfe_t *); static mxfe_buf_t *mxfe_getbuf(mxfe_t *, int); static void mxfe_freebuf(mxfe_buf_t *); static unsigned mxfe_etherhashle(uchar_t *); static int mxfe_msgsize(mblk_t *); static void mxfe_miocack(queue_t *, mblk_t *, uint8_t, int, int); static void mxfe_error(dev_info_t *, char *, ...); static void mxfe_verror(dev_info_t *, int, char *, va_list); static ushort mxfe_sromwidth(mxfe_t *); static ushort mxfe_readsromword(mxfe_t *, unsigned); static void mxfe_readsrom(mxfe_t *, unsigned, unsigned, char *); static void mxfe_getfactaddr(mxfe_t *, uchar_t *); static int mxfe_miireadbit(mxfe_t *); static void mxfe_miiwritebit(mxfe_t *, int); static void mxfe_miitristate(mxfe_t *); static unsigned mxfe_miiread(mxfe_t *, int, int); static void mxfe_miiwrite(mxfe_t *, int, int, ushort); static unsigned mxfe_miireadgeneral(mxfe_t *, int, int); static void mxfe_miiwritegeneral(mxfe_t *, int, int, ushort); static unsigned mxfe_miiread98713(mxfe_t *, int, int); static void mxfe_miiwrite98713(mxfe_t *, int, int, ushort); static void mxfe_phyinit(mxfe_t *); static void mxfe_phyinitmii(mxfe_t *); static void mxfe_phyinitnway(mxfe_t *); static void mxfe_startnway(mxfe_t *); static void mxfe_reportlink(mxfe_t *); static void mxfe_checklink(mxfe_t *); static void mxfe_checklinkmii(mxfe_t *); static void mxfe_checklinknway(mxfe_t *); static void mxfe_disableinterrupts(mxfe_t *); static void mxfe_enableinterrupts(mxfe_t *); static void mxfe_reclaim(mxfe_t *); static mblk_t *mxfe_read(mxfe_t *, int); static int mxfe_ndaddbytes(mblk_t *, char *, int); static int mxfe_ndaddstr(mblk_t *, char *, int); static void mxfe_ndparsestring(mblk_t *, char *, int); static int mxfe_ndparselen(mblk_t *); static int mxfe_ndparseint(mblk_t *); static void mxfe_ndget(mxfe_t *, queue_t *, mblk_t *); static void mxfe_ndset(mxfe_t *, queue_t *, mblk_t *); static void mxfe_ndfini(mxfe_t *); static void mxfe_ndinit(mxfe_t *); #ifdef DEBUG static void mxfe_dprintf(mxfe_t *, const char *, int, char *, ...); #endif #define KIOIP KSTAT_INTR_PTR(mxfep->mxfe_intrstat) /* * Stream information */ static struct module_info mxfe_module_info = { MXFE_IDNUM, /* mi_idnum */ MXFE_IDNAME, /* mi_idname */ MXFE_MINPSZ, /* mi_minpsz */ MXFE_MAXPSZ, /* mi_maxpsz */ MXFE_HIWAT, /* mi_hiwat */ MXFE_LOWAT /* mi_lowat */ }; static struct qinit mxfe_rinit = { NULL, /* qi_putp */ gld_rsrv, /* qi_srvp */ gld_open, /* qi_qopen */ gld_close, /* qi_qclose */ NULL, /* qi_qadmin */ &mxfe_module_info, /* qi_minfo */ NULL /* qi_mstat */ }; static struct qinit mxfe_winit = { gld_wput, /* qi_putp */ gld_wsrv, /* qi_srvp */ NULL, /* qi_qopen */ NULL, /* qi_qclose */ NULL, /* qi_qadmin */ &mxfe_module_info, /* qi_minfo */ NULL /* qi_mstat */ }; static struct streamtab mxfe_streamtab = { &mxfe_rinit, /* st_rdinit */ &mxfe_winit, /* st_wrinit */ NULL, /* st_muxrinit */ NULL /* st_muxwinit */ }; /* * Character/block operations. */ static struct cb_ops mxfe_cbops = { nulldev, /* cb_open */ nulldev, /* cb_close */ nodev, /* cb_strategy */ nodev, /* cb_print */ nodev, /* cb_dump */ nodev, /* cb_read */ nodev, /* cb_write */ nodev, /* cb_ioctl */ nodev, /* cb_devmap */ nodev, /* cb_mmap */ nodev, /* cb_segmap */ nochpoll, /* cb_chpoll */ ddi_prop_op, /* cb_prop_op */ &mxfe_streamtab, /* cb_stream */ D_MP, /* cb_flag */ CB_REV, /* cb_rev */ nodev, /* cb_aread */ nodev /* cb_awrite */ }; /* * Device operations. */ static struct dev_ops mxfe_devops = { DEVO_REV, /* devo_rev */ 0, /* devo_refcnt */ gld_getinfo, /* devo_getinfo */ nulldev, /* devo_identify */ nulldev, /* devo_probe */ mxfe_attach, /* devo_attach */ mxfe_detach, /* devo_detach */ nodev, /* devo_reset */ &mxfe_cbops, /* devo_cb_ops */ NULL, /* devo_bus_ops */ ddi_power /* devo_power */ }; /* * Module linkage information. */ #define MXFE_IDENT "MXFE Fast Ethernet" static struct modldrv mxfe_modldrv = { &mod_driverops, /* drv_modops */ MXFE_IDENT, /* drv_linkinfo */ &mxfe_devops /* drv_dev_ops */ }; static struct modlinkage mxfe_modlinkage = { MODREV_1, /* ml_rev */ { &mxfe_modldrv, NULL } /* ml_linkage */ }; /* * Device attributes. */ static ddi_device_acc_attr_t mxfe_devattr = { DDI_DEVICE_ATTR_V0, DDI_STRUCTURE_LE_ACC, DDI_STRICTORDER_ACC }; static ddi_device_acc_attr_t mxfe_bufattr = { DDI_DEVICE_ATTR_V0, DDI_NEVERSWAP_ACC, DDI_STRICTORDER_ACC }; static ddi_dma_attr_t mxfe_dma_attr = { DMA_ATTR_V0, /* dma_attr_version */ 0, /* dma_attr_addr_lo */ 0xFFFFFFFFU, /* dma_attr_addr_hi */ 0x7FFFFFFFU, /* dma_attr_count_max */ 4, /* dma_attr_align */ /* FIXME: verify the burstsizes */ 0x3F, /* dma_attr_burstsizes */ 1, /* dma_attr_minxfer */ 0xFFFFFFFFU, /* dma_attr_maxxfer */ 0xFFFFFFFFU, /* dma_attr_seg */ 1, /* dma_attr_sgllen */ 1, /* dma_attr_granular */ 0 /* dma_attr_flags */ }; /* * Ethernet addresses. */ static uchar_t mxfe_broadcast_addr[ETHERADDRL] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* * DDI entry points. */ int _init(void) { return (mod_install(&mxfe_modlinkage)); } int _fini(void) { return (mod_remove(&mxfe_modlinkage)); } int _info(struct modinfo *modinfop) { return (mod_info(&mxfe_modlinkage, modinfop)); } static int mxfe_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) { gld_mac_info_t *macinfo; mxfe_t *mxfep; int inst = ddi_get_instance(dip); ddi_acc_handle_t pci; ushort venid; ushort devid; ushort revid; ushort svid; ushort ssid; ushort cachesize; mxfe_card_t *cardp; int i; char buf[16]; switch (cmd) { case DDI_RESUME: macinfo = (gld_mac_info_t *)ddi_get_driver_private(dip); if (macinfo == NULL) { return (DDI_FAILURE); } return (mxfe_resume(macinfo)); case DDI_ATTACH: break; default: return (DDI_FAILURE); } /* this card is a bus master, reject any slave-only slot */ if (ddi_slaveonly(dip) == DDI_SUCCESS) { mxfe_error(dip, "slot does not support PCI bus-master"); return (DDI_FAILURE); } /* PCI devices shouldn't generate hilevel interrupts */ if (ddi_intr_hilevel(dip, 0) != 0) { mxfe_error(dip, "hilevel interrupts not supported"); return (DDI_FAILURE); } if (pci_config_setup(dip, &pci) != DDI_SUCCESS) { mxfe_error(dip, "unable to setup PCI config handle"); return (DDI_FAILURE); } venid = pci_config_get16(pci, MXFE_PCI_VID); devid = pci_config_get16(pci, MXFE_PCI_DID); revid = pci_config_get16(pci, MXFE_PCI_RID); svid = pci_config_get16(pci, MXFE_PCI_SVID); ssid = pci_config_get16(pci, MXFE_PCI_SSID); DBG(MXFE_DPCI, "mingnt %x", pci_config_get8(pci, MXFE_PCI_MINGNT)); DBG(MXFE_DPCI, "maxlat %x", pci_config_get8(pci, MXFE_PCI_MAXLAT)); /* * the last entry in the card table matches every possible * card, so the for-loop always terminates properly. */ cardp = NULL; for (i = 0; i < (sizeof (mxfe_cards) / sizeof (mxfe_card_t)); i++) { if ((venid == mxfe_cards[i].card_venid) && (devid == mxfe_cards[i].card_devid) && ((revid & mxfe_cards[i].card_revmask) == mxfe_cards[i].card_revid)) { cardp = &mxfe_cards[i]; } if ((svid == mxfe_cards[i].card_venid) && (ssid == mxfe_cards[i].card_devid) && ((revid & mxfe_cards[i].card_revmask) == mxfe_cards[i].card_revid)) { cardp = &mxfe_cards[i]; break; } } if (cardp == NULL) { pci_config_teardown(&pci); mxfe_error(dip, "Unable to identify PCI card"); return (DDI_FAILURE); } if (ddi_prop_update_string(DDI_DEV_T_NONE, dip, "model", cardp->card_cardname) != DDI_SUCCESS) { pci_config_teardown(&pci); mxfe_error(dip, "Unable to create model property"); return (DDI_FAILURE); } /* * Grab the PCI cachesize -- we use this to program the * cache-optimization bus access bits. */ cachesize = pci_config_get8(pci, MXFE_PCI_CLS); if ((macinfo = gld_mac_alloc(dip)) == NULL) { pci_config_teardown(&pci); mxfe_error(dip, "Unable to allocate macinfo"); return (DDI_FAILURE); } /* this cannot fail */ mxfep = (mxfe_t *)kmem_zalloc(sizeof (mxfe_t), KM_SLEEP); mxfep->mxfe_macinfo = macinfo; switch (cardp->card_model) { case MXFE_MODEL_98715AEC: case MXFE_MODEL_PNICII: mxfep->mxfe_mcmask = 0x7f; break; case MXFE_MODEL_98715B: mxfep->mxfe_mcmask = 0x3f; break; default: mxfep->mxfe_mcmask = 0x1ff; break; } macinfo->gldm_private = (void *)mxfep; macinfo->gldm_reset = mxfe_reset; macinfo->gldm_start = mxfe_start; macinfo->gldm_stop = mxfe_stop; macinfo->gldm_set_mac_addr = mxfe_set_mac_addr; macinfo->gldm_set_multicast = mxfe_set_multicast; macinfo->gldm_set_promiscuous = mxfe_set_promiscuous; macinfo->gldm_get_stats = mxfe_get_stats; macinfo->gldm_send = mxfe_send; macinfo->gldm_intr = mxfe_intr; macinfo->gldm_ioctl = mxfe_ioctl; macinfo->gldm_ident = cardp->card_cardname; macinfo->gldm_type = DL_ETHER; macinfo->gldm_minpkt = 0; macinfo->gldm_maxpkt = ETHERMTU; macinfo->gldm_addrlen = ETHERADDRL; macinfo->gldm_saplen = -2; macinfo->gldm_broadcast_addr = mxfe_broadcast_addr; macinfo->gldm_vendor_addr = mxfep->mxfe_factaddr; macinfo->gldm_devinfo = dip; macinfo->gldm_ppa = inst; /* get the interrupt block cookie */ if (ddi_get_iblock_cookie(dip, 0, &macinfo->gldm_cookie) != DDI_SUCCESS) { mxfe_error(dip, "ddi_get_iblock_cookie failed"); pci_config_teardown(&pci); kmem_free(mxfep, sizeof (mxfe_t)); gld_mac_free(macinfo); return (DDI_FAILURE); } ddi_set_driver_private(dip, (caddr_t)macinfo); mxfep->mxfe_dip = dip; mxfep->mxfe_cardp = cardp; mxfep->mxfe_phyaddr = -1; mxfep->mxfe_cachesize = cachesize; mxfep->mxfe_numbufs = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "buffers", MXFE_NUMBUFS); mxfep->mxfe_txring = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "txdescriptors", MXFE_TXRING); mxfep->mxfe_rxring = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "rxdescriptors", MXFE_RXRING); /* default properties */ mxfep->mxfe_adv_aneg = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "adv_autoneg_cap", 1); mxfep->mxfe_adv_100T4 = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "adv_100T4_cap", 1); mxfep->mxfe_adv_100fdx = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "adv_100fdx_cap", 1); mxfep->mxfe_adv_100hdx = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "adv_100hdx_cap", 1); mxfep->mxfe_adv_10fdx = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "adv_10fdx_cap", 1); mxfep->mxfe_adv_10hdx = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 0, "adv_10hdx_cap", 1); DBG(MXFE_DPCI, "PCI vendor id = %x", venid); DBG(MXFE_DPCI, "PCI device id = %x", devid); DBG(MXFE_DPCI, "PCI revision id = %x", revid); DBG(MXFE_DPCI, "PCI cachesize = %d", cachesize); DBG(MXFE_DPCI, "PCI COMM = %x", pci_config_get8(pci, MXFE_PCI_COMM)); DBG(MXFE_DPCI, "PCI STAT = %x", pci_config_get8(pci, MXFE_PCI_STAT)); (void) mutex_init(&mxfep->mxfe_buflock, NULL, MUTEX_DRIVER, macinfo->gldm_cookie); (void) mutex_init(&mxfep->mxfe_xmtlock, NULL, MUTEX_DRIVER, macinfo->gldm_cookie); (void) mutex_init(&mxfep->mxfe_intrlock, NULL, MUTEX_DRIVER, macinfo->gldm_cookie); mxfe_ndinit(mxfep); /* * Initialize interrupt kstat. */ sprintf(buf, "mxfec%d", inst); mxfep->mxfe_intrstat = kstat_create("mxfe", inst, buf, "controller", KSTAT_TYPE_INTR, 1, KSTAT_FLAG_PERSISTENT); if (mxfep->mxfe_intrstat) { kstat_install(mxfep->mxfe_intrstat); } /* * Enable bus master, IO space, and memory space accesses. */ pci_config_put16(pci, MXFE_PCI_COMM, pci_config_get16(pci, MXFE_PCI_COMM) | MXFE_PCI_BME | MXFE_PCI_MAE | MXFE_PCI_IOE); /* we're done with this now, drop it */ pci_config_teardown(&pci); /* * Map in the device registers. */ ddi_dev_regsize(dip, 1, &mxfep->mxfe_regsize); if (ddi_regs_map_setup(dip, 1, (caddr_t *)&mxfep->mxfe_regs, 0, 0, &mxfe_devattr, &mxfep->mxfe_regshandle)) { mxfe_error(dip, "ddi_regs_map_setup failed"); pci_config_teardown(&pci); goto failed; } /* Stop the board. */ CLRBIT(mxfep, MXFE_CSR_NAR, MXFE_TX_ENABLE | MXFE_RX_ENABLE); /* Turn off all interrupts for now. */ mxfe_disableinterrupts(mxfep); /* * Allocate DMA resources (descriptor rings and buffers). */ if (mxfe_allocrings(mxfep) != DDI_SUCCESS) { mxfe_error(dip, "unable to allocate DMA resources"); goto failed; } /* * Allocate resources for setup frame. */ if (mxfe_allocsetup(mxfep) != DDI_SUCCESS) { mxfe_error(dip, "unable to allocate DMA for setup frame"); goto failed; } /* Reset the chip. */ mxfe_reset(macinfo); /* FIXME: insert hardware initializations here */ /* Determine the number of address bits to our EEPROM. */ mxfep->mxfe_sromwidth = mxfe_sromwidth(mxfep); /* * Get the factory ethernet address. This becomes the current * ethernet address (it can be overridden later via ifconfig). * FIXME: consider allowing this to be tunable via a property */ mxfe_getfactaddr(mxfep, mxfep->mxfe_factaddr); mxfep->mxfe_promisc = GLD_MAC_PROMISC_NONE; if (ddi_add_intr(dip, 0, NULL, NULL, gld_intr, (void *)macinfo) != DDI_SUCCESS) { mxfe_error(dip, "unable to add interrupt"); goto failed; } /* FIXME: do the power management stuff */ /* make sure we add broadcast address to filter */ mxfe_set_multicast(macinfo, mxfe_broadcast_addr, GLD_MULTI_ENABLE); if (gld_register(dip, MXFE_IDNAME, macinfo) == DDI_SUCCESS) { return (DDI_SUCCESS); } /* failed to register with GLD */ failed: if (macinfo->gldm_cookie != NULL) { ddi_remove_intr(dip, 0, macinfo->gldm_cookie); } if (mxfep->mxfe_intrstat) { kstat_delete(mxfep->mxfe_intrstat); } mxfe_ndfini(mxfep); mutex_destroy(&mxfep->mxfe_buflock); mutex_destroy(&mxfep->mxfe_intrlock); mutex_destroy(&mxfep->mxfe_xmtlock); mxfe_freesetup(mxfep); mxfe_freerings(mxfep); if (mxfep->mxfe_regshandle != NULL) { ddi_regs_map_free(&mxfep->mxfe_regshandle); } kmem_free(mxfep, sizeof (mxfe_t)); gld_mac_free(macinfo); return (DDI_FAILURE); } static int mxfe_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) { gld_mac_info_t *macinfo; mxfe_t *mxfep; macinfo = (gld_mac_info_t *)ddi_get_driver_private(dip); if (macinfo == NULL) { mxfe_error(dip, "no soft state in detach!"); return (DDI_FAILURE); } mxfep = (mxfe_t *)macinfo->gldm_private; switch (cmd) { case DDI_DETACH: if (gld_unregister(macinfo) != DDI_SUCCESS) { return (DDI_FAILURE); } /* make sure hardware is quiesced */ mxfe_stop(macinfo); /* clean up and shut down device */ ddi_remove_intr(dip, 0, macinfo->gldm_cookie); /* cleanup kstats */ if (mxfep->mxfe_intrstat) { kstat_delete(mxfep->mxfe_intrstat); } /* FIXME: delete properties */ /* free up any left over buffers or DMA resources */ if (mxfep->mxfe_desc_dmahandle != NULL) { int i; /* free up buffers first (reclaim) */ for (i = 0; i < mxfep->mxfe_txring; i++) { if (mxfep->mxfe_txbufs[i]) { mxfe_freebuf(mxfep->mxfe_txbufs[i]); mxfep->mxfe_txbufs[i] = NULL; } } for (i = 0; i < mxfep->mxfe_rxring; i++) { if (mxfep->mxfe_rxbufs[i]) { mxfe_freebuf(mxfep->mxfe_rxbufs[i]); mxfep->mxfe_rxbufs[i] = NULL; } } /* then free up DMA resourcess */ mxfe_freerings(mxfep); } mxfe_freesetup(mxfep); mxfe_ndfini(mxfep); ddi_regs_map_free(&mxfep->mxfe_regshandle); mutex_destroy(&mxfep->mxfe_buflock); mutex_destroy(&mxfep->mxfe_intrlock); mutex_destroy(&mxfep->mxfe_xmtlock); kmem_free(mxfep, sizeof (mxfe_t)); gld_mac_free(macinfo); return (DDI_SUCCESS); case DDI_SUSPEND: /* quiesce the hardware */ mutex_enter(&mxfep->mxfe_intrlock); mutex_enter(&mxfep->mxfe_xmtlock); mxfep->mxfe_flags |= MXFE_SUSPENDED; mxfe_stopmac(mxfep); mutex_exit(&mxfep->mxfe_xmtlock); mutex_exit(&mxfep->mxfe_intrlock); return (DDI_SUCCESS); default: return (DDI_FAILURE); } } static int mxfe_ioctl(gld_mac_info_t *macinfo, queue_t *wq, mblk_t *mp) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; switch (IOC_CMD(mp)) { case NDIOC_GET: mxfe_ndget(mxfep, wq, mp); break; case NDIOC_SET: mxfe_ndset(mxfep, wq, mp); break; default: mxfe_miocack(wq, mp, M_IOCNAK, 0, EINVAL); break; } return (GLD_SUCCESS); } static int mxfe_mcadd(mxfe_t *mxfep, unsigned char *macaddr) { unsigned hash; int changed = 0; int byte; int offset; hash = mxfe_etherhashle(macaddr) & mxfep->mxfe_mcmask;; /* calculate the byte offset first */ byte = hash / 8; /* note that this is *not* "byte * 2", due to truncation! */ offset = ((byte / 2) * 4) + (byte % 2); if ((mxfep->mxfe_mccount[hash]) == 0) { mxfep->mxfe_setup_buf[offset] |= (1 << (hash % 8)); changed++; } mxfep->mxfe_mccount[hash]++; return (changed); } static int mxfe_mcdelete(mxfe_t *mxfep, unsigned char *macaddr) { unsigned hash; int changed = 0; int byte; int offset; hash = mxfe_etherhashle(macaddr) & mxfep->mxfe_mcmask; /* calculate the byte offset first */ byte = hash / 8; /* note that this is *not* "byte * 2", due to truncation! */ offset = ((byte / 2) * 4) + (byte % 2); if ((mxfep->mxfe_mccount[hash]) == 1) { mxfep->mxfe_setup_buf[offset] &= ~(1 << (hash % 8)); changed++; } mxfep->mxfe_mccount[hash]--; return (changed); } static int mxfe_set_multicast(gld_mac_info_t *macinfo, unsigned char *macaddr, int flag) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; int changed = 0; /* exclusive access to the card while we reprogram it */ mutex_enter(&mxfep->mxfe_xmtlock); switch (flag) { case GLD_MULTI_ENABLE: changed = mxfe_mcadd(mxfep, macaddr); break; case GLD_MULTI_DISABLE: changed = mxfe_mcdelete(mxfep, macaddr); break; } if (changed) { mxfe_setrxfilt(mxfep); } mutex_exit(&mxfep->mxfe_xmtlock); return (GLD_SUCCESS); } static int mxfe_set_promiscuous(gld_mac_info_t *macinfo, int flag) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; /* exclusive access to the card while we reprogram it */ mutex_enter(&mxfep->mxfe_xmtlock); /* save current promiscuous mode state for replay in resume */ mxfep->mxfe_promisc = flag; mxfe_setrxfilt(mxfep); mutex_exit(&mxfep->mxfe_xmtlock); return (GLD_SUCCESS); } static int mxfe_set_mac_addr(gld_mac_info_t *macinfo, unsigned char *macaddr) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; caddr_t kaddr = mxfep->mxfe_setup_buf; mutex_enter(&mxfep->mxfe_xmtlock); bcopy(macaddr, mxfep->mxfe_curraddr, ETHERADDRL); kaddr[156] = mxfep->mxfe_curraddr[0]; kaddr[157] = mxfep->mxfe_curraddr[1]; kaddr[160] = mxfep->mxfe_curraddr[2]; kaddr[161] = mxfep->mxfe_curraddr[3]; kaddr[164] = mxfep->mxfe_curraddr[4]; kaddr[165] = mxfep->mxfe_curraddr[5]; mxfe_setrxfilt(mxfep); mutex_exit(&mxfep->mxfe_xmtlock); return (GLD_SUCCESS); } /* * Hardware management. */ static int mxfe_resetmac(mxfe_t *mxfep) { int i; unsigned val; ASSERT(mutex_owned(&mxfep->mxfe_intrlock)); ASSERT(mutex_owned(&mxfep->mxfe_xmtlock)); DBG(MXFE_DCHATTY, "resetting!"); SETBIT(mxfep, MXFE_CSR_PAR, MXFE_RESET); for (i = 1; i < 10; i++) { drv_usecwait(5); val = GETCSR(mxfep, MXFE_CSR_PAR); if (!(val & MXFE_RESET)) { break; } } if (i == 10) { mxfe_error(mxfep->mxfe_dip, "timed out waiting for reset!"); return (GLD_FAILURE); } /* FIXME: possibly set some other regs here, e.g. arbitration. */ /* initialize busctl register */ /* clear all the cache alignment bits */ CLRBIT(mxfep, MXFE_CSR_PAR, MXFE_CALIGN_32); /* then set the cache alignment if its supported */ switch (mxfep->mxfe_cachesize) { case 8: SETBIT(mxfep, MXFE_CSR_PAR, MXFE_CALIGN_8); break; case 16: SETBIT(mxfep, MXFE_CSR_PAR, MXFE_CALIGN_16); break; case 32: SETBIT(mxfep, MXFE_CSR_PAR, MXFE_CALIGN_32); break; } /* unconditional 32-word burst */ SETBIT(mxfep, MXFE_CSR_PAR, MXFE_BURST_32); return (GLD_SUCCESS); } static int mxfe_reset(gld_mac_info_t *macinfo) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; int rv; mutex_enter(&mxfep->mxfe_intrlock); mutex_enter(&mxfep->mxfe_xmtlock); rv = mxfe_resetmac(mxfep); mutex_exit(&mxfep->mxfe_xmtlock); mutex_exit(&mxfep->mxfe_intrlock); return (rv); } static int mxfe_resume(gld_mac_info_t *macinfo) { mxfe_t *mxfep; if (macinfo == NULL) { return (DDI_FAILURE); } mxfep = (mxfe_t *)macinfo->gldm_private; mutex_enter(&mxfep->mxfe_intrlock); mutex_enter(&mxfep->mxfe_xmtlock); /* reset chip */ if (mxfe_resetmac(mxfep) != GLD_SUCCESS) { mxfe_error(mxfep->mxfe_dip, "unable to resume chip!"); mxfep->mxfe_flags |= MXFE_SUSPENDED; mutex_exit(&mxfep->mxfe_intrlock); mutex_exit(&mxfep->mxfe_xmtlock); return (DDI_SUCCESS); } /* restore rx filter */ mxfe_setrxfilt(mxfep); /* start the chip */ if (mxfep->mxfe_flags & MXFE_RUNNING) { if (mxfe_startmac(mxfep) != GLD_SUCCESS) { mxfe_error(mxfep->mxfe_dip, "unable to restart mac!"); mxfep->mxfe_flags |= MXFE_SUSPENDED; mutex_exit(&mxfep->mxfe_intrlock); mutex_exit(&mxfep->mxfe_xmtlock); return (DDI_SUCCESS); } } /* drop locks */ mutex_exit(&mxfep->mxfe_xmtlock); mutex_exit(&mxfep->mxfe_intrlock); return (DDI_SUCCESS); } /* * Serial EEPROM access - derived from the FreeBSD implementation. */ static ushort mxfe_sromwidth(mxfe_t *mxfep) { int i; int eeread; int addrlen = 8; eeread = MXFE_SROM_READ | MXFE_SROM_SEL | MXFE_SROM_CHIP; PUTCSR(mxfep, MXFE_CSR_SPR, eeread & ~MXFE_SROM_CHIP); drv_usecwait(1); PUTCSR(mxfep, MXFE_CSR_SPR, eeread); /* command bits first */ for (i = 4; i != 0; i >>= 1) { unsigned val = (MXFE_SROM_READCMD & i) ? MXFE_SROM_DIN : 0; PUTCSR(mxfep, MXFE_CSR_SPR, eeread | val); drv_usecwait(1); PUTCSR(mxfep, MXFE_CSR_SPR, eeread | val | MXFE_SROM_CLOCK); drv_usecwait(1); } PUTCSR(mxfep, MXFE_CSR_SPR, eeread); for (addrlen = 1; addrlen <= 12; addrlen++) { PUTCSR(mxfep, MXFE_CSR_SPR, eeread | MXFE_SROM_CLOCK); drv_usecwait(1); if (!(GETCSR(mxfep, MXFE_CSR_SPR) & MXFE_SROM_DOUT)) { PUTCSR(mxfep, MXFE_CSR_SPR, eeread); drv_usecwait(1); break; } PUTCSR(mxfep, MXFE_CSR_SPR, eeread); drv_usecwait(1); } /* turn off accesses to the EEPROM */ PUTCSR(mxfep, MXFE_CSR_SPR, eeread &~ MXFE_SROM_CHIP); DBG(MXFE_DSROM, "detected srom width = %d bits", addrlen); return ((addrlen < 4 || addrlen > 12) ? 6 : addrlen); } /* * The words in EEPROM are stored in little endian order. We * shift bits out in big endian order, though. This requires * a byte swap on some platforms. */ static ushort mxfe_readsromword(mxfe_t *mxfep, unsigned romaddr) { int i; ushort word = 0; ushort retval; int eeread; int addrlen; int readcmd; uchar_t *ptr; eeread = MXFE_SROM_READ | MXFE_SROM_SEL | MXFE_SROM_CHIP; addrlen = mxfep->mxfe_sromwidth; readcmd = (MXFE_SROM_READCMD << addrlen) | romaddr; if (romaddr >= (1 << addrlen)) { /* too big to fit! */ return (0); } PUTCSR(mxfep, MXFE_CSR_SPR, eeread & ~MXFE_SROM_CHIP); PUTCSR(mxfep, MXFE_CSR_SPR, eeread); /* command and address bits */ for (i = 4 + addrlen; i >= 0; i--) { short val = (readcmd & (1 << i)) ? MXFE_SROM_DIN : 0; PUTCSR(mxfep, MXFE_CSR_SPR, eeread | val); drv_usecwait(1); PUTCSR(mxfep, MXFE_CSR_SPR, eeread | val | MXFE_SROM_CLOCK); drv_usecwait(1); } PUTCSR(mxfep, MXFE_CSR_SPR, eeread); for (i = 0; i < 16; i++) { PUTCSR(mxfep, MXFE_CSR_SPR, eeread | MXFE_SROM_CLOCK); drv_usecwait(1); word <<= 1; if (GETCSR(mxfep, MXFE_CSR_SPR) & MXFE_SROM_DOUT) { word |= 1; } PUTCSR(mxfep, MXFE_CSR_SPR, eeread); drv_usecwait(1); } /* turn off accesses to the EEPROM */ PUTCSR(mxfep, MXFE_CSR_SPR, eeread &~ MXFE_SROM_CHIP); /* * Fix up the endianness thing. Note that the values * are stored in little endian format on the SROM. */ DBG(MXFE_DSROM, "got value %d from SROM (before swap)", word); ptr = (uchar_t *)&word; retval = (ptr[1] << 8) | ptr[0]; return (retval); } static void mxfe_readsrom(mxfe_t *mxfep, unsigned romaddr, unsigned len, char *dest) { int i; ushort word; ushort *ptr = (ushort *)dest; for (i = 0; i < len; i++) { word = mxfe_readsromword(mxfep, romaddr + i); *ptr = word; DBG(MXFE_DSROM, "word at %d is 0x%x", romaddr + i, word); ptr++; } } static void mxfe_getfactaddr(mxfe_t *mxfep, uchar_t *eaddr) { ushort word; uchar_t *ptr; word = mxfe_readsromword(mxfep, MXFE_SROM_ENADDR / 2); ptr = (uchar_t *)&word; word = (ptr[1] << 8) | ptr[0]; mxfe_readsrom(mxfep, word / 2, ETHERADDRL / 2, (char *)eaddr); DBG(MXFE_DMACID, "factory ethernet address = %02x:%02x:%02x:%02x:%02x:%02x", eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]); } static void mxfe_phyinit(mxfe_t *mxfep) { switch (MXFE_MODEL(mxfep)) { case MXFE_MODEL_98713A: mxfe_phyinitmii(mxfep); break; default: mxfe_phyinitnway(mxfep); break; } } /* * NWay support. */ static void mxfe_startnway(mxfe_t *mxfep) { unsigned nar; unsigned tctl; unsigned restart; /* this should not happen in a healthy system */ if (mxfep->mxfe_linkstate != MXFE_NOLINK) { DBG(MXFE_DWARN, "link start called out of state (%x)", mxfep->mxfe_linkstate); return; } if (mxfep->mxfe_adv_aneg == 0) { /* not done for forced mode */ return; } nar = GETCSR(mxfep, MXFE_CSR_NAR); restart = nar & (MXFE_TX_ENABLE | MXFE_RX_ENABLE); /* enable scrambler mode - also disables tx/rx */ PUTCSR(mxfep, MXFE_CSR_NAR, MXFE_NAR_SCR); nar = MXFE_NAR_SCR | MXFE_NAR_PCS | MXFE_NAR_HBD; tctl = GETCSR(mxfep, MXFE_CSR_TCTL); tctl &= ~(MXFE_TCTL_100FDX | MXFE_TCTL_100HDX | MXFE_TCTL_HDX); if (mxfep->mxfe_adv_100fdx) { tctl |= MXFE_TCTL_100FDX; } if (mxfep->mxfe_adv_100hdx) { tctl |= MXFE_TCTL_100HDX; } if (mxfep->mxfe_adv_10fdx) { nar |= MXFE_NAR_FDX | MXFE_TCTL_PWR; } if (mxfep->mxfe_adv_10hdx) { tctl |= MXFE_TCTL_HDX | MXFE_TCTL_PWR; } tctl |= MXFE_TCTL_ANE; tctl |= MXFE_TCTL_LTE | MXFE_TCTL_RSQ | MXFE_TCTL_PWR; /* FIXME: possibly add store-and-forward */ nar = MXFE_NAR_SCR | MXFE_NAR_PCS | MXFE_NAR_HBD | MXFE_NAR_FDX; /* FIXME: possibly this should be absolute, are reads of TCTL sane? */ /* possibly we should add in support for PAUSE frames */ DBG(MXFE_DPHY, "writing nar = 0x%x", nar); PUTCSR(mxfep, MXFE_CSR_NAR, nar); DBG(MXFE_DPHY, "writing tctl = 0x%x", tctl); PUTCSR(mxfep, MXFE_CSR_TCTL, tctl); /* restart autonegotation */ DBG(MXFE_DPHY, "writing tstat = 0x%x", MXFE_ANS_START); PUTCSR(mxfep, MXFE_CSR_TSTAT, MXFE_ANS_START); /* restart tx/rx processes... */ PUTCSR(mxfep, MXFE_CSR_NAR, nar | restart); /* Macronix initializations from Bolo Tsai */ PUTCSR(mxfep, MXFE_CSR_MXMAGIC, 0x0b2c0000); PUTCSR(mxfep, MXFE_CSR_ACOMP, 0x11000); mxfep->mxfe_linkstate = MXFE_NWAYCHECK; } static void mxfe_checklinknway(mxfe_t *mxfep) { unsigned nar, tstat, tctl, lpar; int nwayok = 0; DBG(MXFE_DPHY, "NWay check, state %x", mxfep->mxfe_linkstate); nar = GETCSR(mxfep, MXFE_CSR_NAR); tstat = GETCSR(mxfep, MXFE_CSR_TSTAT); tctl = GETCSR(mxfep, MXFE_CSR_TCTL); lpar = MXFE_TSTAT_LPAR(tstat); mxfep->mxfe_anlpar = lpar; if (tstat & MXFE_TSTAT_LPN) { mxfep->mxfe_aner |= MII_ANER_LPANA; } else { mxfep->mxfe_aner &= ~(MII_ANER_LPANA); } DBG(MXFE_DPHY, "nar(CSR6) = 0x%x", nar); DBG(MXFE_DPHY, "tstat(CSR12) = 0x%x", tstat); DBG(MXFE_DPHY, "tctl(CSR14) = 0x%x", tctl); DBG(MXFE_DPHY, "ANEG state = 0x%x", (tstat & MXFE_TSTAT_ANS) >> 12); if ((tstat & MXFE_TSTAT_ANS) != MXFE_ANS_OK) { /* autoneg did not complete */ nwayok = 0; mxfep->mxfe_bmsr &= ~MII_BMSR_ANC; } else { nwayok = 1; mxfep->mxfe_bmsr |= ~MII_BMSR_ANC; } if ((tstat & MXFE_TSTAT_100F) && (tstat & MXFE_TSTAT_10F)) { mxfep->mxfe_linkup = 0; mxfep->mxfe_ifspeed = 0; mxfep->mxfe_duplex = GLD_DUPLEX_UNKNOWN; mxfep->mxfe_media = GLDM_UNKNOWN; mxfep->mxfe_linkstate = MXFE_NOLINK; mxfe_reportlink(mxfep); mxfe_startnway(mxfep); return; } /* * if the link is newly up, then we might need to set various * mode bits, or negotiate for parameters, etc. */ if (mxfep->mxfe_adv_aneg) { mxfep->mxfe_media = GLDM_TP; mxfep->mxfe_linkup = 1; if (tstat & MXFE_TSTAT_LPN) { /* partner has NWay */ if ((mxfep->mxfe_anlpar & MII_ANEG_100FDX) && mxfep->mxfe_adv_100fdx) { mxfep->mxfe_ifspeed = 100000000; mxfep->mxfe_duplex = GLD_DUPLEX_FULL; } else if ((mxfep->mxfe_anlpar & MII_ANEG_100HDX) && mxfep->mxfe_adv_100hdx) { mxfep->mxfe_ifspeed = 100000000; mxfep->mxfe_duplex = GLD_DUPLEX_HALF; } else if ((mxfep->mxfe_anlpar & MII_ANEG_10FDX) && mxfep->mxfe_adv_10fdx) { mxfep->mxfe_ifspeed = 10000000; mxfep->mxfe_duplex = GLD_DUPLEX_FULL; } else if ((mxfep->mxfe_anlpar & MII_ANEG_10HDX) && mxfep->mxfe_adv_10hdx) { mxfep->mxfe_ifspeed = 10000000; mxfep->mxfe_duplex = GLD_DUPLEX_HALF; } else { mxfep->mxfe_media = GLDM_UNKNOWN; mxfep->mxfe_ifspeed = 0; } } else { /* link partner does not have NWay */ /* we just assume half duplex, since we can't * detect it! */ mxfep->mxfe_duplex = GLD_DUPLEX_HALF; if (!(tstat & MXFE_TSTAT_100F)) { DBG(MXFE_DPHY, "Partner doesn't have NWAY"); mxfep->mxfe_ifspeed = 100000000; } else { mxfep->mxfe_ifspeed = 10000000; } } } else { /* forced modes */ mxfep->mxfe_media = GLDM_TP; mxfep->mxfe_linkup = 1; if (mxfep->mxfe_adv_100fdx) { mxfep->mxfe_ifspeed = 100000000; mxfep->mxfe_duplex = GLD_DUPLEX_FULL; } else if (mxfep->mxfe_adv_100hdx) { mxfep->mxfe_ifspeed = 100000000; mxfep->mxfe_duplex = GLD_DUPLEX_HALF; } else if (mxfep->mxfe_adv_10fdx) { mxfep->mxfe_ifspeed = 10000000; mxfep->mxfe_duplex = GLD_DUPLEX_FULL; } else if (mxfep->mxfe_adv_10hdx) { mxfep->mxfe_ifspeed = 10000000; mxfep->mxfe_duplex = GLD_DUPLEX_HALF; } else { mxfep->mxfe_ifspeed = 0; } } mxfe_reportlink(mxfep); mxfep->mxfe_linkstate = MXFE_GOODLINK; } static void mxfe_phyinitnway(mxfe_t *mxfep) { mxfep->mxfe_linkstate = MXFE_NOLINK; mxfep->mxfe_bmsr = MII_BMSR_ANA | MII_BMSR_100FDX | MII_BMSR_100HDX | MII_BMSR_10FDX | MII_BMSR_10HDX; /* 100-T4 not supported with NWay */ mxfep->mxfe_adv_100T4 = 0; /* make sure at least one valid mode is selected */ if ((!mxfep->mxfe_adv_100fdx) && (!mxfep->mxfe_adv_100hdx) && (!mxfep->mxfe_adv_10fdx) && (!mxfep->mxfe_adv_10hdx)) { mxfe_error(mxfep->mxfe_dip, "No valid link mode selected."); mxfe_error(mxfep->mxfe_dip, "Falling back to 10 Mbps Half-Duplex mode."); mxfep->mxfe_adv_10hdx = 1; } if (mxfep->mxfe_adv_aneg == 0) { /* forced mode */ unsigned restart; unsigned nar; unsigned tctl; nar = GETCSR(mxfep, MXFE_CSR_NAR); tctl = GETCSR(mxfep, MXFE_CSR_TCTL); restart = nar & (MXFE_TX_ENABLE | MXFE_RX_ENABLE); nar &= ~(MXFE_TX_ENABLE | MXFE_RX_ENABLE); nar &= ~(MXFE_NAR_FDX | MXFE_NAR_PORTSEL | MXFE_NAR_SCR | MXFE_NAR_SPEED); tctl &= ~MXFE_TCTL_ANE; if (mxfep->mxfe_adv_100fdx) { nar |= MXFE_NAR_PORTSEL | MXFE_NAR_PCS | MXFE_NAR_SCR; nar |= MXFE_NAR_FDX; } else if (mxfep->mxfe_adv_100hdx) { nar |= MXFE_NAR_PORTSEL | MXFE_NAR_PCS | MXFE_NAR_SCR; } else if (mxfep->mxfe_adv_10fdx) { nar |= MXFE_NAR_FDX | MXFE_NAR_SPEED; } else { /* mxfep->mxfe_adv_10hdx */ nar |= MXFE_NAR_SPEED; } PUTCSR(mxfep, MXFE_CSR_NAR, nar); PUTCSR(mxfep, MXFE_CSR_TCTL, tctl); if (restart) { nar |= restart; PUTCSR(mxfep, MXFE_CSR_NAR, nar); } /* Macronix initializations from Bolo Tsai */ PUTCSR(mxfep, MXFE_CSR_MXMAGIC, 0x0b2c0000); PUTCSR(mxfep, MXFE_CSR_ACOMP, 0x11000); } else { mxfe_startnway(mxfep); } PUTCSR(mxfep, MXFE_CSR_TIMER, MXFE_TIMER_LOOP | (MXFE_LINKTIMER * 1000 / MXFE_TIMER_USEC)); } /* * MII management. */ static void mxfe_phyinitmii(mxfe_t *mxfep) { unsigned phyaddr; unsigned bmcr; unsigned bmsr; unsigned anar; unsigned phyidr1; unsigned phyidr2; int retries; int force; int cnt; int validmode; mxfep->mxfe_phyaddr = -1; /* search for first PHY we can find */ for (phyaddr = 0; phyaddr < 32; phyaddr++) { bmcr = mxfe_miiread(mxfep, phyaddr, MII_REG_BMSR); if ((bmcr != 0) && (bmcr != 0xffff)) { mxfep->mxfe_phyaddr = phyaddr; } } phyidr1 = mxfe_miiread(mxfep, phyaddr, MII_REG_PHYIDR1); phyidr2 = mxfe_miiread(mxfep, phyaddr, MII_REG_PHYIDR2); DBG(MXFE_DPHY, "phy at %d: %x,%x", phyaddr, phyidr1, phyidr2); DBG(MXFE_DPHY, "bmsr = %x", mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_BMSR)); DBG(MXFE_DPHY, "anar = %x", mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_ANAR)); DBG(MXFE_DPHY, "anlpar = %x", mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_ANLPAR)); DBG(MXFE_DPHY, "aner = %x", mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_ANER)); DBG(MXFE_DPHY, "resetting phy"); /* we reset the phy block */ mxfe_miiwrite(mxfep, phyaddr, MII_REG_BMCR, MII_BMCR_RESET); /* * wait for it to complete -- 500usec is still to short to * bother getting the system clock involved. */ drv_usecwait(500); for (retries = 0; retries < 10; retries++) { if (mxfe_miiread(mxfep, phyaddr, MII_REG_BMCR) & MII_BMCR_RESET) { drv_usecwait(500); continue; } break; } if (retries == 100) { mxfe_error(mxfep->mxfe_dip, "timeout waiting on phy to reset"); return; } DBG(MXFE_DPHY, "phy reset complete"); bmsr = mxfe_miiread(mxfep, phyaddr, MII_REG_BMSR); bmcr = mxfe_miiread(mxfep, phyaddr, MII_REG_BMCR); anar = mxfe_miiread(mxfep, phyaddr, MII_REG_ANAR); anar &= ~(MII_ANEG_100BT4 | MII_ANEG_100FDX | MII_ANEG_100HDX | MII_ANEG_10FDX | MII_ANEG_10HDX); force = 0; validmode = 0; /* disable modes not supported in hardware */ if (!(bmsr & MII_BMSR_100BT4)) { mxfep->mxfe_adv_100T4 = 0; } else { validmode = MII_ANEG_100BT4; } if (!(bmsr & MII_BMSR_100FDX)) { mxfep->mxfe_adv_100fdx = 0; } else { validmode = MII_ANEG_100FDX; } if (!(bmsr & MII_BMSR_100HDX)) { mxfep->mxfe_adv_100hdx = 0; } else { validmode = MII_ANEG_100HDX; } if (!(bmsr & MII_BMSR_10FDX)) { mxfep->mxfe_adv_10fdx = 0; } else { validmode = MII_ANEG_10FDX; } if (!(bmsr & MII_BMSR_10HDX)) { mxfep->mxfe_adv_10hdx = 0; } else { validmode = MII_ANEG_10HDX; } if (!(bmsr & MII_BMSR_ANA)) { mxfep->mxfe_adv_aneg = 0; force = 1; } cnt = 0; if (mxfep->mxfe_adv_100T4) { anar |= MII_ANEG_100BT4; cnt++; } if (mxfep->mxfe_adv_100fdx) { anar |= MII_ANEG_100FDX; cnt++; } if (mxfep->mxfe_adv_100hdx) { anar |= MII_ANEG_100HDX; cnt++; } if (mxfep->mxfe_adv_10fdx) { anar |= MII_ANEG_10FDX; cnt++; } if (mxfep->mxfe_adv_10hdx) { anar |= MII_ANEG_10HDX; cnt++; } /* * Make certain at least one valid link mode is selected. */ if (!cnt) { char *s; mxfe_error(mxfep->mxfe_dip, "No valid link mode selected."); switch (validmode) { case MII_ANEG_100BT4: s = "100 Base T4"; mxfep->mxfe_adv_100T4 = 1; break; case MII_ANEG_100FDX: s = "100 Mbps Full-Duplex"; mxfep->mxfe_adv_100fdx = 1; break; case MII_ANEG_100HDX: s = "100 Mbps Half-Duplex"; mxfep->mxfe_adv_100hdx = 1; break; case MII_ANEG_10FDX: s = "10 Mbps Full-Duplex"; mxfep->mxfe_adv_10fdx = 1; break; case MII_ANEG_10HDX: s = "10 Mbps Half-Duplex"; mxfep->mxfe_adv_10hdx = 1; break; default: s = "unknown"; break; } anar |= validmode; mxfe_error(mxfep->mxfe_dip, "Falling back to %s mode.", s); } if ((mxfep->mxfe_adv_aneg) && (bmsr & MII_BMSR_ANA)) { DBG(MXFE_DPHY, "using autoneg mode"); bmcr = (MII_BMCR_ANEG | MII_BMCR_RANEG); } else { DBG(MXFE_DPHY, "using forced mode"); force = 1; if (mxfep->mxfe_adv_100fdx) { bmcr = (MII_BMCR_SPEED | MII_BMCR_DUPLEX); } else if (mxfep->mxfe_adv_100hdx) { bmcr = MII_BMCR_SPEED; } else if (mxfep->mxfe_adv_10fdx) { bmcr = MII_BMCR_DUPLEX; } else { /* 10HDX */ bmcr = 0; } } mxfep->mxfe_forcephy = 0; DBG(MXFE_DPHY, "programming anar to 0x%x", anar); mxfe_miiwrite(mxfep, phyaddr, MII_REG_ANAR, anar); DBG(MXFE_DPHY, "programming bmcr to 0x%x", bmcr); mxfe_miiwrite(mxfep, phyaddr, MII_REG_BMCR, bmcr); /* * schedule a query of the link status */ PUTCSR(mxfep, MXFE_CSR_TIMER, MXFE_TIMER_LOOP | (MXFE_LINKTIMER * 1000 / MXFE_TIMER_USEC)); } static void mxfe_reportlink(mxfe_t *mxfep) { int changed = 0; if (mxfep->mxfe_ifspeed != mxfep->mxfe_lastifspeed) { mxfep->mxfe_lastifspeed = mxfep->mxfe_ifspeed; changed++; } if (mxfep->mxfe_duplex != mxfep->mxfe_lastduplex) { mxfep->mxfe_lastduplex = mxfep->mxfe_duplex; changed++; } if (mxfep->mxfe_linkup && changed) { char *media; switch (mxfep->mxfe_media) { case GLDM_TP: media = "Twisted Pair"; break; case GLDM_PHYMII: media = "MII"; break; case GLDM_FIBER: media = "Fiber"; break; default: media = "Unknown"; break; } cmn_err(CE_NOTE, mxfep->mxfe_ifspeed ? "%s%d: %s %d Mbps %s-Duplex (%s) Link Up" : "%s%d: Unknown %s MII Link Up", ddi_driver_name(mxfep->mxfe_dip), ddi_get_instance(mxfep->mxfe_dip), mxfep->mxfe_forcephy ? "Forced" : "Auto-Negotiated", (int)(mxfep->mxfe_ifspeed / 1000000), mxfep->mxfe_duplex == GLD_DUPLEX_FULL ? "Full" : "Half", media); mxfep->mxfe_lastlinkdown = 0; } else if (mxfep->mxfe_linkup) { mxfep->mxfe_lastlinkdown = 0; } else { /* link lost, warn once every 10 seconds */ if ((ddi_get_time() - mxfep->mxfe_lastlinkdown) > 10) { /* we've lost link, only warn on transition */ mxfe_error(mxfep->mxfe_dip, "Link Down -- Cable Problem?"); mxfep->mxfe_lastlinkdown = ddi_get_time(); } } } static void mxfe_checklink(mxfe_t *mxfep) { switch (MXFE_MODEL(mxfep)) { case MXFE_MODEL_98713A: mxfe_checklinkmii(mxfep); break; default: mxfe_checklinknway(mxfep); } } static void mxfe_checklinkmii(mxfe_t *mxfep) { /* read MII state registers */ ushort bmsr; ushort bmcr; ushort anar; ushort anlpar; ushort aner; mxfep->mxfe_media = GLDM_PHYMII; /* read this twice, to clear latched link state */ bmsr = mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_BMSR); bmsr = mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_BMSR); bmcr = mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_BMCR); anar = mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_ANAR); anlpar = mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_ANLPAR); aner = mxfe_miiread(mxfep, mxfep->mxfe_phyaddr, MII_REG_ANER); mxfep->mxfe_bmsr = bmsr; mxfep->mxfe_anlpar = anlpar; mxfep->mxfe_aner = aner; if (bmsr & MII_BMSR_RFAULT) { mxfe_error(mxfep->mxfe_dip, "Remote fault detected."); } if (bmsr & MII_BMSR_JABBER) { mxfe_error(mxfep->mxfe_dip, "Jabber condition detected."); } if ((bmsr & MII_BMSR_LINK) == 0) { /* no link */ mxfep->mxfe_ifspeed = 0; mxfep->mxfe_duplex = GLD_DUPLEX_UNKNOWN; mxfep->mxfe_linkup = 0; mxfe_reportlink(mxfep); return; } DBG(MXFE_DCHATTY, "link up!"); mxfep->mxfe_lastlinkdown = 0; mxfep->mxfe_linkup = 1; if (!(bmcr & MII_BMCR_ANEG)) { /* forced mode */ if (bmcr & MII_BMCR_SPEED) { mxfep->mxfe_ifspeed = 100000000; } else { mxfep->mxfe_ifspeed = 10000000; } if (bmcr & MII_BMCR_DUPLEX) { mxfep->mxfe_duplex = GLD_DUPLEX_FULL; } else { mxfep->mxfe_duplex = GLD_DUPLEX_HALF; } } else if ((!(bmsr & MII_BMSR_ANA)) || (!(bmsr & MII_BMSR_ANC))) { mxfep->mxfe_ifspeed = 0; mxfep->mxfe_duplex = GLD_DUPLEX_UNKNOWN; } else if (anar & anlpar & MII_ANEG_100BT4) { mxfep->mxfe_ifspeed = 100000000; mxfep->mxfe_duplex = GLD_DUPLEX_HALF; } else if (anar & anlpar & MII_ANEG_100FDX) { mxfep->mxfe_ifspeed = 100000000; mxfep->mxfe_duplex = GLD_DUPLEX_FULL; } else if (anar & anlpar & MII_ANEG_100HDX) { mxfep->mxfe_ifspeed = 100000000; mxfep->mxfe_duplex = GLD_DUPLEX_HALF; } else if (anar & anlpar & MII_ANEG_10FDX) { mxfep->mxfe_ifspeed = 10000000; mxfep->mxfe_duplex = GLD_DUPLEX_FULL; } else if (anar & anlpar & MII_ANEG_10HDX) { mxfep->mxfe_ifspeed = 10000000; mxfep->mxfe_duplex = GLD_DUPLEX_HALF; } else { mxfep->mxfe_ifspeed = 0; mxfep->mxfe_duplex = GLD_DUPLEX_UNKNOWN; } mxfe_reportlink(mxfep); } static void mxfe_miitristate(mxfe_t *mxfep) { unsigned val = MXFE_SROM_WRITE | MXFE_MII_CONTROL; PUTCSR(mxfep, MXFE_CSR_SPR, val); drv_usecwait(1); PUTCSR(mxfep, MXFE_CSR_SPR, val | MXFE_MII_CLOCK); drv_usecwait(1); } static void mxfe_miiwritebit(mxfe_t *mxfep, int bit) { unsigned val = bit ? MXFE_MII_DOUT : 0; PUTCSR(mxfep, MXFE_CSR_SPR, val); drv_usecwait(1); PUTCSR(mxfep, MXFE_CSR_SPR, val | MXFE_MII_CLOCK); drv_usecwait(1); } static int mxfe_miireadbit(mxfe_t *mxfep) { unsigned val = MXFE_MII_CONTROL | MXFE_SROM_READ; int bit; PUTCSR(mxfep, MXFE_CSR_SPR, val); drv_usecwait(1); bit = (GETCSR(mxfep, MXFE_CSR_SPR) & MXFE_MII_DIN) ? 1 : 0; PUTCSR(mxfep, MXFE_CSR_SPR, val | MXFE_MII_CLOCK); drv_usecwait(1); return (bit); } static unsigned mxfe_miiread(mxfe_t *mxfep, int phy, int reg) { switch (MXFE_MODEL(mxfep)) { case MXFE_MODEL_98713A: return (mxfe_miiread98713(mxfep, phy, reg)); default: return (0xffff); } } static unsigned mxfe_miireadgeneral(mxfe_t *mxfep, int phy, int reg) { unsigned value = 0; int i; /* send the 32 bit preamble */ for (i = 0; i < 32; i++) { mxfe_miiwritebit(mxfep, 1); } /* send the start code - 01b */ mxfe_miiwritebit(mxfep, 0); mxfe_miiwritebit(mxfep, 1); /* send the opcode for read, - 10b */ mxfe_miiwritebit(mxfep, 1); mxfe_miiwritebit(mxfep, 0); /* next we send the 5 bit phy address */ for (i = 0x10; i > 0; i >>= 1) { mxfe_miiwritebit(mxfep, (phy & i) ? 1 : 0); } /* the 5 bit register address goes next */ for (i = 0x10; i > 0; i >>= 1) { mxfe_miiwritebit(mxfep, (reg & i) ? 1 : 0); } /* turnaround - tristate followed by logic 0 */ mxfe_miitristate(mxfep); mxfe_miiwritebit(mxfep, 0); /* read the 16 bit register value */ for (i = 0x8000; i > 0; i >>= 1) { value <<= 1; value |= mxfe_miireadbit(mxfep); } mxfe_miitristate(mxfep); return (value); } static unsigned mxfe_miiread98713(mxfe_t *mxfep, int phy, int reg) { unsigned nar; unsigned retval; /* * like an ordinary MII, but we have to turn off portsel while * we read it. */ nar = GETCSR(mxfep, MXFE_CSR_NAR); PUTCSR(mxfep, MXFE_CSR_NAR, nar & ~MXFE_NAR_PORTSEL); retval = mxfe_miireadgeneral(mxfep, phy, reg); PUTCSR(mxfep, MXFE_CSR_NAR, nar); return (retval); } static void mxfe_miiwrite(mxfe_t *mxfep, int phy, int reg, ushort val) { switch (MXFE_MODEL(mxfep)) { case MXFE_MODEL_98713A: mxfe_miiwrite98713(mxfep, phy, reg, val); break; default: break; } } static void mxfe_miiwritegeneral(mxfe_t *mxfep, int phy, int reg, ushort val) { int i; /* send the 32 bit preamble */ for (i = 0; i < 32; i++) { mxfe_miiwritebit(mxfep, 1); } /* send the start code - 01b */ mxfe_miiwritebit(mxfep, 0); mxfe_miiwritebit(mxfep, 1); /* send the opcode for write, - 01b */ mxfe_miiwritebit(mxfep, 0); mxfe_miiwritebit(mxfep, 1); /* next we send the 5 bit phy address */ for (i = 0x10; i > 0; i >>= 1) { mxfe_miiwritebit(mxfep, (phy & i) ? 1 : 0); } /* the 5 bit register address goes next */ for (i = 0x10; i > 0; i >>= 1) { mxfe_miiwritebit(mxfep, (reg & i) ? 1 : 0); } /* turnaround - tristate followed by logic 0 */ mxfe_miitristate(mxfep); mxfe_miiwritebit(mxfep, 0); /* now write out our data (16 bits) */ for (i = 0x8000; i > 0; i >>= 1) { mxfe_miiwritebit(mxfep, (val & i) ? 1 : 0); } /* idle mode */ mxfe_miitristate(mxfep); } static void mxfe_miiwrite98713(mxfe_t *mxfep, int phy, int reg, ushort val) { unsigned nar; /* * like an ordinary MII, but we have to turn off portsel while * we read it. */ nar = GETCSR(mxfep, MXFE_CSR_NAR); PUTCSR(mxfep, MXFE_CSR_NAR, nar & ~MXFE_NAR_PORTSEL); mxfe_miiwritegeneral(mxfep, phy, reg, val); PUTCSR(mxfep, MXFE_CSR_NAR, nar); } static void mxfe_setrxfilt(mxfe_t *mxfep) { uint32_t reenable; uint32_t nar; uint32_t ier; uint32_t status; mxfe_desc_t *tmdp; int i; if (mxfep->mxfe_flags & MXFE_SUSPENDED) { /* don't touch a suspended interface */ return; } DBG(MXFE_DMACID, "preparing setup frame"); /* stop both transmitter and receiver */ nar = GETCSR(mxfep, MXFE_CSR_NAR); reenable = nar & (MXFE_TX_ENABLE | MXFE_RX_ENABLE); nar &= ~reenable; DBG(MXFE_DMACID, "setting NAR to %x", nar); PUTCSR(mxfep, MXFE_CSR_NAR, nar); switch (mxfep->mxfe_promisc) { case GLD_MAC_PROMISC_PHYS: DBG(MXFE_DMACID, "setting promiscuous"); CLRBIT(mxfep, MXFE_CSR_NAR, MXFE_RX_MULTI); SETBIT(mxfep, MXFE_CSR_NAR, MXFE_RX_PROMISC); break; case GLD_MAC_PROMISC_MULTI: DBG(MXFE_DMACID, "setting allmulti"); CLRBIT(mxfep, MXFE_CSR_NAR, MXFE_RX_PROMISC); SETBIT(mxfep, MXFE_CSR_NAR, MXFE_RX_MULTI); break; case GLD_MAC_PROMISC_NONE: CLRBIT(mxfep, MXFE_CSR_NAR, MXFE_RX_PROMISC | MXFE_RX_MULTI); break; } /* turn off tx interrupts */ ier = GETCSR(mxfep, MXFE_CSR_IER); DBG(MXFE_DMACID, "setting IER to %x", ier & ~(MXFE_INT_TXNOBUF|MXFE_INT_TXOK)); PUTCSR(mxfep, MXFE_CSR_IER, (ier & ~(MXFE_INT_TXNOBUF|MXFE_INT_TXOK))); /* * reorder the transmit packets so when we restart the first tx * packet is in slot zero. */ mxfe_txreorder(mxfep); tmdp = mxfep->mxfe_setup_desc; PUTDESC(mxfep, tmdp->desc_control, MXFE_TXCTL_FIRST | MXFE_TXCTL_LAST | MXFE_SETUP_LEN | MXFE_TXCTL_SETUP | MXFE_TXCTL_HASHPERF | MXFE_TXCTL_ENDRING); PUTDESC(mxfep, tmdp->desc_buffer1, mxfep->mxfe_setup_bufpaddr); PUTDESC(mxfep, tmdp->desc_buffer2, 0); PUTDESC(mxfep, tmdp->desc_status, MXFE_TXSTAT_OWN); ddi_dma_sync(mxfep->mxfe_setup_descdmah, 0, 0, DDI_DMA_SYNC_FORDEV); ddi_dma_sync(mxfep->mxfe_setup_bufdmah, 0, 0, DDI_DMA_SYNC_FORDEV); PUTCSR(mxfep, MXFE_CSR_TDB, mxfep->mxfe_setup_descpaddr); PUTCSR(mxfep, MXFE_CSR_NAR, nar | MXFE_TX_ENABLE); /* bang the chip */ PUTCSR(mxfep, MXFE_CSR_TDR, 0xffffffffU); DBG(MXFE_DMACID, "sent setup frame (0x%p)", mxfep->mxfe_setup_buf); /* * wait up to 100 msec for setup frame to get loaded -- it * typically should happen much sooner. */ for (i = 0; i < 100000; i += 100) { ddi_dma_sync(mxfep->mxfe_setup_descdmah, 0, sizeof (unsigned), DDI_DMA_SYNC_FORKERNEL); status = GETDESC(mxfep, tmdp->desc_status); if ((status & MXFE_TXSTAT_OWN) == 0) { break; } drv_usecwait(10); } DBG(status & MXFE_TXSTAT_OWN ? MXFE_DWARN : MXFE_DMACID, "%s setup frame after %d usec", status & MXFE_TXSTAT_OWN ? "timed out" : "processed", i); PUTCSR(mxfep, MXFE_CSR_NAR, nar); PUTCSR(mxfep, MXFE_CSR_TDB, mxfep->mxfe_desc_txpaddr); PUTCSR(mxfep, MXFE_CSR_IER, ier); PUTCSR(mxfep, MXFE_CSR_NAR, nar | reenable); if (reenable & MXFE_TX_ENABLE) { PUTCSR(mxfep, MXFE_CSR_TDR, 0xffffffffU); } if (reenable & MXFE_RX_ENABLE) { PUTCSR(mxfep, MXFE_CSR_RDR, 0xffffffffU); } } /* * Multicast support. */ /* * Calculates the CRC of the multicast address, the lower 6 bits of * which are used to set up the multicast filter. */ static unsigned mxfe_etherhashle(uchar_t *addrp) { unsigned hash = 0xffffffffU; int byte; int bit; uchar_t curr; static unsigned poly = 0xedb88320; /* little endian version of hashing code */ for (byte = 0; byte < ETHERADDRL; byte++) { curr = addrp[byte]; for (bit = 0; bit < 8; bit++, curr >>= 1) { hash = (hash >> 1) ^ (((hash ^ curr) & 1) ? poly : 0); } } return (hash); } static int mxfe_start(gld_mac_info_t *macinfo) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; /* grab exclusive access to the card */ mutex_enter(&mxfep->mxfe_intrlock); mutex_enter(&mxfep->mxfe_xmtlock); if (mxfe_startmac(mxfep) == GLD_SUCCESS) { mxfep->mxfe_flags |= MXFE_RUNNING; } mutex_exit(&mxfep->mxfe_xmtlock); mutex_exit(&mxfep->mxfe_intrlock); return (GLD_SUCCESS); } static int mxfe_stop(gld_mac_info_t *macinfo) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; /* exclusive access to the hardware! */ mutex_enter(&mxfep->mxfe_intrlock); mutex_enter(&mxfep->mxfe_xmtlock); mxfe_stopmac(mxfep); mxfep->mxfe_flags &= ~MXFE_RUNNING; mutex_exit(&mxfep->mxfe_xmtlock); mutex_exit(&mxfep->mxfe_intrlock); return (GLD_SUCCESS); } static int mxfe_startmac(mxfe_t *mxfep) { int i; /* FIXME: do the power management thing */ /* verify exclusive access to the card */ ASSERT(mutex_owned(&mxfep->mxfe_intrlock));; ASSERT(mutex_owned(&mxfep->mxfe_xmtlock)); /* stop the card */ CLRBIT(mxfep, MXFE_CSR_NAR, MXFE_TX_ENABLE | MXFE_RX_ENABLE); /* free any pending buffers */ for (i = 0; i < mxfep->mxfe_txring; i++) { if (mxfep->mxfe_txbufs[i]) { mxfe_freebuf(mxfep->mxfe_txbufs[i]); mxfep->mxfe_txbufs[i] = NULL; } } for (i = 0; i < mxfep->mxfe_rxring; i++) { if (mxfep->mxfe_rxbufs[i]) { mxfe_freebuf(mxfep->mxfe_rxbufs[i]); mxfep->mxfe_rxbufs[i] = NULL; } } /* reset the descriptor ring pointers */ mxfep->mxfe_rxcurrent = 0; mxfep->mxfe_txreclaim = 0; mxfep->mxfe_txsend = 0; mxfep->mxfe_txavail = mxfep->mxfe_txring; PUTCSR(mxfep, MXFE_CSR_TDB, mxfep->mxfe_desc_txpaddr); PUTCSR(mxfep, MXFE_CSR_RDB, mxfep->mxfe_desc_rxpaddr); /* * We only do this if we are initiating a hard reset * of the chip, typically at start of day. When we're * just setting promiscuous mode or somesuch, this becomes * wasteful. */ DBG(MXFE_DCHATTY, "phy reset"); mxfe_phyinit(mxfep); /* point hardware at the descriptor rings */ PUTCSR(mxfep, MXFE_CSR_RDB, mxfep->mxfe_desc_rxpaddr); PUTCSR(mxfep, MXFE_CSR_TDB, mxfep->mxfe_desc_txpaddr); /* set up transmit descriptor ring */ for (i = 0; i < mxfep->mxfe_txring; i++) { mxfe_desc_t *tmdp = &mxfep->mxfe_txdescp[i]; unsigned control = 0; if (i + 1 == mxfep->mxfe_txring) { control |= MXFE_TXCTL_ENDRING; } PUTDESC(mxfep, tmdp->desc_status, 0); PUTDESC(mxfep, tmdp->desc_control, control); PUTDESC(mxfep, tmdp->desc_buffer1, 0); PUTDESC(mxfep, tmdp->desc_buffer2, 0); SYNCDESC(mxfep, tmdp, DDI_DMA_SYNC_FORDEV); } /* make the receive buffers available */ for (i = 0; i < mxfep->mxfe_rxring; i++) { mxfe_buf_t *bufp; mxfe_desc_t *rmdp = &mxfep->mxfe_rxdescp[i]; unsigned control; if ((bufp = mxfe_getbuf(mxfep, 1)) == NULL) { /* this should never happen! */ mxfe_error(mxfep->mxfe_dip, "out of buffers!"); return (DDI_FAILURE); } mxfep->mxfe_rxbufs[i] = bufp; control = MXFE_BUFSZ & MXFE_RXCTL_BUFLEN1; if (i + 1 == mxfep->mxfe_rxring) { control |= MXFE_RXCTL_ENDRING; } PUTDESC(mxfep, rmdp->desc_buffer1, bufp->bp_paddr); PUTDESC(mxfep, rmdp->desc_buffer2, 0); PUTDESC(mxfep, rmdp->desc_control, control); PUTDESC(mxfep, rmdp->desc_status, MXFE_RXSTAT_OWN); /* sync the descriptor for the device */ SYNCDESC(mxfep, rmdp, DDI_DMA_SYNC_FORDEV); } DBG(MXFE_DCHATTY, "descriptors setup"); /* clear the lost packet counter (cleared on read) */ (void) GETCSR(mxfep, MXFE_CSR_LPC); /* program tx threshold bits */ CLRBIT(mxfep, MXFE_CSR_NAR, MXFE_NAR_TR | MXFE_NAR_SF); SETBIT(mxfep, MXFE_CSR_NAR, mxfe_txthresh[mxfep->mxfe_txthresh]); /* disable SQE test */ SETBIT(mxfep, MXFE_CSR_NAR, MXFE_NAR_HBD); /* enable interrupts */ mxfe_enableinterrupts(mxfep); /* start the card */ SETBIT(mxfep, MXFE_CSR_NAR, MXFE_TX_ENABLE | MXFE_RX_ENABLE); return (GLD_SUCCESS); } static int mxfe_stopmac(mxfe_t *mxfep) { /* exclusive access to the hardware! */ ASSERT(mutex_owned(&mxfep->mxfe_intrlock)); ASSERT(mutex_owned(&mxfep->mxfe_xmtlock)); /* FIXME: possibly wait for transmits to drain */ /* stop the card */ CLRBIT(mxfep, MXFE_CSR_NAR, MXFE_TX_ENABLE | MXFE_RX_ENABLE); /* stop the on-card timer */ PUTCSR(mxfep, MXFE_CSR_TIMER, 0); /* disable interrupts */ mxfe_disableinterrupts(mxfep); mxfep->mxfe_linkup = 0; mxfep->mxfe_ifspeed = 0; mxfep->mxfe_duplex = GLD_DUPLEX_UNKNOWN; return (GLD_SUCCESS); } /* * Allocate descriptors. */ static int mxfe_allocrings(mxfe_t *mxfep) { int size; int rval; int i; size_t real_len; ddi_dma_cookie_t cookie; uint ncookies; ddi_dma_handle_t dmah; ddi_acc_handle_t acch; mxfep->mxfe_desc_dmahandle = NULL; mxfep->mxfe_desc_acchandle = NULL; size = (mxfep->mxfe_rxring + mxfep->mxfe_txring) * sizeof (mxfe_desc_t); rval = ddi_dma_alloc_handle(mxfep->mxfe_dip, &mxfe_dma_attr, DDI_DMA_SLEEP, 0, &dmah); if (rval != DDI_SUCCESS) { mxfe_error(mxfep->mxfe_dip, "unable to allocate DMA handle for media descriptors"); return (DDI_FAILURE); } rval = ddi_dma_mem_alloc(dmah, size, &mxfe_devattr, DDI_DMA_CONSISTENT, DDI_DMA_SLEEP, 0, &mxfep->mxfe_desc_kaddr, &real_len, &acch); if (rval != DDI_SUCCESS) { mxfe_error(mxfep->mxfe_dip, "unable to allocate DMA memory for media descriptors"); ddi_dma_free_handle(&dmah); return (DDI_FAILURE); } rval = ddi_dma_addr_bind_handle(dmah, NULL, mxfep->mxfe_desc_kaddr, size, DDI_DMA_RDWR | DDI_DMA_CONSISTENT, DDI_DMA_SLEEP, 0, &cookie, &ncookies); if (rval != DDI_DMA_MAPPED) { mxfe_error(mxfep->mxfe_dip, "unable to bind DMA handle for media descriptors"); ddi_dma_mem_free(&acch); ddi_dma_free_handle(&dmah); return (DDI_FAILURE); } /* we take the 32-bit physical address out of the cookie */ mxfep->mxfe_desc_rxpaddr = cookie.dmac_address; mxfep->mxfe_desc_txpaddr = cookie.dmac_address + (sizeof (mxfe_desc_t) * mxfep->mxfe_rxring); DBG(MXFE_DDMA, "rx phys addr = 0x%x", mxfep->mxfe_desc_rxpaddr); DBG(MXFE_DDMA, "tx phys addr = 0x%x", mxfep->mxfe_desc_txpaddr); if (ncookies != 1) { mxfe_error(mxfep->mxfe_dip, "too many DMA cookies for media " "descriptors"); (void) ddi_dma_unbind_handle(mxfep->mxfe_desc_dmahandle); ddi_dma_mem_free(&acch); ddi_dma_free_handle(&dmah); return (DDI_FAILURE); } size = sizeof (mxfe_buf_t *); /* allocate buffer pointers (not the buffers themselves, yet) */ mxfep->mxfe_buftab = kmem_zalloc(mxfep->mxfe_numbufs * size, KM_SLEEP); mxfep->mxfe_txbufs = kmem_zalloc(mxfep->mxfe_txring * size, KM_SLEEP); mxfep->mxfe_rxbufs = kmem_zalloc(mxfep->mxfe_rxring * size, KM_SLEEP); mxfep->mxfe_temp_bufs = kmem_zalloc(mxfep->mxfe_txring * size, KM_SLEEP); /* save off the descriptor handles */ mxfep->mxfe_desc_dmahandle = dmah; mxfep->mxfe_desc_acchandle = acch; /* now allocate the actual buffers */ for (i = 0; i < mxfep->mxfe_numbufs; i++) { mxfe_buf_t *bufp; dmah = NULL; acch = NULL; bufp = kmem_zalloc(sizeof (mxfe_buf_t), KM_SLEEP); if (ddi_dma_alloc_handle(mxfep->mxfe_dip, &mxfe_dma_attr, DDI_DMA_SLEEP, NULL, &dmah) != DDI_SUCCESS) { kmem_free(bufp, sizeof (mxfe_buf_t)); return (DDI_FAILURE); } if (ddi_dma_mem_alloc(dmah, MXFE_BUFSZ, &mxfe_bufattr, DDI_DMA_STREAMING, DDI_DMA_SLEEP, NULL, &bufp->bp_buf, &real_len, &acch) != DDI_SUCCESS) { ddi_dma_free_handle(&dmah); return (DDI_FAILURE); } if (ddi_dma_addr_bind_handle(dmah, NULL, bufp->bp_buf, real_len, DDI_DMA_STREAMING | DDI_DMA_RDWR, DDI_DMA_SLEEP, 0, &cookie, &ncookies) != DDI_DMA_MAPPED) { (void) ddi_dma_mem_free(&acch); ddi_dma_free_handle(&dmah); kmem_free(bufp, sizeof (mxfe_buf_t)); return (DDI_FAILURE); } bufp->bp_mxfep = mxfep; bufp->bp_frtn.free_func = mxfe_freebuf; bufp->bp_frtn.free_arg = (caddr_t)bufp; bufp->bp_dma_handle = dmah; bufp->bp_acc_handle = acch; bufp->bp_paddr = cookie.dmac_address; DBG(MXFE_DDMA, "buf #%d phys addr = 0x%x", i, bufp->bp_paddr); /* stick it in the stack */ mxfep->mxfe_buftab[i] = bufp; } /* set the top of the stack */ mxfep->mxfe_topbuf = mxfep->mxfe_numbufs; /* descriptor pointers */ mxfep->mxfe_rxdescp = (mxfe_desc_t *)mxfep->mxfe_desc_kaddr; mxfep->mxfe_txdescp = mxfep->mxfe_rxdescp + mxfep->mxfe_rxring; mxfep->mxfe_rxcurrent = 0; mxfep->mxfe_txreclaim = 0; mxfep->mxfe_txsend = 0; mxfep->mxfe_txavail = mxfep->mxfe_txring; return (DDI_SUCCESS); } static void mxfe_freerings(mxfe_t *mxfep) { int i; mxfe_buf_t *bufp; ddi_dma_handle_t dmah; ddi_acc_handle_t acch; for (i = 0; i < mxfep->mxfe_numbufs; i++) { bufp = mxfep->mxfe_buftab[i]; if (bufp != NULL) { dmah = bufp->bp_dma_handle; acch = bufp->bp_acc_handle; if (ddi_dma_unbind_handle(dmah) == DDI_SUCCESS) { ddi_dma_mem_free(&acch); ddi_dma_free_handle(&dmah); } else { mxfe_error(mxfep->mxfe_dip, "ddi_dma_unbind_handle failed!"); } kmem_free(bufp, sizeof (mxfe_buf_t)); } } DBG(MXFE_DCHATTY, "freeing buffer pools"); if (mxfep->mxfe_buftab) { kmem_free(mxfep->mxfe_buftab, mxfep->mxfe_numbufs * sizeof (mxfe_buf_t *)); mxfep->mxfe_buftab = NULL; } if (mxfep->mxfe_temp_bufs) { kmem_free(mxfep->mxfe_temp_bufs, mxfep->mxfe_txring * sizeof (mxfe_buf_t *)); mxfep->mxfe_temp_bufs = NULL; } if (mxfep->mxfe_txbufs) { kmem_free(mxfep->mxfe_txbufs, mxfep->mxfe_txring * sizeof (mxfe_buf_t *)); mxfep->mxfe_txbufs = NULL; } if (mxfep->mxfe_rxbufs) { kmem_free(mxfep->mxfe_rxbufs, mxfep->mxfe_rxring * sizeof (mxfe_buf_t *)); mxfep->mxfe_rxbufs = NULL; } } /* * Allocate setup frame. */ static int mxfe_allocsetup(mxfe_t *mxfep) { size_t size; unsigned ncookies; ddi_dma_cookie_t cookie; /* first prepare the descriptor */ size = sizeof (mxfe_desc_t); if (ddi_dma_alloc_handle(mxfep->mxfe_dip, &mxfe_dma_attr, DDI_DMA_SLEEP, 0, &mxfep->mxfe_setup_descdmah) != DDI_SUCCESS) { mxfe_error(mxfep->mxfe_dip, "unable to allocate DMA handle for setup descriptor"); return (DDI_FAILURE); } if (ddi_dma_mem_alloc(mxfep->mxfe_setup_descdmah, size, &mxfe_devattr, DDI_DMA_CONSISTENT, DDI_DMA_SLEEP, 0, (caddr_t *)&mxfep->mxfe_setup_desc, &size, &mxfep->mxfe_setup_descacch) != DDI_SUCCESS) { mxfe_error(mxfep->mxfe_dip, "unable to allocate DMA memory for setup descriptor"); mxfe_freesetup(mxfep); return (DDI_FAILURE); } bzero((void *)mxfep->mxfe_setup_desc, size); if (ddi_dma_addr_bind_handle(mxfep->mxfe_setup_descdmah, NULL, (caddr_t)mxfep->mxfe_setup_desc, size, DDI_DMA_RDWR | DDI_DMA_CONSISTENT, DDI_DMA_SLEEP, 0, &cookie, &ncookies) != DDI_DMA_MAPPED) { mxfe_error(mxfep->mxfe_dip, "unable to bind DMA handle for setup descriptor"); mxfe_freesetup(mxfep); return (DDI_FAILURE); } mxfep->mxfe_setup_descpaddr = cookie.dmac_address; /* then prepare the buffer itself */ size = MXFE_SETUP_LEN; if (ddi_dma_alloc_handle(mxfep->mxfe_dip, &mxfe_dma_attr, DDI_DMA_SLEEP, 0, &mxfep->mxfe_setup_bufdmah) != DDI_SUCCESS) { mxfe_error(mxfep->mxfe_dip, "unable to allocate DMA handle for setup buffer"); return (DDI_FAILURE); } bzero((void *)mxfep->mxfe_setup_buf, size); if (ddi_dma_addr_bind_handle(mxfep->mxfe_setup_bufdmah, NULL, mxfep->mxfe_setup_buf, size, DDI_DMA_RDWR | DDI_DMA_CONSISTENT, DDI_DMA_SLEEP, 0, &cookie, &ncookies) != DDI_DMA_MAPPED) { mxfe_error(mxfep->mxfe_dip, "unable to bind DMA handle for setup buffer"); mxfe_freesetup(mxfep); return (DDI_FAILURE); } mxfep->mxfe_setup_bufpaddr = cookie.dmac_address; return (DDI_SUCCESS); } /* * Free setup frame. */ static void mxfe_freesetup(mxfe_t *mxfep) { DBG(MXFE_DCHATTY, "free descriptor DMA resources"); if (mxfep->mxfe_setup_bufpaddr) { (void) ddi_dma_unbind_handle(mxfep->mxfe_setup_bufdmah); } if (mxfep->mxfe_setup_bufdmah) { ddi_dma_free_handle(&mxfep->mxfe_setup_bufdmah); } if (mxfep->mxfe_setup_descpaddr) { (void) ddi_dma_unbind_handle(mxfep->mxfe_setup_descdmah); } if (mxfep->mxfe_setup_descacch) { ddi_dma_mem_free(&mxfep->mxfe_setup_descacch); } if (mxfep->mxfe_setup_descdmah) { ddi_dma_free_handle(&mxfep->mxfe_setup_descdmah); } } /* * Buffer management. */ static mxfe_buf_t * mxfe_getbuf(mxfe_t *mxfep, int pri) { int top; mxfe_buf_t *bufp; mutex_enter(&mxfep->mxfe_buflock); top = mxfep->mxfe_topbuf; if ((top == 0) || ((pri == 0) && (top < MXFE_RSVDBUFS))) { mutex_exit(&mxfep->mxfe_buflock); return (NULL); } top--; bufp = mxfep->mxfe_buftab[top]; mxfep->mxfe_buftab[top] = NULL; mxfep->mxfe_topbuf = top; mutex_exit(&mxfep->mxfe_buflock); return (bufp); } static void mxfe_freebuf(mxfe_buf_t *bufp) { mxfe_t *mxfep = bufp->bp_mxfep; mutex_enter(&mxfep->mxfe_buflock); mxfep->mxfe_buftab[mxfep->mxfe_topbuf++] = bufp; bufp->bp_flags = 0; mutex_exit(&mxfep->mxfe_buflock); } /* * Interrupt service routine. */ static unsigned mxfe_intr(gld_mac_info_t *macinfo) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; unsigned status = 0; dev_info_t *dip = mxfep->mxfe_dip; int reset = 0; int linkcheck = 0; int wantw; mblk_t *mp = NULL, **mpp; mxfep->mxfe_intr++; mpp = &mp; mutex_enter(&mxfep->mxfe_intrlock); if (mxfep->mxfe_flags & MXFE_SUSPENDED) { /* we cannot receive interrupts! */ mutex_exit(&mxfep->mxfe_intrlock); return (DDI_INTR_UNCLAIMED); } /* check interrupt status bit, did we interrupt? */ status = GETCSR(mxfep, MXFE_CSR_SR); DBG(MXFE_DINTR, "interrupted, status = %x", status); if (!(status & MXFE_INT_ALL)) { DBG(MXFE_DINTR, " not us? status = %x mask=%x all=%x", status, GETCSR(mxfep, MXFE_CSR_IER), MXFE_INT_ALL); if (mxfep->mxfe_intrstat) KIOIP->intrs[KSTAT_INTR_SPURIOUS]++; mutex_exit(&mxfep->mxfe_intrlock); return (DDI_INTR_UNCLAIMED); } /* ack the interrupt */ PUTCSR(mxfep, MXFE_CSR_SR, status & MXFE_INT_ALL); if (mxfep->mxfe_intrstat) KIOIP->intrs[KSTAT_INTR_HARD]++; if (!(mxfep->mxfe_flags & MXFE_RUNNING)) { /* not running, don't touch anything */ DBG(MXFE_DINTR, "int while not running, status = %x", status); mutex_exit(&mxfep->mxfe_intrlock); return (DDI_INTR_CLAIMED); } if ((MXFE_MODEL(mxfep) != MXFE_MODEL_98713A) && ((status & MXFE_INT_ANEG) || (mxfep->mxfe_linkup && (status & (MXFE_INT_10LINK | MXFE_INT_100LINK))))) { /* rescan the link */ DBG(MXFE_DINTR, "link change interrupt!"); linkcheck++; } if (status & MXFE_INT_TXNOBUF) { /* transmit completed */ wantw = 1; } if (status & (MXFE_INT_RXOK | MXFE_INT_RXNOBUF)) { for (;;) { unsigned status; mxfe_desc_t *rmd = &mxfep->mxfe_rxdescp[mxfep->mxfe_rxcurrent]; /* sync it before we look at it */ SYNCDESC(mxfep, rmd, DDI_DMA_SYNC_FORCPU); status = GETDESC(mxfep, rmd->desc_status); if (status & MXFE_RXSTAT_OWN) { /* chip is still chewing on it */ break; } DBG(MXFE_DCHATTY, "reading packet at %d " "(status = 0x%x, length=%d)", mxfep->mxfe_rxcurrent, status, MXFE_RXLENGTH(status)); *mpp = mxfe_read(mxfep, mxfep->mxfe_rxcurrent); if (*mpp) { mpp = &(*mpp)->b_next; } /* give it back to the hardware */ PUTDESC(mxfep, rmd->desc_status, MXFE_RXSTAT_OWN); SYNCDESC(mxfep, rmd, DDI_DMA_SYNC_FORDEV); /* advance to next RMD */ mxfep->mxfe_rxcurrent++; mxfep->mxfe_rxcurrent %= mxfep->mxfe_rxring; /* poll demand the receiver */ PUTCSR(mxfep, MXFE_CSR_RDR, 1); } /* we rec'd a packet, if linkdown, verify */ if (mxfep->mxfe_linkup == 0) { linkcheck++; } DBG(MXFE_DCHATTY, "done receiving packets"); } if (status & MXFE_INT_RXNOBUF) { mxfep->mxfe_norcvbuf++; DBG(MXFE_DINTR, "rxnobuf interrupt!"); } if (status & (MXFE_INT_RXNOBUF | MXFE_INT_RXIDLE)) { /* restart the receiver */ SETBIT(mxfep, MXFE_CSR_NAR, MXFE_RX_ENABLE); } if (status & MXFE_INT_BUSERR) { reset = 1; switch (status & MXFE_BERR_TYPE) { case MXFE_BERR_PARITY: mxfe_error(dip, "PCI parity error detected"); break; case MXFE_BERR_TARGET_ABORT: mxfe_error(dip, "PCI target abort detected"); break; case MXFE_BERR_MASTER_ABORT: mxfe_error(dip, "PCI master abort detected"); break; default: mxfe_error(dip, "Unknown PCI bus error"); break; } } if (status & MXFE_INT_TXUNDERFLOW) { mxfe_error(dip, "TX underflow detected"); if (mxfep->mxfe_txthresh < MXFE_MAX_TXTHRESH) mxfep->mxfe_txthresh++; reset = 1; } if (status & MXFE_INT_TXJABBER) { mxfe_error(dip, "TX jabber detected"); reset = 1; } if (status & MXFE_INT_RXJABBER) { mxfep->mxfe_errrcv++; reset = 1; } /* * Update the missed frame count. */ mxfep->mxfe_missed += (GETCSR(mxfep, MXFE_CSR_LPC) & MXFE_LPC_COUNT); mutex_exit(&mxfep->mxfe_intrlock); /* * Send up packets. We do this outside of the intrlock. */ while (mp) { mblk_t *nmp = mp->b_next; mp->b_next = NULL; gld_recv(macinfo, mp); mp = nmp; } /* * Reclaim transmitted buffers and reschedule any waiters. */ if (wantw) { mutex_enter(&mxfep->mxfe_xmtlock); mxfe_reclaim(mxfep); mutex_exit(&mxfep->mxfe_xmtlock); gld_sched(macinfo); } if (linkcheck) { mutex_enter(&mxfep->mxfe_xmtlock); mxfe_checklink(mxfep); mutex_exit(&mxfep->mxfe_xmtlock); } if (reset) { /* reset the chip in an attempt to fix things */ mutex_enter(&mxfep->mxfe_intrlock); mutex_enter(&mxfep->mxfe_xmtlock); /* * We only reset the chip if we think it shoudl be running. * This test is necessary to close a race with gld_stop. */ if (mxfep->mxfe_flags & MXFE_RUNNING) { mxfe_stopmac(mxfep); mxfe_resetmac(mxfep); mxfe_startmac(mxfep); } mutex_exit(&mxfep->mxfe_xmtlock); mutex_exit(&mxfep->mxfe_intrlock); } return (DDI_INTR_CLAIMED); } static void mxfe_enableinterrupts(mxfe_t *mxfep) { unsigned mask = MXFE_INT_WANTED; /* the following are used in NWay mode */ mask |= MXFE_INT_ANEG; /* only interrupt on loss of link after link up is achieved */ if (mxfep->mxfe_linkup > 0) { mask |= MXFE_INT_10LINK; mask |= MXFE_INT_100LINK; } DBG(MXFE_DINTR, "setting int mask to 0x%x", mask); PUTCSR(mxfep, MXFE_CSR_IER, mask); } static void mxfe_disableinterrupts(mxfe_t *mxfep) { /* disable further interrupts */ PUTCSR(mxfep, MXFE_CSR_IER, 0); /* clear any pending interrupts */ PUTCSR(mxfep, MXFE_CSR_SR, MXFE_INT_ALL); } static int mxfe_send(gld_mac_info_t *macinfo, mblk_t *mp) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; int len; mxfe_buf_t *bufp; mxfe_desc_t *tmdp; unsigned control; /* if the interface is suspended, put it back on the queue */ if ((mxfep->mxfe_flags & MXFE_RUNNING) == 0) { return (GLD_NORESOURCES); } len = mxfe_msgsize(mp); if (len > ETHERMAX) { mxfep->mxfe_errxmt++; DBG(MXFE_DWARN, "output packet too long!"); return (GLD_BADARG); } /* grab a transmit buffer */ if ((bufp = mxfe_getbuf(mxfep, 1)) == NULL) { SETBIT(mxfep, MXFE_CSR_IER, MXFE_INT_TXNOBUF); DBG(MXFE_DXMIT, "no buffer available"); return (GLD_NORESOURCES); } bufp->bp_len = len; /* prepare the buffer */ if (mp->b_cont == NULL) { /* single mblk, easy fastpath case */ bcopy(mp->b_rptr, (char *)bufp->bp_buf, len); } else { /* chained mblks, use a for-loop */ mblk_t *bp = mp; char *dest = (char *)bufp->bp_buf; while (bp != NULL) { int n = MBLKL(bp); bcopy(bp->b_rptr, dest, n); dest += n; bp = bp->b_cont; } } DBG(MXFE_DCHATTY, "syncing mp = 0x%p, buf 0x%p, len %d", mp, bufp->bp_buf, len); /* sync the buffer for the device */ SYNCBUF(bufp, len, DDI_DMA_SYNC_FORDEV); /* acquire transmit lock */ mutex_enter(&mxfep->mxfe_xmtlock); /* if tx buffers are running low, try to get some more */ if (mxfep->mxfe_txavail < MXFE_RECLAIM) { mxfe_reclaim(mxfep); } if (mxfep->mxfe_txavail == 0) { /* no more tmds */ SETBIT(mxfep, MXFE_CSR_IER, MXFE_INT_TXNOBUF); mutex_exit(&mxfep->mxfe_xmtlock); mxfe_freebuf(bufp); DBG(MXFE_DXMIT, "out of tmds"); return (GLD_NORESOURCES); } freemsg(mp); mp = NULL; mxfep->mxfe_txavail--; tmdp = &mxfep->mxfe_txdescp[mxfep->mxfe_txsend]; control = MXFE_TXCTL_FIRST | MXFE_TXCTL_LAST | (MXFE_TXCTL_BUFLEN1 & len) | MXFE_TXCTL_INTCMPLTE; if (mxfep->mxfe_txsend + 1 == mxfep->mxfe_txring) { control |= MXFE_TXCTL_ENDRING; } PUTDESC(mxfep, tmdp->desc_control, control); PUTDESC(mxfep, tmdp->desc_buffer1, bufp->bp_paddr); PUTDESC(mxfep, tmdp->desc_buffer2, 0); PUTDESC(mxfep, tmdp->desc_status, MXFE_TXSTAT_OWN); mxfep->mxfe_txbufs[mxfep->mxfe_txsend] = bufp; /* sync the descriptor out to the device */ SYNCDESC(mxfep, tmdp, DDI_DMA_SYNC_FORDEV); /* update the ring pointer */ mxfep->mxfe_txsend++; mxfep->mxfe_txsend %= mxfep->mxfe_txring; /* wake up the chip */ PUTCSR(mxfep, MXFE_CSR_TDR, 0xffffffffU); mutex_exit(&mxfep->mxfe_xmtlock); return (GLD_SUCCESS); } /* * This moves all tx descriptors so that the first descriptor in the * ring is the first packet to transmit. The transmitter must be idle * when this is called. This is performed when doing a setup frame, * to ensure that when we restart we are able to continue transmitting * packets without dropping any. */ static void mxfe_txreorder(mxfe_t *mxfep) { int num; int i, j; mxfe_desc_t *tmdp; num = mxfep->mxfe_txring - mxfep->mxfe_txavail; j = mxfep->mxfe_txreclaim; for (i = 0; i < num; i++) { tmdp = &mxfep->mxfe_txdescp[j]; mxfep->mxfe_temp_bufs[i] = mxfep->mxfe_txbufs[j]; mxfep->mxfe_txbufs[j] = NULL; /* clear the ownership bit */ PUTDESC(mxfep, tmdp->desc_status, 0), j++; j %= mxfep->mxfe_txring; } for (i = 0; i < num; i++) { mxfe_buf_t *bufp = mxfep->mxfe_temp_bufs[i]; unsigned control; mxfep->mxfe_txbufs[i] = bufp; tmdp = &mxfep->mxfe_txdescp[i]; control = MXFE_TXCTL_FIRST | MXFE_TXCTL_LAST | (MXFE_TXCTL_BUFLEN1 & bufp->bp_len) | MXFE_TXCTL_INTCMPLTE; if (i + 1 == mxfep->mxfe_txring) { control |= MXFE_TXCTL_ENDRING; } PUTDESC(mxfep, tmdp->desc_control, control); PUTDESC(mxfep, tmdp->desc_buffer1, bufp->bp_paddr); PUTDESC(mxfep, tmdp->desc_buffer2, 0); PUTDESC(mxfep, tmdp->desc_status, MXFE_TXSTAT_OWN); } mxfep->mxfe_txsend = i; mxfep->mxfe_txreclaim = 0; } /* * Reclaim buffers that have completed transmission. */ static void mxfe_reclaim(mxfe_t *mxfep) { mxfe_desc_t *tmdp; int freed = 0; if ((mxfep->mxfe_flags & MXFE_RUNNING) == 0) return; for (;;) { unsigned status; mxfe_buf_t *bufp; if (mxfep->mxfe_txavail == mxfep->mxfe_txring) { /* * We've emptied the ring, so we don't need to * know about it again until the ring fills up * next time. (This logic is required because * we only want to have this interrupt enabled * when we run out of space in the ring; this * significantly reduces the number interrupts * required to transmit.) */ CLRBIT(mxfep, MXFE_CSR_IER, MXFE_INT_TXNOBUF); break; } tmdp = &mxfep->mxfe_txdescp[mxfep->mxfe_txreclaim]; bufp = mxfep->mxfe_txbufs[mxfep->mxfe_txreclaim]; /* sync it before we read it */ SYNCDESC(mxfep, tmdp, DDI_DMA_SYNC_FORCPU); status = GETDESC(mxfep, tmdp->desc_status); if (status & MXFE_TXSTAT_OWN) { /* chip is still working on it, we're done */ break; } /* update statistics */ if (status & MXFE_TXSTAT_TXERR) { mxfep->mxfe_errxmt++; } if (status & MXFE_TXSTAT_JABBER) { /* transmit jabber timeout */ DBG(MXFE_DXMIT, "tx jabber!"); mxfep->mxfe_macxmt_errors++; } if (status & (MXFE_TXSTAT_CARRLOST | MXFE_TXSTAT_NOCARR)) { DBG(MXFE_DXMIT, "no carrier!"); mxfe_checklink(mxfep); mxfep->mxfe_carrier_errors++; } if (status & MXFE_TXSTAT_UFLOW) { DBG(MXFE_DXMIT, "tx underflow!"); mxfep->mxfe_underflow++; mxfep->mxfe_macxmt_errors++; } /* only count SQE errors if the test is not disabled */ if ((status & MXFE_TXSTAT_SQE) && ((GETCSR(mxfep, MXFE_CSR_NAR) & MXFE_NAR_HBD) == 0)) { mxfep->mxfe_sqe_errors++; mxfep->mxfe_macxmt_errors++; } if (status & MXFE_TXSTAT_DEFER) { mxfep->mxfe_defer_xmts++; } /* collision counting */ if (status & MXFE_TXSTAT_LATECOL) { DBG(MXFE_DXMIT, "tx late collision!"); mxfep->mxfe_tx_late_collisions++; mxfep->mxfe_collisions++; } else if (status & MXFE_TXSTAT_EXCOLL) { DBG(MXFE_DXMIT, "tx excessive collisions!"); mxfep->mxfe_ex_collisions++; mxfep->mxfe_collisions += 16; } else if (MXFE_TXCOLLCNT(status) == 1) { mxfep->mxfe_collisions++; mxfep->mxfe_first_collisions++; } else if (MXFE_TXCOLLCNT(status)) { mxfep->mxfe_collisions += MXFE_TXCOLLCNT(status); mxfep->mxfe_multi_collisions += MXFE_TXCOLLCNT(status); } /* release the buffer */ mxfe_freebuf(bufp); mxfep->mxfe_txbufs[mxfep->mxfe_txreclaim] = NULL; mxfep->mxfe_txavail++; mxfep->mxfe_txreclaim++; mxfep->mxfe_txreclaim %= mxfep->mxfe_txring; freed++; } } static mblk_t * mxfe_read(mxfe_t *mxfep, int index) { unsigned status; unsigned length; mxfe_desc_t *rmdp; mxfe_buf_t *bufp; int good = 1; mblk_t *mp; rmdp = &mxfep->mxfe_rxdescp[index]; bufp = mxfep->mxfe_rxbufs[index]; status = rmdp->desc_status; length = MXFE_RXLENGTH(status); /* discard the ethernet frame checksum */ length -= ETHERFCSL; if ((status & MXFE_RXSTAT_LAST) == 0) { /* its an oversize packet! ignore it for now */ DBG(MXFE_DRECV, "rx oversize packet"); return (NULL); } if (status & MXFE_RXSTAT_DESCERR) { DBG(MXFE_DRECV, "rx descriptor error " "(index = %d, length = %d)", index, length); mxfep->mxfe_macrcv_errors++; good = 0; } if (status & MXFE_RXSTAT_RUNT) { DBG(MXFE_DRECV, "runt frame (index = %d, length =%d)", index, length); mxfep->mxfe_runt++; mxfep->mxfe_macrcv_errors++; good = 0; } if ((status & MXFE_RXSTAT_FIRST) == 0) { /* * this should also be a toolong, but specifically we * cannot send it up, because we don't have the whole * frame. */ DBG(MXFE_DRECV, "rx fragmented, dropping it"); good = 0; } if (status & (MXFE_RXSTAT_TOOLONG | MXFE_RXSTAT_WATCHDOG)) { DBG(MXFE_DRECV, "rx toolong or watchdog seen"); mxfep->mxfe_toolong_errors++; good = 0; } if (status & MXFE_RXSTAT_COLLSEEN) { DBG(MXFE_DRECV, "rx late collision"); /* this should really be rx_late_collisions */ mxfep->mxfe_collisions++; good = 0; } if (status & MXFE_RXSTAT_DRIBBLE) { DBG(MXFE_DRECV, "rx dribbling"); mxfep->mxfe_align_errors++; good = 0; } if (status & MXFE_RXSTAT_CRCERR) { DBG(MXFE_DRECV, "rx frame crc error"); mxfep->mxfe_fcs_errors++; good = 0; } if (status & MXFE_RXSTAT_OFLOW) { DBG(MXFE_DRECV, "rx fifo overflow"); mxfep->mxfe_overflow++; mxfep->mxfe_macrcv_errors++; good = 0; } if (length > ETHERMAX) { /* chip garbled length in descriptor field? */ DBG(MXFE_DRECV, "packet length too big (%d)", length); mxfep->mxfe_toolong_errors++; good = 0; } /* last fragment in packet, do the bookkeeping */ if (!good) { mxfep->mxfe_errrcv++; /* packet was munged, drop it */ DBG(MXFE_DRECV, "dropping frame, status = 0x%x", status); return (NULL); } /* sync the buffer before we look at it */ SYNCBUF(bufp, length, DDI_DMA_SYNC_FORCPU); /* * FIXME: note, for efficiency we may wish to "loan-up" * buffers, but for now we just use mblks and copy it. */ if ((mp = allocb(length + MXFE_HEADROOM, BPRI_LO)) == NULL) { mxfep->mxfe_norcvbuf++; return (NULL); } /* offset by headroom (should be 2 modulo 4), avoids bcopy in IP */ mp->b_rptr += MXFE_HEADROOM; bcopy((char *)bufp->bp_buf, mp->b_rptr, length); mp->b_wptr = mp->b_rptr + length; return (mp); } /* * Streams and DLPI utility routines. (Duplicated in strsun.h and * sundlpi.h, but we cannot safely use those for DDI compatibility.) */ static int mxfe_msgsize(mblk_t *mp) { int n; for (n = 0; mp != NULL; mp = mp->b_cont) { n += MBLKL(mp); } return (n); } static void mxfe_miocack(queue_t *wq, mblk_t *mp, uint8_t type, int count, int error) { struct iocblk *iocp = (struct iocblk *)mp->b_rptr; /* * For now we assume that there is exactly one reference * to the mblk. If this isn't true, then its an error. */ mp->b_datap->db_type = type; iocp->ioc_count = count; iocp->ioc_error = error; qreply(wq, mp); } static int mxfe_get_stats(gld_mac_info_t *macinfo, struct gld_stats *sp) { mxfe_t *mxfep = (mxfe_t *)macinfo->gldm_private; #if 0 mutex_enter(&mxfep->mxfe_xmtlock); if (mxfep->mxfe_flags & MXFE_RUNNING) { /* reclaim tx bufs to pick up latest stats */ mxfe_reclaim(mxfep); } mutex_exit(&mxfep->mxfe_xmtlock); /* update the missed frame count from CSR */ if (mxfep->mxfe_flags & MXFE_RUNNING) { mxfep->mxfe_missed += (GETCSR(mxfep, MXFE_CSR_LPC) & MXFE_LPC_COUNT); } #endif sp->glds_speed = mxfep->mxfe_ifspeed; sp->glds_media = mxfep->mxfe_media; sp->glds_intr = mxfep->mxfe_intr; sp->glds_norcvbuf = mxfep->mxfe_norcvbuf; sp->glds_errrcv = mxfep->mxfe_errrcv; sp->glds_errxmt = mxfep->mxfe_errxmt; sp->glds_missed = mxfep->mxfe_missed; sp->glds_underflow = mxfep->mxfe_underflow; sp->glds_overflow = mxfep->mxfe_overflow; sp->glds_frame = mxfep->mxfe_align_errors; sp->glds_crc = mxfep->mxfe_fcs_errors; sp->glds_duplex = mxfep->mxfe_duplex; sp->glds_nocarrier = mxfep->mxfe_carrier_errors; sp->glds_collisions = mxfep->mxfe_collisions; sp->glds_excoll = mxfep->mxfe_ex_collisions; sp->glds_xmtlatecoll = mxfep->mxfe_tx_late_collisions; sp->glds_defer = mxfep->mxfe_defer_xmts; sp->glds_dot3_first_coll = mxfep->mxfe_first_collisions; sp->glds_dot3_multi_coll = mxfep->mxfe_multi_collisions; sp->glds_dot3_sqe_error = mxfep->mxfe_sqe_errors; sp->glds_dot3_mac_xmt_error = mxfep->mxfe_macxmt_errors; sp->glds_dot3_mac_rcv_error = mxfep->mxfe_macrcv_errors; sp->glds_dot3_frame_too_long = mxfep->mxfe_toolong_errors; sp->glds_short = mxfep->mxfe_runt; return (GLD_SUCCESS); } /* * NDD support. */ static mxfe_nd_t * mxfe_ndfind(mxfe_t *mxfep, char *name) { mxfe_nd_t *ndp; for (ndp = mxfep->mxfe_ndp; ndp != NULL; ndp = ndp->nd_next) { if (!strcmp(name, ndp->nd_name)) { break; } } return (ndp); } static void mxfe_ndadd(mxfe_t *mxfep, char *name, mxfe_nd_pf_t get, mxfe_nd_pf_t set, intptr_t arg1, intptr_t arg2) { mxfe_nd_t *newndp; mxfe_nd_t **ndpp; newndp = (mxfe_nd_t *)kmem_alloc(sizeof (mxfe_nd_t), KM_SLEEP); newndp->nd_next = NULL; newndp->nd_name = name; newndp->nd_get = get; newndp->nd_set = set; newndp->nd_arg1 = arg1; newndp->nd_arg2 = arg2; /* seek to the end of the list */ for (ndpp = &mxfep->mxfe_ndp; *ndpp; ndpp = &(*ndpp)->nd_next) { } *ndpp = newndp; } static void mxfe_ndempty(mblk_t *mp) { while (mp != NULL) { mp->b_rptr = mp->b_datap->db_base; mp->b_wptr = mp->b_rptr; /* bzero(mp->b_wptr, MBLKSIZE(mp));*/ mp = mp->b_cont; } } static void mxfe_ndget(mxfe_t *mxfep, queue_t *wq, mblk_t *mp) { mblk_t *nmp = mp->b_cont; mxfe_nd_t *ndp; int rv; char name[128]; /* assumption, name will fit in first mblk of chain */ if ((nmp == NULL) || (MBLKSIZE(nmp) < 1)) { mxfe_miocack(wq, mp, M_IOCNAK, 0, EINVAL); return; } if (mxfe_ndparselen(nmp) >= sizeof (name)) { mxfe_miocack(wq, mp, M_IOCNAK, 0, EINVAL); } mxfe_ndparsestring(nmp, name, sizeof (name)); /* locate variable */ if ((ndp = mxfe_ndfind(mxfep, name)) == NULL) { mxfe_miocack(wq, mp, M_IOCNAK, 0, EINVAL); return; } /* locate set callback */ if (ndp->nd_get == NULL) { mxfe_miocack(wq, mp, M_IOCNAK, 0, EACCES); return; } /* clear the result buffer */ mxfe_ndempty(nmp); rv = (*ndp->nd_get)(mxfep, nmp, ndp); if (rv == 0) { /* add final null bytes */ rv = mxfe_ndaddbytes(nmp, "\0", 1); } if (rv == 0) { mxfe_miocack(wq, mp, M_IOCACK, mxfe_msgsize(nmp), 0); } else { mxfe_miocack(wq, mp, M_IOCNAK, 0, rv); } } static void mxfe_ndset(mxfe_t *mxfep, queue_t *wq, mblk_t *mp) { mblk_t *nmp = mp->b_cont; mxfe_nd_t *ndp; int rv; char name[128]; /* assumption, name will fit in first mblk of chain */ if ((nmp == NULL) || (MBLKSIZE(nmp) < 1)) { return; } if (mxfe_ndparselen(nmp) >= sizeof (name)) { mxfe_miocack(wq, mp, M_IOCNAK, 0, EINVAL); } mxfe_ndparsestring(nmp, name, sizeof (name)); /* locate variable */ if ((ndp = mxfe_ndfind(mxfep, name)) == NULL) { mxfe_miocack(wq, mp, M_IOCNAK, 0, EINVAL); return; } /* locate set callback */ if (ndp->nd_set == NULL) { mxfe_miocack(wq, mp, M_IOCNAK, 0, EACCES); return; } rv = (*ndp->nd_set)(mxfep, nmp, ndp); if (rv == 0) { mxfe_miocack(wq, mp, M_IOCACK, 0, 0); } else { mxfe_miocack(wq, mp, M_IOCNAK, 0, rv); } } static int mxfe_ndaddbytes(mblk_t *mp, char *bytes, int cnt) { int index; for (index = 0; index < cnt; index++) { while (mp && (mp->b_wptr >= DB_LIM(mp))) { mp = mp->b_cont; } if (mp == NULL) { return (ENOSPC); } *(mp->b_wptr) = *bytes; mp->b_wptr++; bytes++; } return (0); } static int mxfe_ndaddstr(mblk_t *mp, char *str, int addnull) { /* store the string, plus the terminating null */ return (mxfe_ndaddbytes(mp, str, strlen(str) + (addnull ? 1 : 0))); } static int mxfe_ndparselen(mblk_t *mp) { int len = 0; int done = 0; uchar_t *ptr; while (mp && !done) { for (ptr = mp->b_rptr; ptr < mp->b_wptr; ptr++) { if (!(*ptr)) { done = 1; break; } len++; } mp = mp->b_cont; } return (len); } static int mxfe_ndparseint(mblk_t *mp) { int done = 0; int val = 0; while (mp && !done) { while (mp->b_rptr < mp->b_wptr) { uchar_t ch = *(mp->b_rptr); mp->b_rptr++; if ((ch >= '0') && (ch <= '9')) { val *= 10; val += ch - '0'; } else if (ch == 0) { mxfe_t *mxfep = NULL; DBG(MXFE_DPHY, "parsed value %d", val); return (val); } else { /* parse error, put back rptr */ mp->b_rptr--; return (val); } } mp = mp->b_cont; } return (val); } static void mxfe_ndparsestring(mblk_t *mp, char *buf, int maxlen) { int done = 0; int len = 0; /* ensure null termination */ buf[maxlen - 1] = 0; while (mp && !done) { while (mp->b_rptr < mp->b_wptr) { char ch = *((char *)mp->b_rptr); mp->b_rptr++; buf[len++] = ch; if ((ch == 0) || (len == maxlen)) { return; } } mp = mp->b_cont; } } static int mxfe_ndquestion(mxfe_t *mxfep, mblk_t *mp, mxfe_nd_t *ndp) { for (ndp = mxfep->mxfe_ndp; ndp; ndp = ndp->nd_next) { int rv; char *s; if ((rv = mxfe_ndaddstr(mp, ndp->nd_name, 0)) != 0) { return (rv); } if (ndp->nd_get && ndp->nd_set) { s = " (read and write)"; } else if (ndp->nd_get) { s = " (read only)"; } else if (ndp->nd_set) { s = " (write only)"; } else { s = " (no read or write)"; } if ((rv = mxfe_ndaddstr(mp, s, 1)) != 0) { return (rv); } } return (0); } static int mxfe_ndgetlinkstatus(mxfe_t *mxfep, mblk_t *mp, mxfe_nd_t *ndp) { unsigned val; mutex_enter(&mxfep->mxfe_xmtlock); val = mxfep->mxfe_linkup; mutex_exit(&mxfep->mxfe_xmtlock); return (mxfe_ndaddstr(mp, val ? "1" : "0", 1)); } static int mxfe_ndgetlinkspeed(mxfe_t *mxfep, mblk_t *mp, mxfe_nd_t *ndp) { unsigned val; char buf[16]; mutex_enter(&mxfep->mxfe_xmtlock); val = mxfep->mxfe_ifspeed; mutex_exit(&mxfep->mxfe_xmtlock); /* convert from bps to Mbps */ sprintf(buf, "%d", val / 1000000); return (mxfe_ndaddstr(mp, buf, 1)); } static int mxfe_ndgetlinkmode(mxfe_t *mxfep, mblk_t *mp, mxfe_nd_t *ndp) { unsigned val; mutex_enter(&mxfep->mxfe_xmtlock); val = mxfep->mxfe_duplex; mutex_exit(&mxfep->mxfe_xmtlock); return (mxfe_ndaddstr(mp, val == GLD_DUPLEX_FULL ? "1" : "0", 1)); } static int mxfe_ndgetbit(mxfe_t *mxfep, mblk_t *mp, mxfe_nd_t *ndp) { unsigned val; unsigned mask; val = *(unsigned *)ndp->nd_arg1; mask = (unsigned)ndp->nd_arg2; return (mxfe_ndaddstr(mp, val & mask ? "1" : "0", 1)); } static int mxfe_ndgetadv(mxfe_t *mxfep, mblk_t *mp, mxfe_nd_t *ndp) { unsigned val; mutex_enter(&mxfep->mxfe_xmtlock); val = *((unsigned *)ndp->nd_arg1); mutex_exit(&mxfep->mxfe_xmtlock); return (mxfe_ndaddstr(mp, val ? "1" : "0", 1)); } static int mxfe_ndsetadv(mxfe_t *mxfep, mblk_t *mp, mxfe_nd_t *ndp) { unsigned *ptr = (unsigned *)ndp->nd_arg1; mutex_enter(&mxfep->mxfe_xmtlock); *ptr = (mxfe_ndparseint(mp) ? 1 : 0); /* now reset the phy */ if ((mxfep->mxfe_flags & MXFE_SUSPENDED) == 0) { mxfe_phyinit(mxfep); } mutex_exit(&mxfep->mxfe_xmtlock); return (0); } static void mxfe_ndfini(mxfe_t *mxfep) { mxfe_nd_t *ndp; while ((ndp = mxfep->mxfe_ndp) != NULL) { mxfep->mxfe_ndp = ndp->nd_next; kmem_free(ndp, sizeof (mxfe_nd_t)); } } static void mxfe_ndinit(mxfe_t *mxfep) { mxfe_ndadd(mxfep, "?", mxfe_ndquestion, NULL, 0, 0); mxfe_ndadd(mxfep, "link_status", mxfe_ndgetlinkstatus, NULL, 0, 0); mxfe_ndadd(mxfep, "link_speed", mxfe_ndgetlinkspeed, NULL, 0, 0); mxfe_ndadd(mxfep, "link_mode", mxfe_ndgetlinkmode, NULL, 0, 0); mxfe_ndadd(mxfep, "adv_autoneg_cap", mxfe_ndgetadv, mxfe_ndsetadv, (intptr_t)mxfep->mxfe_adv_aneg, 0); mxfe_ndadd(mxfep, "adv_100T4_cap", mxfe_ndgetadv, mxfe_ndsetadv, (intptr_t)mxfep->mxfe_adv_100T4, 0); mxfe_ndadd(mxfep, "adv_100fdx_cap", mxfe_ndgetadv, mxfe_ndsetadv, (intptr_t)mxfep->mxfe_adv_100fdx, 0); mxfe_ndadd(mxfep, "adv_100hdx_cap", mxfe_ndgetadv, mxfe_ndsetadv, (intptr_t)mxfep->mxfe_adv_100hdx, 0); mxfe_ndadd(mxfep, "adv_10fdx_cap", mxfe_ndgetadv, mxfe_ndsetadv, (intptr_t)mxfep->mxfe_adv_10fdx, 0); mxfe_ndadd(mxfep, "adv_10hdx_cap", mxfe_ndgetadv, mxfe_ndsetadv, (intptr_t)mxfep->mxfe_adv_10hdx, 0); mxfe_ndadd(mxfep, "autoneg_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_bmsr, MII_BMSR_ANA); mxfe_ndadd(mxfep, "100T4_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_bmsr, MII_BMSR_100BT4); mxfe_ndadd(mxfep, "100fdx_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_bmsr, MII_BMSR_100FDX); mxfe_ndadd(mxfep, "100hdx_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_bmsr, MII_BMSR_100HDX); mxfe_ndadd(mxfep, "10fdx_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_bmsr, MII_BMSR_10FDX); mxfe_ndadd(mxfep, "10hdx_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_bmsr, MII_BMSR_10HDX); /* XXX: this needs ANER */ mxfe_ndadd(mxfep, "lp_autoneg_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_aner, MII_ANER_LPANA); mxfe_ndadd(mxfep, "lp_100T4_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_anlpar, MII_ANEG_100BT4); mxfe_ndadd(mxfep, "lp_100fdx_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_anlpar, MII_ANEG_100FDX); mxfe_ndadd(mxfep, "lp_100hdx_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_anlpar, MII_ANEG_100HDX); mxfe_ndadd(mxfep, "lp_10fdx_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_anlpar, MII_ANEG_10HDX); mxfe_ndadd(mxfep, "lp_10hdx_cap", mxfe_ndgetbit, NULL, (intptr_t)&mxfep->mxfe_anlpar, MII_ANEG_10HDX); } /* * Debugging and error reporting. */ static void mxfe_verror(dev_info_t *dip, int level, char *fmt, va_list ap) { char buf[256]; vsprintf(buf, fmt, ap); if (dip) { cmn_err(level, level == CE_CONT ? "%s%d: %s\n" : "%s%d: %s", ddi_driver_name(dip), ddi_get_instance(dip), buf); } else { cmn_err(level, level == CE_CONT ? "%s: %s\n" : "%s: %s", MXFE_IDNAME, buf); } } static void mxfe_error(dev_info_t *dip, char *fmt, ...) { va_list ap; va_start(ap, fmt); mxfe_verror(dip, CE_WARN, fmt, ap); va_end(ap); } #ifdef DEBUG static void mxfe_dprintf(mxfe_t *mxfep, const char *func, int level, char *fmt, ...) { va_list ap; va_start(ap, fmt); if (mxfe_debug & level) { char tag[64]; char buf[256]; if (mxfep && mxfep->mxfe_dip) { sprintf(tag, "%s%d", ddi_driver_name(mxfep->mxfe_dip), ddi_get_instance(mxfep->mxfe_dip)); } else { sprintf(tag, "%s", MXFE_IDNAME); } sprintf(buf, "%s: %s: %s", tag, func, fmt); vcmn_err(CE_CONT, buf, ap); } va_end(ap); } #endif
25.872931
79
0.683869
[ "model" ]
2486a3599cff6dffeb95f1a50e67b6dbc6eae7f2
1,182
h
C
src/examples/basic/Interface/CommandsUI.h
Timurinyo/classic_game_template
4486e534fa76ccc8b4323515fad1c5fdae6ad8bc
[ "MIT" ]
null
null
null
src/examples/basic/Interface/CommandsUI.h
Timurinyo/classic_game_template
4486e534fa76ccc8b4323515fad1c5fdae6ad8bc
[ "MIT" ]
null
null
null
src/examples/basic/Interface/CommandsUI.h
Timurinyo/classic_game_template
4486e534fa76ccc8b4323515fad1c5fdae6ad8bc
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include <map> #include <examples/basic/CommandQueue.h> #include <engine/external_libs.h> #include <engine/system.h> #include <render_core/i_render_context.h> #include <imgui.h> struct CommandUIProps { cgt::render::TextureHandle Texture; ImVec2 UV0 = { 0, 0 }; ImVec2 UV1 = { 1, 1 }; const char* Description; //To show as tooltips ImVec2 Size = { 64, 64 }; // tint/border color }; class CommandsUI { public: CommandsUI(std::shared_ptr<cgt::render::IRenderContext> render, CommandQueue* queue, u32 windowWidth, u32 windowHeight); void Tick(const float dt); private: void DrawCommandQueue(); void DrawCommandSelectButtons(); void DrawCommandImage(const Command& command, bool isHighlighted = false); bool DrawCommandImageButton(const Command& command); CommandUIProps GetCommandUIProps(const Command& command) const; std::vector<Command> m_AvailableCommands = {}; CommandQueue* m_CommandQueue = nullptr; std::shared_ptr<cgt::render::IRenderContext> m_Render = nullptr; std::unordered_map<CommandID, CommandUIProps> m_CommandUIPropsMap; const ImVec2 m_WindowSize; };
23.64
124
0.720812
[ "render", "vector" ]
2498aeab60b274de890007741fe5349bd715ace3
499
h
C
src/engine/viewport/layout/ViewportLayoutH1V2.h
Armanimani/Game-Engine
8087cd999f7264488d24a5dc5571b659347a49dd
[ "MIT" ]
null
null
null
src/engine/viewport/layout/ViewportLayoutH1V2.h
Armanimani/Game-Engine
8087cd999f7264488d24a5dc5571b659347a49dd
[ "MIT" ]
1
2017-04-05T01:40:02.000Z
2017-04-05T07:36:55.000Z
src/engine/viewport/layout/ViewportLayoutH1V2.h
Armanimani/Game-Engine
8087cd999f7264488d24a5dc5571b659347a49dd
[ "MIT" ]
null
null
null
#pragma once #include "ViewportLayout.h" class ViewportLayoutH1V2 : public ViewportLayout { public: ViewportLayoutH1V2(const std::shared_ptr<WindowSettings> settings, const GLfloat& cutY) : ViewportLayout(settings, ViewportLayoutType::H2V1), cutY(cutY) {} virtual void initLayout(std::vector<std::shared_ptr<Viewport>>& map, const std::vector<std::shared_ptr<Camera>> cams) override; virtual void updateLayout(std::vector<std::shared_ptr<Viewport>>& map) override; protected: GLfloat cutY; };
35.642857
156
0.781563
[ "vector" ]
249c17be3b8107e6a3cee1369c3761e9f54e4b08
320
h
C
qemu/hw/ppc/e500-ccsr.h
hyunjoy/scripts
01114d3627730d695b5ebe61093c719744432ffa
[ "Apache-2.0" ]
44
2022-03-16T08:32:31.000Z
2022-03-31T16:02:35.000Z
qemu/hw/ppc/e500-ccsr.h
hyunjoy/scripts
01114d3627730d695b5ebe61093c719744432ffa
[ "Apache-2.0" ]
1
2022-03-29T02:30:28.000Z
2022-03-30T03:40:46.000Z
qemu/hw/ppc/e500-ccsr.h
hyunjoy/scripts
01114d3627730d695b5ebe61093c719744432ffa
[ "Apache-2.0" ]
18
2022-03-19T04:41:04.000Z
2022-03-31T03:32:12.000Z
#ifndef E500_CCSR_H #define E500_CCSR_H #include "hw/sysbus.h" #include "qom/object.h" struct PPCE500CCSRState { /*< private >*/ SysBusDevice parent; /*< public >*/ MemoryRegion ccsr_space; }; #define TYPE_CCSR "e500-ccsr" OBJECT_DECLARE_SIMPLE_TYPE(PPCE500CCSRState, CCSR) #endif /* E500_CCSR_H */
16.842105
50
0.709375
[ "object" ]
24a29da50d346a0359f1e37fe7f2b2701318610c
1,236
h
C
cppclient/delegates.h
AeroNotix/freepoint
aca053b43e04cc3ffb30ca75ec4b0da334af952d
[ "BSD-4-Clause" ]
1
2015-11-05T18:50:05.000Z
2015-11-05T18:50:05.000Z
cppclient/delegates.h
AeroNotix/freepoint
aca053b43e04cc3ffb30ca75ec4b0da334af952d
[ "BSD-4-Clause" ]
null
null
null
cppclient/delegates.h
AeroNotix/freepoint
aca053b43e04cc3ffb30ca75ec4b0da334af952d
[ "BSD-4-Clause" ]
null
null
null
#ifndef DELEGATES_H #define DELEGATES_H #include <QtGui> #include <QItemDelegate> #include <QStringList> class MainWindow; class ComboDelegate : public QItemDelegate { Q_OBJECT public: explicit ComboDelegate(QStringList data, QMainWindow *parent = nullptr) : QItemDelegate(parent), data(data) {}; QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const; protected: QStringList data; }; class TimeDelegate : public QItemDelegate { Q_OBJECT public: explicit TimeDelegate(QMainWindow *parent = nullptr) : QItemDelegate(parent) {}; QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const; }; class DateDelegate : public QItemDelegate { Q_OBJECT public: explicit DateDelegate(QMainWindow *parent = nullptr) : QItemDelegate(parent) {}; QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const; void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; }; QItemDelegate* SelectDelegate(QString choice, QStringList choices, QMainWindow *parent = nullptr); #endif // DELEGATES_H
25.22449
99
0.711165
[ "model" ]
24ac414a91a3248a35dd05f33bbd24ef0fb7b0ee
445
h
C
Source/MiriwakuEditor/Public/MiriwakuEditorUtilityWidget.h
TheHoodieGuy02/Miriwaku
63aaf2cc6f4bfb8b514e632646c6dc52e4d44744
[ "MIT" ]
1
2021-06-13T07:21:34.000Z
2021-06-13T07:21:34.000Z
Source/MiriwakuEditor/Public/MiriwakuEditorUtilityWidget.h
TheHoodieGuy02/Miriwaku
63aaf2cc6f4bfb8b514e632646c6dc52e4d44744
[ "MIT" ]
5
2021-03-18T08:46:59.000Z
2021-07-10T04:45:21.000Z
Source/MiriwakuEditor/Public/MiriwakuEditorUtilityWidget.h
TheHoodieGuy02/Miriwaku
63aaf2cc6f4bfb8b514e632646c6dc52e4d44744
[ "MIT" ]
2
2021-05-27T14:51:19.000Z
2021-06-15T06:45:36.000Z
// Idol Model (C) BANDAI NAMCO ENTERTAINMENT Inc. Code (C) THG #pragma once #include "CoreMinimal.h" #include "EditorUtilityWidget.h" #include "MiriwakuEditorUtilityWidget.generated.h" /** * */ UCLASS() class MIRIWAKUEDITOR_API UMiriwakuEditorUtilityWidget : public UEditorUtilityWidget { GENERATED_BODY() public: UMiriwakuEditorUtilityWidget(); ~UMiriwakuEditorUtilityWidget(); UFUNCTION(BlueprintCallable) void ModuleTest(); };
18.541667
83
0.773034
[ "model" ]
24b686b7448159e9b9d8060f0b0ea248d4b0065b
3,026
h
C
src/plugins/tools/ssl/myssltoolmode.h
paule32/QDataTools
4ebaa4371950b93c7c1d17cb7626c5bba37e496c
[ "MIT" ]
null
null
null
src/plugins/tools/ssl/myssltoolmode.h
paule32/QDataTools
4ebaa4371950b93c7c1d17cb7626c5bba37e496c
[ "MIT" ]
null
null
null
src/plugins/tools/ssl/myssltoolmode.h
paule32/QDataTools
4ebaa4371950b93c7c1d17cb7626c5bba37e496c
[ "MIT" ]
null
null
null
// -------------------------------------------------------------------------------- // MIT License // // Copyright (c) 2020 Jens Kallup // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // -------------------------------------------------------------------------------- #ifndef MYSSLTOOLMODE_H #define MYSSLTOOLMODE_H #include <QWidget> #include <QTextBrowser> #include <QLineEdit> #include <QTreeWidget> #include <QTreeWidgetItem> #include <QStringList> #include "lineedit.h" #include "ui_myssltoolmode.h" namespace Ui { class MySSLToolMode; } class MySSLToolMode : public QWidget { Q_OBJECT public: explicit MySSLToolMode(QWidget *parent = nullptr); ~MySSLToolMode(); bool write_cert(QString pro_str); void msgbox(QString msg); QString openPath(); void pathEditTextChanged(const QString &arg1, QLineEdit * pathEdit); Ui::MySSLToolMode * getUI() { return ui; } QTextBrowser * getTextBrowser() { return getUI()->textBrowser; } private slots: void on_addNewCA_clicked(); void on_pathEdit_textChanged(const QString &arg1); void on_openPath1_clicked(); void on_openPath2_clicked(); void on_openPath3_clicked(); void on_openPath4_clicked(); void on_openPath5_clicked(); void on_serverPathEdit_textChanged(const QString &arg1); void on_pcPathEdit_textChanged(const QString &arg1); void on_appPathEdit_textChanged(const QString &arg1); void on_humPathEdit_textChanged(const QString &arg1); void on_delCA_clicked(); void on_importBtn_clicked(); private: Ui::MySSLToolMode *ui; }; struct my_ssl_edit_struct { my_ssl_edit_struct ( int p_group, MyLineSSLEdit * p_edit, MySSLToolMode * p_mode) : m_group(p_group) , m_edit (p_edit ) , m_mode (p_mode ) { } int m_group ; MyLineSSLEdit * m_edit ; MySSLToolMode * m_mode ; }; extern std::vector<my_ssl_edit_struct> ssl_edit_vector; #endif // MYSSLTOOLMODE_H
31.852632
83
0.68341
[ "vector" ]
24bfb6c1479d6d18eeb6ff390ea3dbe62d1bc228
15,391
h
C
src/WFSTModelOnTheFly.h
idiap/juicer
c1d67eb710c5390d0555deb05428ea11cd5e2bf1
[ "BSD-3-Clause" ]
52
2015-01-23T14:09:06.000Z
2021-06-24T00:19:42.000Z
src/WFSTModelOnTheFly.h
idiap/juicer
c1d67eb710c5390d0555deb05428ea11cd5e2bf1
[ "BSD-3-Clause" ]
null
null
null
src/WFSTModelOnTheFly.h
idiap/juicer
c1d67eb710c5390d0555deb05428ea11cd5e2bf1
[ "BSD-3-Clause" ]
22
2015-01-19T03:03:36.000Z
2020-08-10T05:39:11.000Z
/* * Copyright 2006 by IDIAP Research Institute * http://www.idiap.ch * * See the file COPYING for the licence associated with this software. */ #ifndef WFST_MODELONTHEFLY_INC #define WFST_MODELONTHEFLY_INC #include "general.h" #include "WFSTModel.h" /* Author: Octavian Cheng (ocheng@idiap.ch) Date: 6 June 2006 */ namespace Juicer { /* * The following are the data structures added for doing dynamic * composition */ // Changes Octavian 20060417 20060531 20060630 /** * This structure contains * a gState Index, a matchedOutLabel and a pointer of a * hypothesis. The pair (gState, matchedOutLabel) will be the key * (index) for finding hypotheses. It is a linked list node, hence it * also has a pointer to the next node. It is used for organizing a * list of hypotheses in each emitting state and the last state of the * HMM. Because now each state will have more than 1 hypotheses. Each * hypothesis has a different gState number. * */ union NodeToDecHypOnTheFly_ptr { struct NodeToDecHypOnTheFly *next ; struct NodeToDecHypOnTheFly *left ; } ; struct NodeToDecHypOnTheFly { int gState ; int matchedOutLabel ; // Changes Octavian 20060627 // DecHypOnTheFly *hyp ; DecHypOnTheFly hyp ; // Changes Octavian 20060630 // If it is used as a linked list, use ptr.next // It it is used as a binary search tree, use ptr.left union NodeToDecHypOnTheFly_ptr ptr ; // Changes Octavian 20060630 struct NodeToDecHypOnTheFly *right ; } ; // Changes Octavian 20060417 /** * This structure contains a linked list of nodes. * This list serves as a map of gStateIndex to a hyp * It is the structure to maintain the linked list of NodeToDecHypOntheFly * nodes for each emitting state and the last state. */ struct NodeToDecHypOnTheFlyList { struct NodeToDecHypOnTheFly *head ; struct NodeToDecHypOnTheFly *tail ; } ; // Changes Octavian 20060417 /** * A block memory pool for storing NodeToDecHypOnTheFly nodes */ class NodeToDecHypOnTheFlyPool { public: NodeToDecHypOnTheFlyPool() ; NodeToDecHypOnTheFlyPool( int reallocAmount_ ) ; virtual ~NodeToDecHypOnTheFlyPool() ; NodeToDecHypOnTheFly *getSingleNode() { // Changes Octavian 20060627 NodeToDecHypOnTheFly *newNode = (NodeToDecHypOnTheFly *) ( pool->getElem() ) ; DecHypHistPool::initDecHypOnTheFly( &(newNode->hyp), -1 , -1 ) ; // Changes Octavian 20060627 return newNode ; } ; void returnSingleNode( NodeToDecHypOnTheFly *node ) { // Changes Octavian 20060627 #ifdef DEBUG if ( DecHypHistPool::isActiveHyp( &(node->hyp) ) == true ) error("NodeToDecHypOnTheFlyPool - the hyp is active") ; #endif pool->returnElem( (void *) node ) ; return ; } ; protected: int reallocAmount ; BlockMemPool *pool ; } ; // Changes Octavian 20060424 20060531 20060630 // This is the data structure speically for the initial state // of the HMM. It is implemented as a binary search tree because // hypotheses of different state numbers are coming out of order. // The pair (gState, matchedOutLabel) is a key to this binary search tree. /* struct NodeToDecHypOnTheFlyMap { int gState ; int matchedOutLabel ; // Changes Octavian 20060627 // DecHypOnTheFly *hyp ; DecHypOnTheFly hyp ; NodeToDecHypOnTheFlyMap *left ; NodeToDecHypOnTheFlyMap *right ; } ; */ // Changes Octavian 20060424 20060630 // A block memory pool for storing NodeToDecHypOnTheFlyMap /* class NodeToDecHypOnTheFlyMapPool { public: NodeToDecHypOnTheFlyMapPool() ; NodeToDecHypOnTheFlyMapPool( int reallocAmount_ ) ; virtual ~NodeToDecHypOnTheFlyMapPool() ; NodeToDecHypOnTheFlyMap *getSingleNode() { // Changes Octavian 20060627 NodeToDecHypOnTheFlyMap *newNode = (NodeToDecHypOnTheFlyMap *)( pool->getElem() ) ; DecHypHistPool::initDecHypOnTheFly( &(newNode->hyp), -1, -1 ) ; // Changes Octavian 20060627 return newNode ; } ; void returnSingleNode( NodeToDecHypOnTheFlyMap *node ) { // Changes Octavian 20060627 #ifdef DEBUG if ( DecHypHistPool::isActiveHyp( &(node->hyp) ) == true ) error("NodeToDecHypOnTheFlyMapPool - the hyp is active") ; #endif pool->returnElem( (void *) node ) ; return ; } ; protected: int reallocAmount ; BlockMemPool *pool ; } ; */ // Changes Octavian 20060417 20060423 20060630 /** * A data structure which represents an active model (ie a model which has * hypotheses) * Basic attribes are similar to WFSTModel * The main difference is that the initial state is implemented as a binary * search tree. * The emitting states and the last state is implemented as an ordered linked * list (NodeToDecHypOnTheFlyList). * In simple terms, if an HMM has 5 states (3 emitting states + init state + * last state), the init state is a binary search tree; the rest are ordered * linked list. * The two pools are basically for allocating nodes when necessary. * * NOTE: WFSTOnTheFlyDecoder::extendInitMap also changes some attributes * of this class. */ class WFSTModelOnTheFly { public: // Methods // Other extenal functions will allocate/release memory of this class. WFSTModelOnTheFly() {} ; virtual ~WFSTModelOnTheFly() {} ; // Changes Octavian 20060531 // This method returns the NodeToDecHypOnTheFly in the last state of this // HMM. // If isPushed == true, it will find the hyp from currHypsPushed. // Otherwise, it will return the hyp from currHypsNotPushed. // Return NULL if no more hyp is found. // Will automatically dequeue the record from the last state. // Remember to call returnSingleNode() after finishing this hyp. // gPushedState stores the pushed G state of the hyp. // matchedOutLabel stores the matched output label of the hyp - // matchedOutLabel = UNDECIDEDOUTLABEL if unpushed or // matchedOutLabel = a matching CoL outLabel if pushed /* DecHypOnTheFly *getLastStateHyp( bool isPushed, int *gPushedState, int *matchedOutLabel ) ; */ NodeToDecHypOnTheFly *getLastStateHyp( bool isPushed, int *gPushedState, int *matchedOutLabel ) ; // Get all the hypotheses in all the NodeToDecHypOnTheFlyLists // No particular order. // Return NULL if the model has no more hyps in the lists // Will auotmatically dequeue the record from the list // Remember to call returnSingleHyp() for the returned hyp // DecHypOnTheFly *getNonInitStateHyp() ; // Changes Octavian 20060627 // Clear all hypotheses in the non-initial state of the HMM. Always call // this function after all frames have been processed. void clearNonInitStateHyp() ; // Changes Octavian 20060424 20060531 20060627 20060630 // Find the hyp from the init state map. If found, isNew is false and // return where it could be found. If not found, create a new entry // and return where the hyp could be found // Start searching from currNode. // The key of the map is (gState, matchedOutLabel) /* DecHypOnTheFly *findInitStateHyp( NodeToDecHypOnTheFlyMap *currNode, bool isPushed, int gState, int matchedOutLabel, bool *isNew ) ; */ DecHypOnTheFly *findInitStateHyp( NodeToDecHypOnTheFly *currNode, bool isPushed, int gState, int matchedOutLabel, bool *isNew ) ; // Changes Octavian 20060531 20060627 // This function return the next hyp from all emit states // according to the accending (gState, matchedOutLabel) order. // If isPushed == true, it will find the next hyp from all emit states of // prevHypsPushed. Otherwise, it will search from prevHypsNotPushed. // Return NULL if no more hyp is found. // Will automatically dequeue the hyp record from the corresponding // linked list. // Remember to call returnSingleNode() after using NodeToDecHypOnTheFly. // The reason for the accending order to is to ensure the hyp are // still in an accending-ordered linked list after Viterbi, // so that it doesn't need to search to do the Viterbi. NodeToDecHypOnTheFly *getNextEmitStateHyps( bool isPushed, int *gPushedState, int *matchedOutLabel, int *fromHMMState ) ; // Changes Octavian 20060531 20060627 // This function will search for a hyp in the hmmState of an HMM with // (gPushedState, matchedOutLabel) as an index. If isPushed == // true, it will search the currHypsPushed[hmmState-1]. Otherwise, it will // search the currHypsNotPushed[hmmState-1]. Return hyp pointer. // If found, hyp pointer is pointing towards an already-existed hyp and // isNew is false. Otherwise, hyp pointer is pointing towards a newly- // created hyp (to which you can extend the old hyp to this new one) and // isNew is true. // helper is an array of pointers which point to a node in the linked list. // For example, if the there 3 emitting states and a last state, then // the array will have 4 elements. Each is pointing towards a node of the // linked list of the corresponding state. When this function returns, it // will point to a node which has a <= gState number than gPushedState and // a <= matchedOutLabel number than the argument matchedOutLabel. // The only exception is when there is only one node in the list. DecHypOnTheFly *findCurrEmitStateHypsFromInitSt( int hmmState, bool isPushed, int gPushedState, int matchedOutLabel, NodeToDecHypOnTheFly **helper, bool *isNew ) ; // Changes Octavian 20060531 20060627 // This function will find the hyp on the hmmState of the HMM model with // the G state index of gPushedState and the matchedOutLabel. // If isPushed == true, it will search in the currHypsPushed[hmmState-1] // linked list. Otherwise, it will search in the // currHypsNotPushed[hmmState-1] linked list. // Return hyp pointer. See findCurrEmitStateHypsFromInitSt(). // Because all hyps are organized in an accending order of gPushedState, // what this function does is just checking the last elem of the linked // list. DecHypOnTheFly *findCurrEmitStateHypsFromEmitSt( int hmmState, bool isPushed, int gPushedState, int matchedOutLabel, bool *isNew ) ; // Changes Octavian 20060531 20060627 // This function puts newHyp to the hmmState of the HMM model. // (gPushedState, matchedOutLabel) is a key to differentiate other hyps // in the same HMM state. If isPushed == true, put the newHyp in the // currHypsPushed linked list. Otherwise, put it in the currHypsNotPushed // linked list. It will maintain the ascending order of the original list, // so it is not just attaching at the tail - the main difference from // putCurrEmitStateHypsFromEmitSt(). // helper should point to the insertion point. /* void putCurrEmitStateHypsFromInitSt( DecHypOnTheFly *newHyp, int hmmState, bool isPushed, int gPushedState, int matchedOutLabel, NodeToDecHypOnTheFly **helper ) ; */ // Changes Octavian 20060531 20060627 // This function puts newHyp to the hmmState of the HMM model. // (gPushedState, matchedOutLabel) is a key to differentiate other hyps // in the same HMM state. If isPushed == true, put the newHyp in the // currHypsPushed linked list. Otherwise, put it in the currHypsNotPushed // linked list. Since hypotheses are coming in the accending order of // gPushedState, this function just attaches the newHyp at the tail of // the linked list. /* void putCurrEmitStateHypsFromEmitSt( DecHypOnTheFly *newHyp, int hmmState, bool isPushed, int gPushedState, int matchedOutLabel ) ; */ // This function creates the helper array NodeToDecHypOnTheFly **createHelper() ; // This function assign the helper array pointing to the head of // currHypsNotPushed or currHypsPushed of each state void assignHelper( NodeToDecHypOnTheFly **helper, bool isPushed ) ; // Attributes WFSTTransition *trans ; // A model is associated with a transition in the WFST DecodingHMM *hmm ; // Pointer to the HMM definition. // Changes Octavian 20060423 20060424 20060630 /* NodeToDecHypOnTheFlyMap *initMapNotPushed ; NodeToDecHypOnTheFlyMap *initMapPushed ; */ NodeToDecHypOnTheFly *initMapNotPushed ; NodeToDecHypOnTheFly *initMapPushed ; // Linked list to map gState to hyp pointer. // An array of linked list starting from the second state to the last NodeToDecHypOnTheFlyList *hyp1NotPushed ; NodeToDecHypOnTheFlyList *hyp1Pushed ; NodeToDecHypOnTheFlyList *hyp2NotPushed ; NodeToDecHypOnTheFlyList *hyp2Pushed ; NodeToDecHypOnTheFlyList *prevHypsNotPushed ; NodeToDecHypOnTheFlyList *prevHypsPushed ; NodeToDecHypOnTheFlyList *currHypsNotPushed ; NodeToDecHypOnTheFlyList *currHypsPushed ; // A pool which manages the allocation of NodeToDecHypOnTheFly NodeToDecHypOnTheFlyPool *pool ; // Changes Octavian 20060424 20060630 // A pool which manages the allocation of NodeToDecHypOnTheFlyMap // NodeToDecHypOnTheFlyMapPool *mapPool ; // Changes Octavian 20060627 // A pool which manages hyp history // Created by decoder DecHypHistPool *decHypHistPool ; int nActiveHyps ; WFSTModelOnTheFly *next ; // We also have a straight linked list of all active WFSTModel elements. }; // Changes Octavian 20060417 /** * A structure similar to WFSTModelFNSPool */ struct WFSTModelOnTheFlyFNSPool // FNS = Fixed Number of States { int nStates ; // All elements in this pool are for models with this many states. int nTotal ; int nUsed ; int nFree ; int reallocAmount ; int nAllocs ; WFSTModelOnTheFly **allocs ; WFSTModelOnTheFly **freeElems ; } ; // Changes Octavian 20060417 /** */ class WFSTModelOnTheFlyPool : public WFSTModelPool { public: // Changes Octavian 20060627 /* WFSTModelOnTheFlyPool( PhoneModels *phoneModels_ , DecHypHistPool *decHypHistPool_ , DecHypPool *decHypPool_ ) ; WFSTModelOnTheFlyPool( Models *models_ , DecHypHistPool *decHypHistPool_ , DecHypPool *decHypPool_ ) ; */ //PNG WFSTModelOnTheFlyPool( //PNG PhoneModels *phoneModels_ , DecHypHistPool *decHypHistPool_ ) ; WFSTModelOnTheFlyPool( Models *models_ , DecHypHistPool *decHypHistPool_ ) ; virtual ~WFSTModelOnTheFlyPool() ; WFSTModelOnTheFly *getElem( WFSTTransition *trans ) ; void returnElem( WFSTModelOnTheFly *elem ) ; protected: // Changes Octavian 20060627 // DecHypPool *decHypPool ; // Changes Octavian 20060417 NodeToDecHypOnTheFlyPool *nodeToDecHypOnTheFlyPool ; // Changes Octavian 20060424 20060630 // NodeToDecHypOnTheFlyMapPool *nodeToDecHypOnTheFlyMapPool ; virtual void initFNSPool( int poolInd , int nStates , int initReallocAmount ) ; virtual void allocPool( int poolInd ) ; private: WFSTModelOnTheFlyFNSPool *poolsOnTheFly ; void initElem( WFSTModelOnTheFly *elem , int nStates ) ; void resetElem( WFSTModelOnTheFly *elem , int nStates ) ; void checkActive( WFSTModelOnTheFly *elem ) ; // Changes Octavian 20060424 20060531 20060630 // Similar to WFSTOnTheFlyDecoder::extendInitMap() // Reset and return all hypotheses in the initial state of an HMM // void iterInitMap( NodeToDecHypOnTheFlyMap *currNode ) ; void iterInitMap( NodeToDecHypOnTheFly *currNode ) ; } ; //***************************************** } #endif
36.129108
101
0.724319
[ "model" ]
24c2b33431d74b44b11d65cea45d77760e7a9590
2,408
h
C
Source/Services/Marketplace/WinRT/BrowseCatalogResult_WinRT.h
blgrossMS/xbox-live-api
17c586336e11f0fa3a2a3f3acd665b18c5487b24
[ "MIT" ]
2
2021-07-17T13:34:20.000Z
2022-01-09T00:55:51.000Z
Source/Services/Marketplace/WinRT/BrowseCatalogResult_WinRT.h
blgrossMS/xbox-live-api
17c586336e11f0fa3a2a3f3acd665b18c5487b24
[ "MIT" ]
null
null
null
Source/Services/Marketplace/WinRT/BrowseCatalogResult_WinRT.h
blgrossMS/xbox-live-api
17c586336e11f0fa3a2a3f3acd665b18c5487b24
[ "MIT" ]
1
2018-11-18T08:32:40.000Z
2018-11-18T08:32:40.000Z
//********************************************************* // // Copyright (c) Microsoft. All rights reserved. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //********************************************************* #pragma once #include "xsapi/marketplace.h" #include "CatalogItem_WinRT.h" NAMESPACE_MICROSOFT_XBOX_SERVICES_MARKETPLACE_BEGIN public ref class BrowseCatalogResult sealed { public: // "Items": // [ // { // // ... // } // ], // // "Totals": // [ // { // "Name":"GameType", // "Count":126, // "MediaItemTypes": // [ // { // "Name":"XboxGameConsumable", // "Count":126 // } // ] // } // ], /// <summary> /// Collection of XboxCatalogItem objects returned by a request /// </summary> property Windows::Foundation::Collections::IVectorView<CatalogItem^>^ Items { Windows::Foundation::Collections::IVectorView<CatalogItem^>^ get(); } /// <summary> // The total count of the items /// </summary> DEFINE_PROP_GET_OBJ(TotalCount, total_count, uint32); /// <summary> /// Returns an BrowseCatalogResult object containing the next page of BrowseCatalogResult /// </summary> /// <param name="maxItems">The maximum number of items the result can contain. Pass 0 to attempt retrieving all items.</param> /// <returns>A BrowseCatalogResult object.</returns> /// <remarks>Calls V3.2 GET /media/{marketplaceId}/browse</remarks> Windows::Foundation::IAsyncOperation<BrowseCatalogResult^>^ GetNextAsync( _In_ uint32 maxItems ); /// <summary> /// Indicates if there is additional data to retrieve from a GetNextAsync call /// </summary> DEFINE_PROP_GET_OBJ(HasNext, has_next, bool); internal: BrowseCatalogResult( _In_ xbox::services::marketplace::browse_catalog_result cppObj ); private: xbox::services::marketplace::browse_catalog_result m_cppObj; Windows::Foundation::Collections::IVectorView<CatalogItem^>^ m_items; }; NAMESPACE_MICROSOFT_XBOX_SERVICES_MARKETPLACE_END
29.728395
131
0.584302
[ "object" ]
24c3e1f56386d89a26a6c30a8c369c38ebcef654
6,555
c
C
gpvdm_core/plugins/light_full/light.c
roderickmackenzie/gpvdm
914fd2ee93e7202339853acaec1d61d59b789987
[ "BSD-3-Clause" ]
12
2016-09-13T08:58:13.000Z
2022-01-17T07:04:52.000Z
gpvdm_core/plugins/light_full/light.c
roderickmackenzie/gpvdm
914fd2ee93e7202339853acaec1d61d59b789987
[ "BSD-3-Clause" ]
3
2017-11-11T12:33:02.000Z
2019-03-08T00:48:08.000Z
gpvdm_core/plugins/light_full/light.c
roderickmackenzie/gpvdm
914fd2ee93e7202339853acaec1d61d59b789987
[ "BSD-3-Clause" ]
6
2019-01-03T06:17:12.000Z
2022-01-01T15:59:00.000Z
// // General-purpose Photovoltaic Device Model gpvdm.com - a drift diffusion // base/Shockley-Read-Hall model for 1st, 2nd and 3rd generation solarcells. // The model can simulate OLEDs, Perovskite cells, and OFETs. // // Copyright 2008-2022 Roderick C. I. MacKenzie https://www.gpvdm.com // r.c.i.mackenzie at googlemail.com // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // /** @file light.c @brief Full optical pluugin solver. */ #include <stdio.h> #include <stdlib.h> #include <util.h> #include <dump_ctrl.h> #include <gpvdm_const.h> #include <light.h> #include <device.h> #include <light_interface.h> #include <functions.h> #include <log.h> #include <lang.h> #include <matrix.h> #include <memory.h> #include <triangles.h> #include <string.h> //static long double min_light_error=1e-10; EXPORT void light_dll_ver(struct simulation *sim) { //printf_log(sim,"%s\n",_("Full transfer matrix based light model")); } EXPORT int light_dll_solve_lam_slice(struct simulation *sim,struct device *cell,struct light *li,long double *sun_E,int z, int x, int l,int w) { int y; long double complex Epl=0.0+0.0*I; //long double complex Epc=0.0+0.0*I; //long double complex Epr=0.0+0.0*I; //long double complex Enl=0.0+0.0*I; //long double complex Enc=0.0+0.0*I; //long double complex Enr=0.0+0.0*I; long double complex rc=0.0+0.0*I; long double complex tc=0.0+0.0*I; long double complex rr=0.0+0.0*I; long double complex tr=0.0+0.0*I; long double complex nbar_c=0.0; long double complex xi_c=0.0; long double complex nbar_r=0.0; long double complex xi_r=0.0; long double complex rl=0.0+0.0*I; long double complex tl=0.0+0.0*I; long double complex nbar_l=0.0; long double complex xi_l=0.0; long double complex fp=0.0; long double complex fn=0.0; long double dy=0.0; //long double nc; long double lam=0; int ittr=0; int pos=0; double mul=1.0; int quit=FALSE; long double test=FALSE; long double update; struct vec my_vec; struct matrix *mx=&(li->mx[w]); struct dim_light *dim=&li->dim; if (sun_E[l]==0.0) { return 0; } lam=dim->l[l]; dy=dim->y[2]-dim->y[1]; //printf("%d\n",li->light_profile_tri); //getchar(); if (strcmp(li->light_profile,"box")!=0) { if ((dim->xlen>1)&&(dim->zlen>1)) { my_vec.x=dim->x[x]; my_vec.z=dim->z[z]; mul=triangles_interpolate(&li->light_profile_tri,&my_vec); if (mul<0.01) { return 0; } mul=sqrt(mul); } } //printf("%le %le %le\n",my_vec.x,my_vec.z,mul); //getchar(); do { pos=0; for (y=0;y<dim->ylen;y++) { rc=li->r[z][x][y][l]; tc=li->t[z][x][y][l]; if (y==0) { rl=li->r[z][x][y][l]; tl=li->t[z][x][y][l]; nbar_l=li->nbar[z][x][y][l]; Epl=sun_E[l]*mul+0.0*I; }else { rl=li->r[z][x][y-1][l]; tl=li->t[z][x][y-1][l]; nbar_l=li->nbar[z][x][y-1][l]; Epl=0.0; } if (y==dim->ylen-1) { rr=li->r[z][x][y][l]; tr=li->t[z][x][y][l]; nbar_r=li->nbar[z][x][y][l]; }else { rr=li->r[z][x][y+1][l]; tr=li->t[z][x][y+1][l]; nbar_r=li->nbar[z][x][y+1][l]; } nbar_c=li->nbar[z][x][y][l]; //printf("%d %d %e %e\n",l,y,li->n[z][x][y][l],li->alpha[z][x][y][l]); xi_l=((2*PI)/lam)*nbar_l; xi_c=((2*PI)/lam)*nbar_c; xi_r=((2*PI)/lam)*nbar_r; long double complex pa=-tl; long double complex pbp=cexp(xi_c*dy*I); long double complex pbn=rl*cexp(-xi_c*dy*I); long double complex na=-tc;//Enc long double complex nbp=rc*cexp(xi_r*dy*I);//Enr* long double complex nbn=cexp(-xi_r*dy*I); //getchar(); fp=0.0+0.0*I; fn=0.0+0.0*I; if (y==0) { fp=Epl; pa=0.0+0.0*I; }else { fp=0.0+0.0*I; } //printf("%d %d\n",pos,mx->nz); //getchar(); if (y!=0) { mx->Ti[pos]=y; mx->Tj[pos]=y-1; mx->Tx[pos]=gcreal(pa); mx->Txz[pos]=gcimag(pa); pos++; } mx->Ti[pos]=y; mx->Tj[pos]=y; mx->Tx[pos]=gcreal(pbp); mx->Txz[pos]=gcimag(pbp); pos++; mx->Ti[pos]=y; mx->Tj[pos]=dim->ylen+y; mx->Tx[pos]=gcreal(pbn); mx->Txz[pos]=gcimag(pbn); pos++; if (y!=dim->ylen-1) { mx->Ti[pos]=dim->ylen+y; mx->Tj[pos]=y+1; mx->Tx[pos]=gcreal(nbp); mx->Txz[pos]=gcimag(nbp); pos++; } mx->Ti[pos]=dim->ylen+y; mx->Tj[pos]=dim->ylen+y; mx->Tx[pos]=gcreal(na); mx->Txz[pos]=gcimag(na); pos++; if (y!=dim->ylen-1) { mx->Ti[pos]=dim->ylen+y; mx->Tj[pos]=dim->ylen+y+1; mx->Tx[pos]=gcreal(nbn); mx->Txz[pos]=gcimag(nbn); pos++; } mx->b[y]=gcreal(fp); mx->bz[y]=gcimag(fp); mx->b[dim->ylen+y]=gcreal(fn); mx->bz[dim->ylen+y]=gcimag(fn); } //complex_solver_print(sim,li->M,li->N,li->Ti,li->Tj, li->Tx, li->Txz,li->b,li->bz); //complex_solver_dump_matrix(li->M,li->N,li->Ti,li->Tj, li->Tx, li->Txz,li->b,li->bz); if (pos!=mx->nz) { printf_log(sim,"%s %d %d\n",_("I can't solve the matrix because I don't have enough equations."),pos,mx->nz); exit(0); } matrix_solve(sim,&(li->msm[w]),mx); //complex_solver(sim,li->M,li->N,li->Ti,li->Tj, li->Tx, li->Txz,li->b,li->bz); for (y=0;y<dim->ylen;y++) { update=mx->b[y]; li->Ep[z][x][y][l]=update; update=mx->bz[y]; li->Epz[z][x][y][l]=update; update=mx->b[dim->ylen+y]; li->En[z][x][y][l]=update; update=mx->bz[dim->ylen+y]; li->Enz[z][x][y][l]=update; } ittr++; if (test==TRUE) { if (ittr>1) quit=TRUE; getchar(); }else { quit=TRUE; } }while(quit==FALSE); //getchar(); //getchar(); return 0; }
21.07717
142
0.605034
[ "model" ]
24d326508201677acb7747cd6331902ad3f884b8
16,331
h
C
osgVegetation/ov_GPUCullData.h
leadcoder/osgVegetation
c13bb8e0225467c97b0bc85f3d38826f793c368e
[ "MIT" ]
22
2015-01-22T17:51:17.000Z
2021-12-24T06:59:46.000Z
osgVegetation/ov_GPUCullData.h
leadcoder/osgVegetation
c13bb8e0225467c97b0bc85f3d38826f793c368e
[ "MIT" ]
null
null
null
osgVegetation/ov_GPUCullData.h
leadcoder/osgVegetation
c13bb8e0225467c97b0bc85f3d38826f793c368e
[ "MIT" ]
10
2015-12-31T05:52:30.000Z
2020-03-13T05:31:51.000Z
#pragma once #include "AggregateGeometryVisitor.h" #include "ov_MeshLayerConfig.h" #include <osg/PrimitiveSetIndirect> #include <osg/TextureBuffer> #include <osg/BindImageTexture> #include <osg/BufferIndexBinding> #include <osg/BufferTemplate> #include <osg/ComputeBoundsVisitor> namespace osgVegetation { // each instance type may have max 8 LODs ( if you change // this value, don't forget to change it in vertex shaders accordingly ) const unsigned int OV_MAXIMUM_LOD_NUMBER = 8; // during culling each instance may be sent to max 4 indirect targets const unsigned int OV_MAXIMUM_INDIRECT_TARGET_NUMBER = 4; // Struct defining information about specific instance type : bounding box, lod ranges, indirect target indices etc struct InstanceType { // Struct defining LOD data for particular instance type struct InstanceLOD { InstanceLOD() : bbMin(FLT_MAX, FLT_MAX, FLT_MAX, 1.0f), bbMax(-FLT_MAX, -FLT_MAX, -FLT_MAX, 1.0f) { } InstanceLOD(const InstanceLOD& iLod) : bbMin(iLod.bbMin), bbMax(iLod.bbMax), indirectTargetParams(iLod.indirectTargetParams), distances(iLod.distances) { } InstanceLOD& operator=(const InstanceLOD& iLod) { if (&iLod != this) { bbMin = iLod.bbMin; bbMax = iLod.bbMax; indirectTargetParams = iLod.indirectTargetParams; distances = iLod.distances; } return *this; } inline void setBoundingBox(const osg::BoundingBox& bbox) { bbMin = osg::Vec4f(bbox.xMin(), bbox.yMin(), bbox.zMin(), bbMin.w()); bbMax = osg::Vec4f(bbox.xMax(), bbox.yMax(), bbox.zMax(), bbMax.w()); } inline void setIntensity(const float& intensity) { bbMin.w() = intensity; } inline osg::BoundingBox getBoundingBox() { return osg::BoundingBox(bbMin.x(), bbMin.y(), bbMin.z(), bbMax.x(), bbMax.y(), bbMax.z()); } osg::Vec4f bbMin; // LOD bounding box osg::Vec4f bbMax; osg::Vec4i indirectTargetParams; // x=lodIndirectCommand, y=lodIndirectCommandIndex, z=offsetsInTarget, w=lodMaxQuantity osg::Vec4f distances; // x=minDistance, y=minFadeDistance, z=maxFadeDistance, w=maxDistance }; InstanceType() : bbMin(FLT_MAX, FLT_MAX, FLT_MAX, 1.0f), bbMax(-FLT_MAX, -FLT_MAX, -FLT_MAX, 1.0f) { params.x() = 0; // this variable defines the number of LODs for (unsigned int i = 0; i < OV_MAXIMUM_LOD_NUMBER; ++i) lods[i] = InstanceLOD(); } InstanceType(const InstanceType& iType) : bbMin(iType.bbMin), bbMax(iType.bbMax), params(iType.params), floatParams(iType.floatParams) { for (unsigned int i = 0; i < OV_MAXIMUM_LOD_NUMBER; ++i) lods[i] = iType.lods[i]; } InstanceType& operator=(const InstanceType& iType) { if (&iType != this) { bbMin = iType.bbMin; bbMax = iType.bbMax; floatParams = iType.floatParams; params = iType.params; for (unsigned int i = 0; i < OV_MAXIMUM_LOD_NUMBER; ++i) lods[i] = iType.lods[i]; } return *this; } inline void setLodDefinition(unsigned int i, unsigned int targetID, unsigned int indexInTarget, unsigned int offsetInTarget, const osg::BoundingBox& lodBBox, const MeshTypeConfig::MeshLODConfig &config) { if (i >= OV_MAXIMUM_LOD_NUMBER) return; params.x() = osg::maximum<int>(params.x(), i + 1); lods[i].indirectTargetParams = osg::Vec4i(targetID, indexInTarget, offsetInTarget, config.Type); lods[i].distances = config.Distance; lods[i].setBoundingBox(lodBBox); lods[i].setIntensity(config.Intensity); expandBy(lodBBox); } inline void expandBy(const osg::BoundingBox& bbox) { osg::BoundingBox myBBox = getBoundingBox(); myBBox.expandBy(bbox); setBoundingBox(myBBox); } inline void setBoundingBox(const osg::BoundingBox& bbox) { bbMin = osg::Vec4f(bbox.xMin(), bbox.yMin(), bbox.zMin(), bbMin.w()); bbMax = osg::Vec4f(bbox.xMax(), bbox.yMax(), bbox.zMax(), bbMax.w()); } inline osg::BoundingBox getBoundingBox() { return osg::BoundingBox(bbMin.x(), bbMin.y(), bbMin.z(), bbMax.x(), bbMax.y(), bbMax.z()); } inline void setProbability(float value) { bbMin.w() = value; } osg::Vec4f bbMin; // bounding box that includes all LODs osg::Vec4f bbMax; osg::Vec4f floatParams; osg::Vec4i params; // x=number of active LODs InstanceLOD lods[OV_MAXIMUM_LOD_NUMBER]; // information about LODs }; // CPU side representation of a struct defined in ARB_draw_indirect extension struct DrawArraysIndirectCommand { DrawArraysIndirectCommand() : count(0), primCount(0), first(0), baseInstance(0) { } DrawArraysIndirectCommand(unsigned int aFirst, unsigned int aCount) : count(aCount), primCount(0), first(aFirst), baseInstance(0) { } unsigned int count; unsigned int primCount; unsigned int first; unsigned int baseInstance; }; // During the first phase of instance rendering cull shader places information about // instance LODs in texture buffers called "indirect targets" // All data associated with the indirect target is placed in struct defined below // ( like for example - draw shader associated with specific indirect target. // Draw shader performs second phase of instance rendering - the actual rendering of objects // to screen or to frame buffer object ). struct IndirectTarget { IndirectTarget() : _maxTargetQuantity(0) { _indirectCommands = new osg::DefaultIndirectCommandDrawArrays; _indirectCommands->getBufferObject()->setUsage(GL_DYNAMIC_DRAW); } IndirectTarget(AggregateGeometryVisitor* agv, osg::Program* program) : _geometryAggregator(agv), _drawProgram(program), _maxTargetQuantity(0) { _indirectCommands = new osg::DefaultIndirectCommandDrawArrays; _indirectCommands->getBufferObject()->setUsage(GL_DYNAMIC_DRAW); } void endRegister(unsigned int index, unsigned int rowsPerInstance, GLenum pixelFormat, GLenum type, GLint internalFormat, bool useMultiDrawArraysIndirect) { _indirectCommandTextureBuffer = new osg::TextureBuffer(_indirectCommands.get()); _indirectCommandTextureBuffer->setInternalFormat(GL_R32I); _indirectCommandTextureBuffer->setUnRefImageDataAfterApply(false); _indirectCommandImageBinding = new osg::BindImageTexture(index, _indirectCommandTextureBuffer.get(), osg::BindImageTexture::READ_WRITE, GL_R32I); // add proper primitivesets to geometryAggregators if (!useMultiDrawArraysIndirect) // use glDrawArraysIndirect() { std::vector<osg::DrawArraysIndirect*> newPrimitiveSets; for (unsigned int j = 0; j < _indirectCommands->size(); ++j) { osg::DrawArraysIndirect *ipr = new osg::DrawArraysIndirect(GL_TRIANGLES, j); ipr->setIndirectCommandArray(_indirectCommands.get()); newPrimitiveSets.push_back(ipr); } _geometryAggregator->getAggregatedGeometry()->removePrimitiveSet(0, _geometryAggregator->getAggregatedGeometry()->getNumPrimitiveSets()); for (unsigned int j = 0; j < _indirectCommands->size(); ++j) _geometryAggregator->getAggregatedGeometry()->addPrimitiveSet(newPrimitiveSets[j]); } else // use glMultiDrawArraysIndirect() { osg::MultiDrawArraysIndirect *ipr = new osg::MultiDrawArraysIndirect(GL_TRIANGLES); ipr->setIndirectCommandArray(_indirectCommands.get()); _geometryAggregator->getAggregatedGeometry()->removePrimitiveSet(0, _geometryAggregator->getAggregatedGeometry()->getNumPrimitiveSets()); _geometryAggregator->getAggregatedGeometry()->addPrimitiveSet(ipr); } _geometryAggregator->getAggregatedGeometry()->setUseDisplayList(false); _geometryAggregator->getAggregatedGeometry()->setUseVertexBufferObjects(true); osg::Image* instanceTargetImage = new osg::Image; instanceTargetImage->allocateImage(_maxTargetQuantity*rowsPerInstance, 1, 1, pixelFormat, type); osg::VertexBufferObject * instanceTargetImageBuffer = new osg::VertexBufferObject(); instanceTargetImageBuffer->setUsage(GL_DYNAMIC_DRAW); instanceTargetImage->setBufferObject(instanceTargetImageBuffer); _instanceTarget = new osg::TextureBuffer(instanceTargetImage); _instanceTarget->setInternalFormat(internalFormat); _instanceTargetimagebinding = new osg::BindImageTexture(OV_MAXIMUM_INDIRECT_TARGET_NUMBER + index, _instanceTarget.get(), osg::BindImageTexture::READ_WRITE, internalFormat); _geometryAggregator->generateTextureArray(); } void addIndirectCommandData(const std::string& uniformNamePrefix, int index, osg::StateSet* stateset) { std::string uniformName = uniformNamePrefix + char('0' + index); osg::Uniform* uniform = new osg::Uniform(uniformName.c_str(), (int)index); stateset->addUniform(uniform); stateset->setAttribute(_indirectCommandImageBinding); stateset->setTextureAttribute(index, _indirectCommandTextureBuffer.get()); } void addIndirectTargetData(bool cullPhase, const std::string& uniformNamePrefix, int index, osg::StateSet* stateset) { std::string uniformName; if (cullPhase) uniformName = uniformNamePrefix + char('0' + index); else uniformName = uniformNamePrefix; osg::Uniform* uniform = new osg::Uniform(uniformName.c_str(), (int)(OV_MAXIMUM_INDIRECT_TARGET_NUMBER + index)); stateset->addUniform(uniform); stateset->setAttribute(_instanceTargetimagebinding); stateset->setTextureAttribute(OV_MAXIMUM_INDIRECT_TARGET_NUMBER + index, _instanceTarget.get()); } void addDrawProgram(const std::string& uniformBlockName, osg::StateSet* stateset) { _drawProgram->addBindUniformBlock(uniformBlockName, 1); stateset->setAttributeAndModes(_drawProgram.get(), osg::StateAttribute::PROTECTED | osg::StateAttribute::ON); } osg::ref_ptr< osg::DefaultIndirectCommandDrawArrays > _indirectCommands; osg::ref_ptr<osg::TextureBuffer> _indirectCommandTextureBuffer; osg::ref_ptr<osg::BindImageTexture> _indirectCommandImageBinding; osg::ref_ptr< AggregateGeometryVisitor > _geometryAggregator; osg::ref_ptr<osg::Program> _drawProgram; osg::ref_ptr< osg::TextureBuffer > _instanceTarget; osg::ref_ptr<osg::BindImageTexture> _instanceTargetimagebinding; unsigned int _maxTargetQuantity; }; // This is the main structure holding all information about particular 2-phase instance rendering // ( instance types, indirect targets, etc ). struct GPUCullData { GPUCullData() : _maxHeight(0) { useMultiDrawArraysIndirect = false; instanceTypes = new osg::BufferTemplate< std::vector<InstanceType> >; // build Uniform BufferObject with instanceTypes data instanceTypesUBO = new osg::UniformBufferObject; // instanceTypesUBO->setUsage( GL_STREAM_DRAW ); instanceTypes->setBufferObject(instanceTypesUBO.get()); instanceTypesUBB = new osg::UniformBufferBinding(1, instanceTypes.get(), 0, 0); } void setUseMultiDrawArraysIndirect(bool value) { useMultiDrawArraysIndirect = value; } void registerIndirectTarget(unsigned int index, AggregateGeometryVisitor* agv, osg::Program* targetDrawProgram) { if (index >= OV_MAXIMUM_INDIRECT_TARGET_NUMBER || agv == NULL || targetDrawProgram == NULL) return; targets[index] = IndirectTarget(agv, targetDrawProgram); } bool registerType(unsigned int typeID, unsigned int targetID, osg::Node* node, float maxDensityPerSquareKilometer, float max_dist, float probablity, const MeshTypeConfig::MeshLODConfig &config) { if (typeID >= instanceTypes->getData().size()) instanceTypes->getData().resize(typeID + 1); InstanceType& itd = instanceTypes->getData().at(typeID); unsigned int lodNumber = (unsigned int)itd.params.x(); if (lodNumber >= OV_MAXIMUM_LOD_NUMBER) return false; std::map<unsigned int, IndirectTarget>::iterator target = targets.find(targetID); if (target == targets.end()) return false; // AggregateGeometryVisitor creates single osg::Geometry from all objects used by specific indirect target AggregateGeometryVisitor::AddObjectResult aoResult = target->second._geometryAggregator->addObject(node, typeID, lodNumber); // Information about first vertex and a number of vertices is stored for later primitiveset creation target->second._indirectCommands->push_back(osg::DrawArraysIndirectCommand(aoResult.count, 1, aoResult.first)); osg::ComputeBoundsVisitor cbv; node->accept(cbv); _maxHeight = osg::maximum<double>(_maxHeight, cbv.getBoundingBox().zMax()); itd.setLodDefinition(lodNumber, targetID, aoResult.index, target->second._maxTargetQuantity, cbv.getBoundingBox(), config); itd.setProbability(probablity); const osg::Vec4 lodDistances = config.Distance; // Indirect target texture buffers have finite size, therefore each instance LOD has maximum number that may be rendered in one frame. float lodArea = 0; if(max_dist > 0) lodArea = osg::PI * (max_dist * max_dist); else // This maximum number of rendered instances is estimated from the area that LOD covers and maximum density of instances per square kilometer. lodArea = osg::PI * (lodDistances.w() * lodDistances.w() - lodDistances.x() * lodDistances.x()); // calculate max quantity of objects in lodArea using maximum density per square kilometer const unsigned int maxQuantity = (unsigned int)ceil(lodArea * maxDensityPerSquareKilometer); target->second._maxTargetQuantity += maxQuantity; return true; } // endRegister() method is called after all indirect targets and instance types are registered. // It creates indirect targets with pixel format and data type provided by user ( indirect targets may hold // different information about single instance depending on user's needs ( in our example : static rendering // sends all vertex data to indirect target during GPU cull phase, while dynamic rendering sends only a "pointer" // to texture buffer containing instance data ( look at endRegister() invocations in createStaticRendering() and // createDynamicRendering() ) void endRegister(unsigned int rowsPerInstance, GLenum pixelFormat, GLenum type, GLint internalFormat) { OSG_INFO << "instance types" << std::endl; for (unsigned int i = 0; i < instanceTypes->getData().size(); ++i) { InstanceType& iType = instanceTypes->getData().at(i); int sum = 0; OSG_INFO << "Type " << i << " : ( "; int lodCount = iType.params.x(); for (int j = 0; j < lodCount; ++j) { OSG_INFO << "{" << iType.lods[j].indirectTargetParams.x() << "}" << iType.lods[j].indirectTargetParams.z() << "->" << iType.lods[j].indirectTargetParams.w() << " "; sum += iType.lods[j].indirectTargetParams.w(); } OSG_INFO << ") => " << sum << " elements" << std::endl; } OSG_INFO << "indirect targets" << std::endl; std::map<unsigned int, IndirectTarget>::iterator it, eit; for (it = targets.begin(), eit = targets.end(); it != eit; ++it) { for (unsigned j = 0; j < it->second._indirectCommands->size(); ++j) { osg::DrawArraysIndirectCommand& iComm = it->second._indirectCommands->at(j); OSG_INFO << "(" << iComm.first << " " << iComm.instanceCount << " " << iComm.count << ") "; } unsigned int sizeInBytes = (unsigned int)it->second._maxTargetQuantity * sizeof(osg::Vec4); OSG_INFO << " => Maximum elements in target : " << it->second._maxTargetQuantity << " ( " << sizeInBytes << " bytes, " << sizeInBytes / 1024 << " kB )" << std::endl; } instanceTypesUBB->setSize(instanceTypes->getTotalDataSize()); for (it = targets.begin(), eit = targets.end(); it != eit; ++it) it->second.endRegister(it->first, rowsPerInstance, pixelFormat, type, internalFormat, useMultiDrawArraysIndirect); } bool useMultiDrawArraysIndirect; osg::ref_ptr< osg::BufferTemplate< std::vector<InstanceType> > > instanceTypes; osg::ref_ptr<osg::UniformBufferObject> instanceTypesUBO; osg::ref_ptr<osg::UniformBufferBinding> instanceTypesUBB; double _maxHeight; std::map<unsigned int, IndirectTarget> targets; }; }
40.523573
176
0.706693
[ "geometry", "object", "vector" ]
24db3ed21425049056105a8e6f854e287c5ae321
12,217
h
C
pkgs/apps/facesim/src/Public_Library/Matrices_And_Vectors/QUATERNION.h
relokin/parsec
75d63d9bd2368913343be9037e301947ecf78f7f
[ "BSD-3-Clause" ]
2
2017-04-24T22:37:28.000Z
2020-05-26T01:57:37.000Z
pkgs/apps/facesim/src/Public_Library/Matrices_And_Vectors/QUATERNION.h
cota/parsec2-aarch64
cdf7da348afd231dbe067266f24dc14d22f5cebf
[ "BSD-3-Clause" ]
null
null
null
pkgs/apps/facesim/src/Public_Library/Matrices_And_Vectors/QUATERNION.h
cota/parsec2-aarch64
cdf7da348afd231dbe067266f24dc14d22f5cebf
[ "BSD-3-Clause" ]
null
null
null
//##################################################################### // Copyright 2002-2005, Robert Bridson, Ronald Fedkiw, Eran Guendelman, Geoffrey Irving, Igor Neverov, Eftychios Sifakis, Joseph Teran, Rachel Weinstein. // This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt. //##################################################################### // Class QUATERNION //##################################################################### #ifndef __QUATERNION__ #define __QUATERNION__ #include <math.h> #include <iostream> #include "VECTOR_3D.h" #include "MATRIX_4X4.h" #include "VECTOR_ND.h" #include "../Math_Tools/constants.h" #include "../Math_Tools/clamp.h" namespace PhysBAM{ template<class T> class QUATERNION{ public: T s; // cos(theta/2) VECTOR_3D<T> v; QUATERNION() :s(1) // note that the vector v is set to (0,0,0) by default {} template<class T2> QUATERNION(const QUATERNION<T2>& q) :s((T)q.s),v(q.v) {} QUATERNION(const T s,const T x,const T y,const T z) :s(s),v(x,y,z) {} QUATERNION(const T angle,const VECTOR_3D<T>& direction) :s(cos(angle/2)),v(direction) { v.Normalize();v*=sin(angle/2); } QUATERNION(const T euler_angle_x,const T euler_angle_y,const T euler_angle_z) { *this=QUATERNION<T>(euler_angle_z,VECTOR_3D<T>(0,0,1))*QUATERNION<T>(euler_angle_y,VECTOR_3D<T>(0,1,0))*QUATERNION<T>(euler_angle_x,VECTOR_3D<T>(1,0,0)); } QUATERNION(const VECTOR_3D<T>& v_input) // makes a vector into a quaternion (note difference from From_Rotation_Vector!) :s(0),v(v_input) {} QUATERNION(const VECTOR_ND<T>& v_input) // used to make a vector from a 4 vector :s(v_input(1)),v(v_input(2),v_input(3),v_input(4)) {assert(v_input.n==4);} QUATERNION(const MATRIX_3X3<T>& A) // matches A with a quaternion {T trace=1+A(1,1)+A(2,2)+A(3,3);// trace=4*cos^2(theta/2) if(trace > 1){s=T(.5)*sqrt(trace);v.x=A(3,2)-A(2,3);v.y=A(1,3)-A(3,1);v.z=A(2,1)-A(1,2);v*=T(.25)/s;} else{int i=(A(1,1) > A(2,2)) ? 1:2;i=(A(i,i) > A(3,3)) ? i:3; // set i to be the index of the dominating diagonal term switch(i){ case 1:v.x=T(.5)*sqrt(1+A(1,1)-A(2,2)-A(3,3));v.y=T(.25)*(A(2,1)+A(1,2))/v.x;v.z=T(.25)*(A(1,3)+A(3,1))/v.x;s=T(.25)*(A(3,2)-A(2,3))/v.x;break; case 2:v.y=T(.5)*sqrt(1-A(1,1)+A(2,2)-A(3,3));v.x=T(.25)*(A(2,1)+A(1,2))/v.y;v.z=T(.25)*(A(3,2)+A(2,3))/v.y;s=T(.25)*(A(1,3)-A(3,1))/v.y;break; case 3:v.z=T(.5)*sqrt(1-A(1,1)-A(2,2)+A(3,3));v.x=T(.25)*(A(1,3)+A(3,1))/v.z;v.y=T(.25)*(A(3,2)+A(2,3))/v.z;s=T(.25)*(A(2,1)-A(1,2))/v.z;break;}}} QUATERNION(const MATRIX_4X4<T>& A) // matches rotation part of A with a quaternion {T trace=1+A(1,1)+A(2,2)+A(3,3);// trace=4*cos^2(theta/2) if(trace > 1){s=T(.5)*sqrt(trace);v.x=A(3,2)-A(2,3);v.y=A(1,3)-A(3,1);v.z=A(2,1)-A(1,2);v*=T(.25)/s;} else{int i=(A(1,1) > A(2,2)) ? 1:2;i=(A(i,i) > A(3,3)) ? i:3; // set i to be the index of the dominating diagonal term switch(i){ case 1:v.x=T(.5)*sqrt(1+A(1,1)-A(2,2)-A(3,3));v.y=T(.25)*(A(2,1)+A(1,2))/v.x;v.z=T(.25)*(A(1,3)+A(3,1))/v.x;s=T(.25)*(A(3,2)-A(2,3))/v.x;break; case 2:v.y=T(.5)*sqrt(1-A(1,1)+A(2,2)-A(3,3));v.x=T(.25)*(A(2,1)+A(1,2))/v.y;v.z=T(.25)*(A(3,2)+A(2,3))/v.y;s=T(.25)*(A(1,3)-A(3,1))/v.y;break; case 3:v.z=T(.5)*sqrt(1-A(1,1)-A(2,2)+A(3,3));v.x=T(.25)*(A(1,3)+A(3,1))/v.z;v.y=T(.25)*(A(3,2)+A(2,3))/v.z;s=T(.25)*(A(2,1)-A(1,2))/v.z;break;}}} bool operator==(const QUATERNION<T>& q) const {return s == q.s && v == q.v;} bool operator!=(const QUATERNION<T>& q) const {return s != q.s || v != q.v;} QUATERNION<T> operator-() const {return QUATERNION<T>(-s,-v.x,-v.y,-v.z);} QUATERNION<T>& operator+=(const QUATERNION<T>& q) {s+=q.s,v.x+=q.v.x,v.y+=q.v.y,v.z+=q.v.z;return *this;} QUATERNION<T>& operator-=(const QUATERNION<T>& q) {s-=q.s,v.x-=q.v.x,v.y-=q.v.y,v.z-=q.v.z;return *this;} QUATERNION<T>& operator*=(const QUATERNION<T>& q) {return *this=*this*q;} QUATERNION<T>& operator*=(const T a) {s*=a;v*=a;return *this;} QUATERNION<T>& operator/=(const T a) {assert(a!=0);T r=1/a;s*=r;v*=r;return *this;} QUATERNION<T> operator+(const QUATERNION<T>& q) const {return QUATERNION<T>(s+q.s,v.x+q.v.x,v.y+q.v.y,v.z+q.v.z);} QUATERNION<T> operator-(const QUATERNION<T>& q) const {return QUATERNION<T>(s-q.s,v.x-q.v.x,v.y-q.v.y,v.z-q.v.z);} QUATERNION<T> operator*(const QUATERNION<T>& q) const // 16 mult and 13 add/sub {VECTOR_3D<T> r=s*q.v+q.s*v+VECTOR_3D<T>::Cross_Product(v,q.v);return QUATERNION<T>(s*q.s-VECTOR_3D<T>::Dot_Product(v,q.v),r.x,r.y,r.z);} QUATERNION<T> operator*(const T a) const {return QUATERNION<T>(s*a,v.x*a,v.y*a,v.z*a);} QUATERNION<T> operator/(const T a) const {assert(a != 0);T r=1/a;return QUATERNION<T>(s*r,v.x*r,v.y*r,v.z*r); } T Magnitude() const {return sqrt(sqr(s)+sqr(v.x)+sqr(v.y)+sqr(v.z));} T Magnitude_Squared() const {return sqr(s)+sqr(v.x)+sqr(v.y)+sqr(v.z);} T Max_Abs_Element() const {return maxabs(s,v.x,v.y,v.z);} void Normalize() {T magnitude=Magnitude();assert(magnitude != 0);T r=1/magnitude;s*=r;v.x*=r;v.y*=r;v.z*=r;} T Robust_Normalize(T tolerance=(T)1e-8,const QUATERNION<T>& fallback=QUATERNION<T>(1,0,0,0)) {T magnitude=Magnitude();if(magnitude>tolerance){T r=1/magnitude;s*=r;v.x*=r;v.y*=r;v.z*=r;}else{*this=fallback;}return magnitude;} QUATERNION<T> Normalized() const {QUATERNION<T> q(*this);q.Normalize();return q;} QUATERNION<T> Robust_Normalized(T tolerance=(T)1e-8,const QUATERNION<T>& fallback=QUATERNION<T>(1,0,0,0)) {T magnitude=Magnitude();if(magnitude>tolerance) return *this/magnitude;else return fallback;} void Invert() {*this=Inverse();} QUATERNION<T> Inverse() const {return QUATERNION<T>(s,-v.x,-v.y,-v.z);} static QUATERNION<T> Switch_Hemisphere(const QUATERNION<T>& current_hemisphere_quaternion,const QUATERNION<T>& check_quaternion) {if(Dot_Product(current_hemisphere_quaternion,check_quaternion) < 0) return -check_quaternion; else return check_quaternion;} static T Dot_Product(const QUATERNION<T>& q1,const QUATERNION<T>& q2) {return q1.s*q2.s+q1.v.x*q2.v.x+q1.v.y*q2.v.y+q1.v.z*q2.v.z;} VECTOR_3D<T> Rotation_Vector() const {if(v.Magnitude() == 0.0) return VECTOR_3D<T>(); // return identity return 2*(T)acos(s)*v.Normalized();} static QUATERNION<T> From_Rotation_Vector(const VECTOR_3D<T>& v) {if(v.Magnitude() == 0.0) return QUATERNION<T>(); // return identity else return QUATERNION<T>(v.Magnitude(),v);} VECTOR_3D<T> Rotate(const VECTOR_3D<T>& v) const // 32 mult and 26 add/sub {QUATERNION<T> q=*this*QUATERNION<T>(v)*Inverse();return q.v;} VECTOR_3D<T> Inverse_Rotate(const VECTOR_3D<T>& v) const {QUATERNION<T> q=Inverse()*QUATERNION<T>(v)*(*this);return q.v;} void Euler_Angles(T& euler_angle_x,T& euler_angle_y,T& euler_angle_z) const {T r11=1-2*sqr(v.y)-2*sqr(v.z),r12=2*(v.x*v.y-s*v.z),r21=2*(v.x*v.y+s*v.z),r22=1-2*sqr(v.x)-2*sqr(v.z),r31=2*(v.x*v.z-v.y*s),r32=2*(v.y*v.z+v.x*s),r33=1-2*sqr(v.x)-2*sqr(v.y); T cos_beta=sqrt(sqr(r11)+sqr(r21)); if(cos_beta < 1e-14){ euler_angle_z=0; if(r31 > 0){euler_angle_x=-atan2(r12,r22);euler_angle_y=-(T).5*(T)pi;} else{euler_angle_x=atan2(r12,r22);euler_angle_y=(T).5*(T)pi;}} else{ T secant_beta=1/cos_beta; euler_angle_x=atan2(r32*secant_beta,r33*secant_beta); // between -pi and pi euler_angle_y=atan2(-r31,cos_beta); // between -pi/2 and pi/2 euler_angle_z=atan2(r21*secant_beta,r11*secant_beta);}} // between -pi and pi void Get_Rotated_Frame(VECTOR_3D<T>& x_axis,VECTOR_3D<T>& y_axis,VECTOR_3D<T>& z_axis) const // assumes quaternion is normalized {T vx2=sqr(v.x),vy2=sqr(v.y),vz2=sqr(v.z),vxvy=v.x*v.y,vxvz=v.x*v.z,vyvz=v.y*v.z,svx=s*v.x,svy=s*v.y,svz=s*v.z; x_axis=VECTOR_3D<T>(1-2*(vy2+vz2),2*(vxvy+svz),2*(vxvz-svy)); // Q*(1,0,0) y_axis=VECTOR_3D<T>(2*(vxvy-svz),1-2*(vx2+vz2),2*(vyvz+svx)); // Q*(0,1,0) z_axis=VECTOR_3D<T>(2*(vxvz+svy),2*(vyvz-svx),1-2*(vx2+vy2));} // Q*(0,0,1) void Get_Angle_Axis(T& angle,VECTOR_3D<T>& axis) const {if(s==1){angle=0;axis=VECTOR_3D<T>();} angle=acos(s);axis=v/sin(angle);angle*=2;} T Angle() const {return 2*acos(s);} VECTOR_ND<T> Four_Vector() const {VECTOR_ND<T> vector(4);vector.x[0]=s;vector.x[1]=v.x;vector.x[2]=v.y;vector.x[3]=v.z;return vector;} VECTOR_3D<T> Get_Rotation_Vector() const {if(s==1) return VECTOR_3D<T>(); T angle_over_two=acos(s),angle=2*angle_over_two;return v*(angle/sin(angle_over_two));} MATRIX_3X3<T> Matrix_3X3() const // assumes quaternion is normalized; 18 mult and 12 add/sub {T vx2=sqr(v.x),vy2=sqr(v.y),vz2=sqr(v.z),vxvy=v.x*v.y,vxvz=v.x*v.z,vyvz=v.y*v.z,svx=s*v.x,svy=s*v.y,svz=s*v.z; return MATRIX_3X3<T>(1-2*(vy2+vz2),2*(vxvy+svz),2*(vxvz-svy), 2*(vxvy-svz),1-2*(vx2+vz2),2*(vyvz+svx), 2*(vxvz+svy),2*(vyvz-svx),1-2*(vx2+vy2));} MATRIX_4X4<T> Matrix_4X4() const // assumes quaternion is normalized {T vx2=sqr(v.x),vy2=sqr(v.y),vz2=sqr(v.z),vxvy=v.x*v.y,vxvz=v.x*v.z,vyvz=v.y*v.z,svx=s*v.x,svy=s*v.y,svz=s*v.z; return MATRIX_4X4<T>(1-2*(vy2+vz2),2*(vxvy+svz),2*(vxvz-svy),0, 2*(vxvy-svz),1-2*(vx2+vz2),2*(vyvz+svx),0, 2*(vxvz+svy),2*(vyvz-svx),1-2*(vx2+vy2),0, 0,0,0,1);} static QUATERNION<T> Linear_Interpolation(const QUATERNION<T>& q1,const QUATERNION<T>& q2,const T t) {QUATERNION<T> q=(1-t)*q1+t*q2;q.Normalize();return q;} static QUATERNION<T> Spherical_Linear_Interpolation(const QUATERNION<T>& q1,const QUATERNION<T>& q2,const T t) {T sign=1,cos_theta=Dot_Product(q1,q2);if(cos_theta<0){cos_theta*=-1;sign=-1;}cos_theta=min(cos_theta,(T)1);T theta=acos(cos_theta); if(theta<1e-6) return (sign*(1-t))*q1+t*q2; // Linear but not normalized because the worst normalization error will be on the order of 1e-12 else{ T sin_theta=sqrt(1-sqr(cos_theta)),sin_t_theta=sin(t*theta),sin_one_minus_t_theta=sin_theta*sqrt(1-sqr(sin_t_theta))-sin_t_theta*cos_theta; return (1/sin_theta)*((sign*sin_one_minus_t_theta)*q1+sin_t_theta*q2);}} static QUATERNION<T> Rotation_Quaternion(const VECTOR_3D<T>& initial_vector,const VECTOR_3D<T>& final_vector) {VECTOR_3D<T> initial_unit=initial_vector/initial_vector.Magnitude(),final_unit=final_vector/final_vector.Magnitude(); T cos_theta=clamp(VECTOR_3D<T>::Dot_Product(initial_unit,final_unit),(T)-1.0,(T)1.0); VECTOR_3D<T> v=VECTOR_3D<T>::Cross_Product(initial_unit,final_unit); T v_magnitude=v.Magnitude();if(v_magnitude == 0) return QUATERNION<T>(); //initial and final vectors are collinear T s_squared=(T).5*(1+cos_theta); // uses the half angle formula T v_magnitude_desired=sqrt(1-s_squared);v*=(v_magnitude_desired/v_magnitude); return QUATERNION<T>(sqrt(s_squared),v.x,v.y,v.z);} void Print() const {std::cout << "QUATERNION<T>: " << s << " " << v.x << " " << v.y << " " << v.z << std::endl;} template<class RW> void Read(std::istream& input_stream) {Read_Binary<RW>(input_stream,s);v.template Read<RW>(input_stream);} template<class RW> void Write(std::ostream& output_stream) const {Write_Binary<RW>(output_stream,s);v.template Write<RW>(output_stream);} //##################################################################### }; template<class T> inline QUATERNION<T> operator*(const T a,const QUATERNION<T>& q) {return QUATERNION<T>(q.s*a,q.v.x*a,q.v.y*a,q.v.z*a);} template<class T> inline std::ostream& operator<<(std::ostream& output_stream,const QUATERNION<T>& q) {output_stream << q.s << " " << q.v;return output_stream; } template<class T> inline std::istream& operator>>(std::istream& input_stream, QUATERNION<T>& q) {input_stream >> q.s >> q.v;q.Normalize();return input_stream;} } #endif
47.536965
179
0.609642
[ "vector" ]
24e914977e512ab0bdda51e25b5c9473cbeba892
4,858
h
C
src/chrono/fea/ChMaterialBeamANCF.h
lucasw/chrono
e79d8c761c718ecb4c796725cff37026f357da8c
[ "BSD-3-Clause" ]
1,383
2015-02-04T14:17:40.000Z
2022-03-30T04:58:16.000Z
src/chrono/fea/ChMaterialBeamANCF.h
pchaoWT/chrono
fd68d37d1d4ee75230dc1eea78ceff91cca7ac32
[ "BSD-3-Clause" ]
245
2015-01-11T15:30:51.000Z
2022-03-30T21:28:54.000Z
src/chrono/fea/ChMaterialBeamANCF.h
pchaoWT/chrono
fd68d37d1d4ee75230dc1eea78ceff91cca7ac32
[ "BSD-3-Clause" ]
351
2015-02-04T14:17:47.000Z
2022-03-30T04:42:52.000Z
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Michael Taylor, Antonio Recuero, Radu Serban // ============================================================================= // Material class for ANCF beam elements using the Enhanced Continuum Mechanics based method // // A description of the Enhanced Continuum Mechanics based method can be found in: K. Nachbagauer, P. Gruber, and J. // Gerstmayr. Structural and Continuum Mechanics Approaches for a 3D Shear Deformable ANCF Beam Finite Element : // Application to Static and Linearized Dynamic Examples.J.Comput.Nonlinear Dynam, 8 (2) : 021004, 2012. // ============================================================================= #ifndef CHMATERIALBEAMANCF_H #define CHMATERIALBEAMANCF_H #include "chrono/fea/ChElementBeam.h" namespace chrono { namespace fea { /// @addtogroup fea_elements /// @{ /// Definition of materials to be used for ANCF beams utilizing the Enhanced Continuum Mechanics based method class ChApi ChMaterialBeamANCF { public: /// Construct an isotropic material. ChMaterialBeamANCF(double rho, ///< material density double E, ///< Young's modulus double nu, ///< Poisson ratio double k1, ///< Shear correction factor along beam local y axis double k2 ///< Shear correction factor along beam local z axis ); /// Construct a (possibly) orthotropic material. ChMaterialBeamANCF(double rho, ///< material density const ChVector<>& E, ///< elasticity moduli (E_x, E_y, E_z) const ChVector<>& nu, ///< Poisson ratios (nu_xy, nu_xz, nu_yz) const ChVector<>& G, ///< shear moduli (G_xy, G_xz, G_yz) double k1, ///< Shear correction factor along beam local y axis double k2 ///< Shear correction factor along beam local z axis ); /// Return the material density. double Get_rho() const { return m_rho; } /// Complete Elasticity Tensor in 6x6 matrix form void Get_D(ChMatrixNM<double, 6, 6>& D); /// Diagonal components of the 6x6 elasticity matrix form without the terms contributing to the Poisson effect const ChVectorN<double, 6>& Get_D0() const { return m_D0; } /// Upper 3x3 block of the elasticity matrix with the terms contributing to the Poisson effect const ChMatrixNM<double, 3, 3>& Get_Dv() const { return m_Dv; } /// Return the matrix of elastic coefficients: Diagonal terms. (For compatibility with ChElementBeam only) const ChMatrixNM<double, 6, 6>& Get_E_eps() const { return m_E_eps; } /// Return the matrix of elastic coefficients: Coupling terms. (For compatibility with ChElementBeam only) const ChMatrixNM<double, 6, 6>& Get_E_eps_Nu() const { return m_E_eps_Nu; } private: /// Calculate the matrix form of two stiffness tensors used by the ANCF beam for selective reduced integration of /// the Poisson effect k1 and k2 are Timoshenko shear correction factors. void Calc_D0_Dv(const ChVector<>& E, const ChVector<>& nu, const ChVector<>& G, double k1, double k2); /// Calculate the matrix of elastic coefficients: k1 and k2 are Timoshenko shear correction factors. (For /// compatibility with ChElementBeam only) void Calc_E_eps(const ChVector<>& E, const ChVector<>& nu, const ChVector<>& G, double k1, double k2); /// Calculate the matrix of elastic coefficients. (For compatibility with ChElementBeam only) void Calc_E_eps_Nu(const ChVector<>& E, const ChVector<>& nu, const ChVector<>& G); double m_rho; ///< density ChVectorN<double, 6> m_D0; ///< Diagonal components of the 6x6 elasticity matrix form without the terms ///< contributing to the Poisson effect ChMatrixNM<double, 3, 3> m_Dv; ///< Upper 3x3 block of the elasticity matrix with the terms contributing to the Poisson effect ChMatrixNM<double, 6, 6> m_E_eps; ///< matrix of elastic coefficients (For compatibility with ChElementBeam only) ChMatrixNM<double, 6, 6> m_E_eps_Nu; ///< matrix of elastic coefficients (For compatibility with ChElementBeam only) public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; /// @} fea_elements } // end of namespace fea } // end of namespace chrono #endif
48.09901
118
0.632359
[ "3d" ]
24edfaced3b720b100ddc935b98b18c2472e2843
1,529
h
C
include/cdm_FieldFileNameFormat.h
jorji/CDMlib
863f1e10739e502d74de52f9e4526d1ff6ddc20e
[ "BSD-2-Clause" ]
null
null
null
include/cdm_FieldFileNameFormat.h
jorji/CDMlib
863f1e10739e502d74de52f9e4526d1ff6ddc20e
[ "BSD-2-Clause" ]
null
null
null
include/cdm_FieldFileNameFormat.h
jorji/CDMlib
863f1e10739e502d74de52f9e4526d1ff6ddc20e
[ "BSD-2-Clause" ]
null
null
null
#ifndef _CDM_FIELDFILENAMEFORMAT_H_ #define _CDM_FIELDFILENAMEFORMAT_H_ /* ################################################################################### # # CDMlib - Cartesian Data Management library # # Copyright (c) 2013-2017 Advanced Institute for Computational Science (AICS), RIKEN. # All rights reserved. # # Copyright (c) 2016-2017 Research Institute for Information Technology (RIIT), Kyushu University. # All rights reserved. # ################################################################################### */ #include<map> #include "cdm_FieldFileNameFormatElem.h" class cdm_FieldFileNameFormat { public: vector<string> LabelList; map<string,cdm_FieldFileNameFormatElem> mapElem; public: /** コンストラクタ */ cdm_FieldFileNameFormat(); /** デストラクタ */ ~cdm_FieldFileNameFormat(); public: /** TextParser */ CDM::E_CDM_ERRORCODE //Read(TextParser *tp); Read(cdm_TextParser tpCntl); /** パラメータの出力 */ void Print(); /** FieldFileNameFormatElemクラスの追加 */ bool AddFieldFileNameFormatElem(cdm_FieldFileNameFormatElem elem); /** FieldFileNameFormatElemクラスの取得 */ cdm_FieldFileNameFormatElem* GetFieldFileNameFormatElem(const string label); /** label list の取得 */ vector<string> GetLabelList(); /** File有無判定 */ bool FileExist(string label, string DirPath, int nStep, int nId); /** File名生成 */ string GenerateFileName(string label, string DirPath, int nStep, int nId); /** index.dfi FieldFileNameFormat{} 出力 */ void Write(FILE *fp, const unsigned tab); }; #endif
22.15942
98
0.651406
[ "vector" ]
7002c2c5215d2e25118ac908ca770672aa0d7a73
4,132
h
C
Stuff/ReadWriteToFile.h
fishavore/Cpp-Code-Gems
ad21283ba937d04a9bbf532d026e3831ca9ce30b
[ "MIT" ]
null
null
null
Stuff/ReadWriteToFile.h
fishavore/Cpp-Code-Gems
ad21283ba937d04a9bbf532d026e3831ca9ce30b
[ "MIT" ]
null
null
null
Stuff/ReadWriteToFile.h
fishavore/Cpp-Code-Gems
ad21283ba937d04a9bbf532d026e3831ca9ce30b
[ "MIT" ]
null
null
null
#pragma once #include <iostream> #include <fstream> /* /////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////// Copy and paste for debug #include <iostream> #include <fstream> void LLLOG(std::string text) { std::string path = "C:\\temp"; std::string filename = "log.txt"; std::ofstream out; //Create directory if (CreateDirectory(path.c_str(), NULL) || ERROR_ALREADY_EXISTS == GetLastError()) { //Create file std::string fullpath = path + "\\" + filename; out.open(fullpath, std::fstream::in | std::fstream::out | std::fstream::app); if (!out) { out.open(filename, fstream::in | fstream::out | fstream::trunc); } //Log to the file if (out.is_open()) { out << text << std::endl; out.close(); } } } */ /////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////// //For read from file you should use: //Do not use while(!in.eof()){ because the end of file bit will not //be set until *after* a failed read due to end of file. namespace ReadWriteToFile { struct Hacktoberfest { int PR; char t_shirt[60]; }; int FindFileExtension(std::string path) { int ext_type = 0; int pos = path.find("."); string ext = path.substr(pos + 1); if (ext == "txt") { ext_type = 1; } else if (ext == "dat") { ext_type = 2; } return ext_type; } void ReadFromFile(std::string path) { std::ifstream in; int ext_type = FindFileExtension(path); switch (ext_type) { case 1: in.open(path); if (in.is_open()) { //Grab each line until the end of line. { std::vector<std::string> lines; std::string line; while (getline(in, line)) { lines.push_back(line); } } //Setup to read again { in.clear(); in.seekg(0, in.beg); } //Read { std::vector<std::string> lines; std::string word; char achar; achar = in.get(); //Read char. This will even read things like \n. while (true) { if (in.good()) { in >> word; //Reads word by word seperated by blank space or \n. } else { break; } } } in.close(); } else { std::cout << "Read from file error.\n"; } break; case 2: in.open(path, ios::in | ios::binary); if (in.is_open()) { int x; Hacktoberfest hacktoberfest; in.read((char*)&x, sizeof(x)); cout << x << endl; in.read((char*)&hacktoberfest, sizeof(hacktoberfest)); cout << hacktoberfest.PR << endl; cout << hacktoberfest.t_shirt << endl; in.close(); } else { std::cout << "Read from file error.\n"; } break; default: std::cout << "Invalid file extionsion error.\n"; } } void WriteToFile(std::string path) { std::ofstream out; int ext_type = FindFileExtension(path); switch (ext_type) { case 1: out.open(path); if (out.is_open()) { out << "1"; out << "2"; //outputs: 12 out << std::endl; out << "3\n"; out << "4\n"; /* 12 3 4 */ out << "This is a sentence we can use to look at words or specific chars.\n"; out.close(); } else { std::cout << "Write to file error.\n"; } break; case 2: out.open(path, ios::out | ios::binary); if (out.is_open()) { int x = 5678; Hacktoberfest hacktoberfest = { 4, "Support open source and earn a limited edition T-shirt!" }; out.write((char*)&x, sizeof(x)); out.write((char*)&hacktoberfest, sizeof(hacktoberfest)); out.close(); } else { std::cout << "Write to file error.\n"; } break; default: std::cout << "Invalid file extionsion error.\n"; } } void start() { std::string path = "file.txt"; WriteToFile(path); ReadFromFile(path); path = "file.dat"; WriteToFile(path); ReadFromFile(path); } }
18.86758
104
0.506534
[ "vector" ]
2a25f206eb3f5945c8577c13d395e3248f283474
844
h
C
wbs/src/RangerLib/RangerLib.h
RNCan/WeatherBasedSimulationFramework
19df207d11b1dddf414d78e52bece77f31d45df8
[ "MIT" ]
6
2017-05-26T21:19:41.000Z
2021-09-03T14:17:29.000Z
wbs/src/RangerLib/RangerLib.h
RNCan/WeatherBasedSimulationFramework
19df207d11b1dddf414d78e52bece77f31d45df8
[ "MIT" ]
5
2016-02-18T12:39:58.000Z
2016-03-13T12:57:45.000Z
wbs/src/RangerLib/RangerLib.h
RNCan/WeatherBasedSimulationFramework
19df207d11b1dddf414d78e52bece77f31d45df8
[ "MIT" ]
1
2019-06-16T02:49:20.000Z
2019-06-16T02:49:20.000Z
#pragma once #include "RangerLib/globals.h" #include "RangerLib/Utility/DataChar.h" #include "RangerLib/Utility/DataShort.h" #include "RangerLib/Utility/DataFloat.h" #include "RangerLib/Utility/DataDouble.h" #include "RangerLib/Forest/ForestClassification.h" #include "RangerLib/Forest/ForestRegression.h" #include "RangerLib/Forest/ForestSurvival.h" #include "RangerLib/Forest/ForestProbability.h" // Create forest object inline Forest* CreateForest(TreeType treetype) { Forest* forest = NULL; switch (treetype) { case TREE_CLASSIFICATION: forest = new ForestClassification; break; case TREE_REGRESSION: forest = new ForestRegression; break; case TREE_SURVIVAL: forest = new ForestSurvival; break; case TREE_PROBABILITY: forest = new ForestProbability; break; } return forest; }
23.444444
51
0.742891
[ "object" ]
2a2d5efcbc1972a35a7fc95d8ca177eb972f01e8
25,603
h
C
include/private/internal/hld.h
Foxbud/libaermre
9d61eb01e78e7912ed0c01bd109e260bcae0efc0
[ "Apache-2.0" ]
1
2022-03-07T09:54:08.000Z
2022-03-07T09:54:08.000Z
include/private/internal/hld.h
Foxbud/libaermre
9d61eb01e78e7912ed0c01bd109e260bcae0efc0
[ "Apache-2.0" ]
9
2021-01-24T00:01:03.000Z
2021-03-26T17:52:09.000Z
include/private/internal/hld.h
Foxbud/libaermre
9d61eb01e78e7912ed0c01bd109e260bcae0efc0
[ "Apache-2.0" ]
null
null
null
/** * @copyright 2021 the libaermre authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INTERNAL_HLD_H #define INTERNAL_HLD_H #include <assert.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdlib.h> /* ----- INTERNAL MACROS ----- */ #define HLDPrimitiveMakeUndefined(name) \ HLDPrimitive name = {.type = HLD_PRIMITIVE_UNDEFINED} #define HLDPrimitiveMakeReal(name, initVal) \ HLDPrimitive name = {.value.r = (initVal), .type = HLD_PRIMITIVE_REAL} #define HLDPrimitiveMakeStringS(name, str, len) \ HLDPrimitiveString name##InnerValue = { \ .chars = (str), .refs = 1, .length = (len)}; \ HLDPrimitive name = {.value.p = &name##InnerValue, \ .type = HLD_PRIMITIVE_STRING} #define HLDPrimitiveMakeStringH(name, str, len) \ HLDPrimitiveString* name##InnerValue = malloc(sizeof(HLDPrimitiveString)); \ assert(name##InnerValue); \ name##InnerValue->chars = (str); \ name##InnerValue->refs = 1; \ name##InnerValue->length = (len); \ HLDPrimitive name = {.value.p = name##InnerValue, \ .type = HLD_PRIMITIVE_STRING} #define HLDAPICallAdv(api, target, other, ...) \ ({ \ HLDPrimitive HLDAPICallAdv_argv[] = {__VA_ARGS__}; \ HLDPrimitiveMakeUndefined(HLDAPICallAdv_result); \ (api)(&HLDAPICallAdv_result, (target), (other), \ sizeof(HLDAPICallAdv_argv) / sizeof(HLDPrimitive), \ HLDAPICallAdv_argv); \ HLDAPICallAdv_result; \ }) #define HLDAPICall(api, ...) HLDAPICallAdv((api), NULL, NULL, ##__VA_ARGS__) #define HLDScriptCallAdv(script, target, other, ...) \ ({ \ HLDPrimitive* HLDScriptCallAdv_argv[] = {__VA_ARGS__}; \ HLDPrimitiveMakeUndefined(HLDScriptCallAdv_result); \ (script)((target), (other), &HLDScriptCallAdv_result, \ sizeof(HLDScriptCallAdv_argv) / sizeof(HLDPrimitive*), \ HLDScriptCallAdv_argv); \ HLDScriptCallAdv_result; \ }) #define HLDScriptCall(script, ...) \ HLDScriptCallAdv((script), NULL, NULL, ##__VA_ARGS__) #define HLDObjectLookup(objIdx) \ ((HLDObject*)HLDOpenHashTableLookup(*hldvars.objectTableHandle, (objIdx))) #define HLDInstanceLookup(instId) \ ((HLDInstance*)HLDOpenHashTableLookup(hldvars.instanceTable, (instId))) /* ----- INTERNAL TYPES ----- */ typedef enum HLDEventType { HLD_EVENT_CREATE, HLD_EVENT_DESTROY, HLD_EVENT_ALARM, HLD_EVENT_STEP, HLD_EVENT_COLLISION, HLD_EVENT_UNKNOWN_0, HLD_EVENT_UNKNOWN_1, HLD_EVENT_OTHER, HLD_EVENT_DRAW, HLD_EVENT_UNKNOWN_2, HLD_EVENT_UNKNOWN_3, HLD_EVENT_UNKNOWN_4, HLD_EVENT_UNKNOWN_5, HLD_EVENT_UNKNOWN_6, HLD_EVENT_UNKNOWN_7 } HLDEventType; typedef enum HLDEventStepType { HLD_EVENT_STEP_NORMAL, HLD_EVENT_STEP_PRE, HLD_EVENT_STEP_POST } HLDEventStepType; typedef enum HLDEventOtherType { HLD_EVENT_OTHER_ANIMATION_END = 7 } HLDEventOtherType; typedef enum HLDEventDrawType { HLD_EVENT_DRAW_NORMAL = 0, HLD_EVENT_DRAW_GUI_NORMAL = 64 } HLDEventDrawType; typedef struct HLDOpenHashItem { struct HLDOpenHashItem* prev; struct HLDOpenHashItem* next; int32_t key; void* value; } HLDOpenHashItem; typedef struct HLDOpenHashSlot { struct HLDOpenHashItem* first; struct HLDOpenHashItem* last; } HLDOpenHashSlot; typedef struct HLDOpenHashTable { struct HLDOpenHashSlot* slots; uint32_t keyMask; size_t numItems; } HLDOpenHashTable; typedef struct HLDClosedHashSlot { int32_t nameIdx; void* value; int32_t key; } HLDClosedHashSlot; typedef struct HLDClosedHashTable { size_t numSlots; size_t numItems; uint32_t keyMask; uint32_t field_C; struct HLDClosedHashSlot* slots; } HLDClosedHashTable; typedef struct HLDLookupTable { size_t size; uint32_t field_4; uint32_t field_8; void* elements; } HLDLookupTable; typedef struct HLDVecReal { float x; float y; } HLDVecReal; typedef struct HLDVecIntegral { int32_t x; int32_t y; } HLDVecIntegral; typedef struct HLDArrayPreSize { size_t size; void* elements; } HLDArrayPreSize; typedef struct HLDArrayPostSize { void* elements; size_t size; } HLDArrayPostSize; typedef enum HLDPrimitiveType { HLD_PRIMITIVE_REAL = 0x0, HLD_PRIMITIVE_STRING = 0x1, HLD_PRIMITIVE_ARRAY = 0x2, HLD_PRIMITIVE_PTR = 0x3, HLD_PRIMITIVE_VEC3 = 0x4, HLD_PRIMITIVE_UNDEFINED = 0x5, HLD_PRIMITIVE_OBJECT = 0x6, HLD_PRIMITIVE_INT32 = 0x7, HLD_PRIMITIVE_VEC4 = 0x8, HLD_PRIMITIVE_MATRIX = 0x9, HLD_PRIMITIVE_INT64 = 0xA, HLD_PRIMITIVE_ACCESSOR = 0xB, HLD_PRIMITIVE_NULL = 0xC, HLD_PRIMITIVE_BOOL = 0xD, HLD_PRIMITIVE_ITERATOR = 0xE, } HLDPrimitiveType; typedef union __attribute__((aligned(4))) HLDPrimitiveValue { uint32_t raw[3]; double r; void* p; int32_t i32; int64_t i64; bool b; } HLDPrimitiveValue; typedef struct HLDPrimitive { HLDPrimitiveValue value; HLDPrimitiveType type; } HLDPrimitive; typedef struct HLDPrimitiveString { const char* chars; size_t refs; size_t length; } HLDPrimitiveString; typedef struct __attribute__((aligned(4))) HLDPrimitiveArray { uint32_t field_0; struct HLDArrayPreSize* subArrays; void* field_8; uint32_t field_C; size_t numSubArrays; } HLDPrimitiveArray; typedef struct HLDEventSubscribers { int32_t* objects; uint32_t field_4; } HLDEventSubscribers; typedef struct HLDNamedFunction { const char* name; void* function; } HLDNamedFunction; typedef struct HLDNodeDLL { struct HLDNodeDLL* next; struct HLDNodeDLL* prev; void* item; } HLDNodeDLL; typedef struct HLDBoundingBox { int32_t left; int32_t top; int32_t right; int32_t bottom; } HLDBoundingBox; typedef struct HLDEvent { void* classDef; struct HLDEvent* eventNext; uint32_t field_8; uint32_t field_C; void* field_10; uint32_t field_14; uint32_t field_18; uint32_t field_1C; uint32_t field_20; uint32_t field_24; uint32_t field_28; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; uint32_t field_48; uint32_t field_4C; uint32_t field_50; uint32_t field_54; void* field_58; const char* name; uint32_t handlerIndex; struct HLDNamedFunction* handler; uint32_t field_68; uint32_t field_6C; uint32_t field_70; uint32_t field_74; uint32_t field_78; uint32_t field_7C; } HLDEvent; typedef struct HLDEventWrapper { void* classDef; struct HLDEvent* event; void* field_08; uint32_t field_0C; } HLDEventWrapper; typedef struct HLDObject { struct { uint8_t solid : 1; uint8_t visible : 1; uint8_t persistent : 1; uint8_t : 1; uint8_t collisions : 1; uint8_t : 3; } flags; uint8_t field_1; uint8_t field_2; uint8_t field_3; int32_t spriteIndex; uint32_t depth; int32_t parentIndex; int32_t maskIndex; const char* name; int32_t index; uint32_t physics; uint32_t field_20; uint32_t field_24; uint32_t field_28; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; struct HLDObject* parent; struct HLDArrayPreSize eventListeners[15]; struct HLDNodeDLL* instanceFirst; struct HLDNodeDLL* instanceLast; uint32_t numInstances; uint32_t field_D0; uint32_t field_D4; uint32_t field_D8; } HLDObject; typedef struct HLDInstance { void* classDef; uint32_t field_4; uint32_t field_8; uint32_t field_C; uint32_t field_10; uint32_t field_14; uint8_t field_18; uint8_t field_19; uint8_t field_1A; uint8_t field_1B; uint32_t field_1C; uint32_t field_20; uint32_t field_24; uint32_t tangible; uint32_t field_2C; uint32_t field_30; HLDClosedHashTable* locals; uint8_t field_38; bool visible; bool solid; bool persistent; bool marked; bool deactivated; uint8_t field_3E; uint8_t field_3F; uint32_t field_40; uint32_t field_44; uint32_t field_48; uint32_t id; int32_t objectIndex; struct HLDObject* object; uint32_t field_58; uint32_t field_5C; int32_t spriteIndex; float imageIndex; float imageSpeed; struct HLDVecReal imageScale; float imageAngle; float imageAlpha; uint32_t imageBlend; int32_t maskIndex; uint32_t field_84; struct HLDVecReal pos; struct HLDVecReal posStart; struct HLDVecReal posPrev; float direction; float speed; float friction; float gravityDir; float gravity; float speedX; float speedY; struct HLDBoundingBox bbox; int32_t alarms[12]; int32_t pathIndex; float pathPos; float pathPosPrev; uint32_t field_108; uint32_t field_10C; uint32_t field_110; uint32_t field_114; uint32_t field_118; uint32_t field_11C; uint32_t field_120; uint32_t field_124; uint32_t field_128; uint32_t field_12C; uint8_t field_130; uint8_t field_131; uint8_t field_132; uint8_t field_133; uint32_t field_134; uint32_t field_138; uint32_t field_13C; uint32_t field_140; uint32_t field_144; bool field_148; uint8_t field_149; uint8_t field_14A; uint8_t field_14B; struct HLDInstance* instanceNext; struct HLDInstance* instancePrev; float depth; uint32_t field_158; uint32_t lastUpdate; uint32_t field_160; uint32_t field_164; uint32_t field_168; uint32_t field_16C; uint32_t field_170; uint32_t field_174; uint32_t field_178; uint32_t field_17C; uint32_t field_180; } HLDInstance; typedef struct HLDView { bool visible; uint8_t field_1; uint8_t field_2; uint8_t field_3; HLDVecReal posRoom; HLDVecReal sizeRoom; HLDVecIntegral posPort; HLDVecIntegral sizePort; float angle; HLDVecIntegral border; HLDVecIntegral speed; int32_t objectIndex; int32_t surfaceId; int32_t camera; } HLDView; typedef struct HLDRoom { uint32_t field_0; struct HLDRoom* self; uint32_t field_8; uint32_t field_C; uint32_t field_10; uint32_t field_14; uint32_t field_18; uint32_t field_1C; uint32_t field_20; uint32_t field_24; uint32_t field_28; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; HLDView* views[8]; uint32_t field_68; uint32_t field_6C; uint32_t field_70; uint32_t field_74; uint32_t field_78; uint32_t field_7C; struct HLDInstance* instanceFirst; struct HLDInstance* instanceLast; int32_t numInstances; uint32_t field_8C; uint32_t field_90; uint32_t field_94; uint32_t field_98; uint32_t field_9C; uint32_t field_A0; uint32_t field_A4; uint32_t field_A8; uint32_t field_AC; uint32_t field_B0; uint32_t field_B4; uint32_t field_B8; uint32_t field_BC; uint32_t field_C0; uint32_t field_C4; uint32_t field_C8; const char* name; uint32_t field_D0; uint32_t field_D4; uint32_t field_D8; uint32_t field_DC; uint32_t field_E0; uint32_t field_E4; uint32_t field_E8; uint32_t field_EC; uint32_t field_F0; uint32_t field_F4; uint32_t field_F8; uint32_t field_FC; uint32_t field_100; uint32_t field_104; uint32_t field_108; uint32_t field_10C; uint32_t field_110; uint32_t field_114; uint32_t field_118; uint32_t field_11C; uint32_t field_120; } HLDRoom; typedef struct HLDSprite { void* classDef; uint32_t field_4; uint32_t field_8; uint32_t field_C; uint32_t field_10; uint32_t field_14; uint32_t numImages; struct HLDVecIntegral size; struct HLDVecIntegral origin; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; uint32_t field_48; uint32_t field_4C; uint32_t field_50; uint32_t field_54; uint32_t field_58; const char* name; uint32_t index; uint32_t field_64; uint32_t field_68; float speed; uint32_t field_70; uint32_t field_74; uint32_t field_78; uint32_t field_7C; uint32_t field_80; uint32_t field_84; } HLDSprite; typedef struct HLDFont { void* classDef; const char* fontname; size_t size; bool bold; bool italic; uint8_t field_E; uint8_t field_F; uint32_t field_10; uint32_t field_14; int32_t first; int32_t last; uint32_t field_20; uint32_t field_24; uint32_t field_28; uint32_t field_2C; uint32_t field_30; uint32_t field_34; uint32_t field_38; uint32_t field_3C; uint32_t field_40; uint32_t field_44; uint32_t field_48; uint32_t field_4C; uint32_t field_50; uint32_t field_54; uint32_t field_58; uint32_t field_5C; uint32_t field_60; uint32_t field_64; uint32_t field_68; uint32_t field_6C; uint32_t field_70; uint32_t field_74; uint32_t field_78; uint32_t field_7C; uint32_t field_80; uint32_t field_84; uint32_t field_88; uint32_t field_8C; } HLDFont; /* Builtin GML function signature. */ typedef void (*HLDAPICallback)(HLDPrimitive* result, HLDInstance* target, HLDInstance* other, size_t argc, HLDPrimitive* argv); /* Custom Heart Machine function signature. */ typedef HLDPrimitive* (*HLDScriptCallback)(HLDInstance* target, HLDInstance* other, HLDPrimitive* result, size_t argc, HLDPrimitive** argv); /* * This struct holds pointers to global variables in the Game Maker * engine. These pointers are passed into the MRE from the hooks injected * into the game's executable. */ typedef struct __attribute__((packed)) HLDVariables { /* Allocated GML hash tables. */ HLDArrayPostSize* maps; /* Number of steps since start of the game. */ int32_t* numSteps; /* Tables of booleans where each index represents a key code. */ bool (*keysPressedTable)[0x100]; bool (*keysHeldTable)[0x100]; bool (*keysReleasedTable)[0x100]; /* Tables of booleans where each index represents a mouse button. */ bool (*mouseButtonsPressedTable)[0x3]; bool (*mouseButtonsHeldTable)[0x3]; bool (*mouseButtonsReleasedTable)[0x3]; /* Mouse cursor position in pixels. */ uint32_t* mousePosX; uint32_t* mousePosY; /* Array of all registered rooms. */ HLDArrayPreSize* roomTable; /* Index of currently active room. */ int32_t* roomIndexCurrent; /* Actual room object of currently active room. */ HLDRoom** roomCurrent; /* Array of all registered sprites. */ HLDArrayPreSize* spriteTable; /* Array of all registered fonts. */ HLDArrayPreSize* fontTable; /* Index of currently active font. */ int32_t* fontIndexCurrent; /* Actual font object of currently active font. */ HLDFont** fontCurrent; /* Hash table of all registered objects. */ HLDOpenHashTable** objectTableHandle; /* Hash table of all in-game instances. */ HLDOpenHashTable* instanceTable; /* Lookup table of all instance local variable names. */ HLDLookupTable* instanceLocalTable; /* * As an optimization, the engine only checks for alarm events on objects * listed (or "subscribed") in these arrays. */ size_t (*alarmEventSubscriberCounts)[12]; HLDEventSubscribers (*alarmEventSubscribers)[12]; /* Same as above, but for step events. */ size_t (*stepEventSubscriberCounts)[3]; HLDEventSubscribers (*stepEventSubscribers)[3]; /* Addresses necessary for creating new events. */ void* eventClass; void* eventWrapperClass; /* * Not certain what this address even references, but the custom events * won't work unless some of their fields point to this address. */ void* unknownEventAddress; } HLDVariables; /* * This struct holds pointers to functions in the Game Maker * engine. These pointers are passed into the MRE from the hooks injected * into the game's executable. */ typedef struct __attribute__((packed)) HLDFunctions { /* Mouse x position relative to current room. */ int32_t (*actionMouseGetX)(int32_t unknown0); /* Mouse y position relative to current room. */ int32_t (*actionMouseGetY)(int32_t unknown0); /* Go to room. */ void (*actionRoomGoto)(int32_t roomIdx, int32_t unknown0); /* Register a new sprite. */ int32_t (*actionSpriteAdd)(const char* fname, size_t imgNum, int32_t unknown0, int32_t unknown1, int32_t unknown2, int32_t unknown3, uint32_t origX, uint32_t origY); /* Overwrite an existing sprite with a new one. */ void (*actionSpriteReplace)(int32_t spriteIdx, const char* fname, size_t imgNum, int32_t unknown0, int32_t unknown1, int32_t unknown2, int32_t unknown3, uint32_t origX, uint32_t origY); /* Register a new font. */ int32_t (*actionFontAdd)(const char* fname, size_t size, bool bold, bool italic, int32_t first, int32_t last); /* Register a new object. */ int32_t (*actionObjectAdd)(void); /* Trigger an event as if it occurred "naturally." */ int32_t (*actionEventPerform)(HLDInstance* target, HLDInstance* other, int32_t targetObjIdx, uint32_t eventType, int32_t eventNum); /* Get the current global draw alpha. */ float (*actionDrawGetAlpha)(void); /* Set the current global draw alpha. */ void (*actionDrawSetAlpha)(float alpha); /* Draw a sprite to the screen. */ void (*actionDrawSpriteGeneral)(HLDSprite* sprite, uint32_t imgNum, float left, float top, float width, float height, float x, float y, float scaleX, float scaleY, float angle, uint32_t blendNW, uint32_t blendNE, uint32_t blendSE, uint32_t blendSW, float alpha); /* Draw a line to the screen. */ void (*actionDrawLine)(float x1, float y1, float x2, float y2, float width, uint32_t color1, uint32_t color2); /* Draw an ellipse to the screen. */ void (*actionDrawEllipse)(float left, float top, float right, float bottom, uint32_t colorCenter, uint32_t colorEdge, bool outline); /* Draw a triangle to the screen. */ void (*actionDrawTriangle)(float x1, float y1, float x2, float y2, float x3, float y3, uint32_t color1, uint32_t color2, uint32_t color3, bool outline); /* Draw a rectangle to the screen. */ void (*actionDrawRectangle)(float left, float top, float right, float bottom, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, bool outline); /* Draw a string to the screen. */ void (*actionDrawText)(float x, float y, const char* text, int32_t height, uint32_t width, float scaleX, float scaleY, float angle, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, float alpha); /* Draw an instance's sprite. */ void (*actionDrawSelf)(HLDInstance* inst); /* Set the currently active draw font. */ void (*actionDrawSetFont)(int32_t fontIdx); /* Spawn a new instance of an object. */ HLDInstance* (*actionInstanceCreate)(int32_t objIdx, float posX, float posY); /* Change the object type of an instance. */ void (*actionInstanceChange)(HLDInstance* inst, int32_t newObjIdx, bool doEvents); /* Destroy an instance. */ void (*actionInstanceDestroy)(HLDInstance* inst0, HLDInstance* inst1, int32_t objIdx, bool doEvent); /* Set instance's position (and update bounding box accordingly). */ void (*Instance_setPosition)(HLDInstance* inst, float x, float y); /* Set instance's mask index. */ void (*Instance_setMaskIndex)(HLDInstance* inst, int32_t maskIndex); /* Set an instance's direction and speed based on its motion vector. */ void (*Instance_setMotionPolarFromCartesian)(HLDInstance* inst); /* Create a new GML map. Parameters: NULL. */ HLDAPICallback API_dsMapCreate; /* Retrieve value from a GML map. Parameters: id, key. */ HLDAPICallback API_dsMapFindValue; /* Set a GML map key to value. Parameters: id, key, val. */ HLDAPICallback API_dsMapSet; /* * Add a GML map to another GML map for JSON representation. * Parameters: id, key, val. */ HLDAPICallback API_dsMapAddMap; /* * Custom Heart Machine function that sets an instance's draw depth based * on its y position and the current room's height. */ HLDScriptCallback Script_Setdepth; } HLDFunctions; /* ----- INTERNAL GLOBALS ----- */ extern HLDVariables hldvars; extern HLDFunctions hldfuncs; /* ----- INTERNAL FUNCTIONS ----- */ HLDView* HLDViewLookup(uint32_t viewIdx); HLDSprite* HLDSpriteLookup(int32_t spriteIdx); HLDFont* HLDFontLookup(int32_t fontIdx); HLDRoom* HLDRoomLookup(int32_t roomIdx); void* HLDOpenHashTableLookup(HLDOpenHashTable* table, int32_t key); void* HLDClosedHashTableLookup(HLDClosedHashTable* table, int32_t key); HLDEvent* HLDEventNew(HLDNamedFunction* handler); HLDEventWrapper* HLDEventWrapperNew(HLDEvent* event); void HLDRecordEngineRefs(HLDVariables* vars, HLDFunctions* funcs); #endif /* INTERNAL_HLD_H */
30.371293
80
0.60282
[ "object", "vector", "solid" ]
2a4115e039f985f874b8e6113cfe4fc0ba78c1b0
969
h
C
include/lispp/simple_callable_object.h
trukanduk/lispp
9fe4564b2197ae216214fa0408f1e5c4c5105237
[ "MIT" ]
null
null
null
include/lispp/simple_callable_object.h
trukanduk/lispp
9fe4564b2197ae216214fa0408f1e5c4c5105237
[ "MIT" ]
null
null
null
include/lispp/simple_callable_object.h
trukanduk/lispp
9fe4564b2197ae216214fa0408f1e5c4c5105237
[ "MIT" ]
null
null
null
#pragma once #include <functional> #include <lispp/callable_object.h> namespace lispp { template<typename Callable> class SimpleCallableObject : public CallableObject { public: explicit SimpleCallableObject( Callable callable, CallableType type = CallableType::kFunction, bool create_separate_scope = false) : CallableObject(type, create_separate_scope), callable_(callable) {} protected: ObjectPtr<> execute_impl(const std::shared_ptr<Scope>& scope, const std::vector<ObjectPtr<>>& args) override { return callable_(scope, args); } private: Callable callable_; }; template<typename Callable> ObjectPtr<SimpleCallableObject<Callable>> make_simple_callable( Callable callable, CallableType type = CallableType::kFunction, bool create_separate_scope = false) { return new SimpleCallableObject<Callable>(callable, type, create_separate_scope); } } // lispp
26.916667
75
0.713106
[ "vector" ]
2a436fde6b2428b2c5edc105d12b40f058450588
32,639
h
C
src/libSBML/src/sbml/packages/render/sbml/GlobalRenderInformation.h
copasi/copasi-dependencies
c01dd455c843522375c32c2989aa8675f59bb810
[ "Unlicense" ]
5
2015-04-16T14:27:38.000Z
2021-11-30T14:54:39.000Z
src/libSBML/src/sbml/packages/render/sbml/GlobalRenderInformation.h
copasi/copasi-dependencies
c01dd455c843522375c32c2989aa8675f59bb810
[ "Unlicense" ]
8
2017-05-30T16:58:39.000Z
2022-02-22T16:51:34.000Z
src/libSBML/src/sbml/packages/render/sbml/GlobalRenderInformation.h
copasi/copasi-dependencies
c01dd455c843522375c32c2989aa8675f59bb810
[ "Unlicense" ]
7
2016-05-29T08:12:59.000Z
2019-05-02T13:39:25.000Z
/** * @file GlobalRenderInformation.h * @brief Definition of the GlobalRenderInformation class. * @author Ralph Gauges * @author Frank T. Bergmann * * <!-------------------------------------------------------------------------- * This file is part of libSBML. Please visit http://sbml.org for more * information about SBML, and the latest version of libSBML. * * Copyright (C) 2020 jointly by the following organizations: * 1. California Institute of Technology, Pasadena, CA, USA * 2. University of Heidelberg, Heidelberg, Germany * 3. University College London, London, UK * * Copyright (C) 2019 jointly by the following organizations: * 1. California Institute of Technology, Pasadena, CA, USA * 2. University of Heidelberg, Heidelberg, Germany * * Copyright (C) 2013-2018 jointly by the following organizations: * 1. California Institute of Technology, Pasadena, CA, USA * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK * 3. University of Heidelberg, Heidelberg, Germany * * Copyright (C) 2011-2013 jointly by the following organizations: * 1. California Institute of Technology, Pasadena, CA, USA * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK * * Copyright 2010 Ralph Gauges * Group for the modeling of biological processes * University of Heidelberg * Im Neuenheimer Feld 267 * 69120 Heidelberg * Germany * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation. A copy of the license agreement is provided * in the file named "LICENSE.txt" included with this software distribution * and also available online as http://sbml.org/software/libsbml/license.html * ------------------------------------------------------------------------ --> * * @class GlobalRenderInformation * @sbmlbrief{render} Render information stored in a ListOfLayouts. * * GlobalRenderInformation is one of the subclasses of RenderInformationBase. * A global render information object contains color definitions, gradient * definitions and line endings as defined in RenderInformationBase. * Additionally it has a list of global styles which specifies type and role * based render information. This class of objects cannot specify id-based * render information because it does not belong to a certain layout but it * belongs to all layouts. GlobalRenderInformation can be applied to all * layouts. */ #ifndef GlobalRenderInformation_H__ #define GlobalRenderInformation_H__ #include <sbml/common/extern.h> #include <sbml/common/sbmlfwd.h> #include <sbml/packages/render/common/renderfwd.h> #include <sbml/xml/XMLNode.h> #ifdef __cplusplus #include <string> #include <sbml/packages/render/sbml/RenderInformationBase.h> #include <sbml/packages/render/extension/RenderExtension.h> #include <sbml/packages/render/sbml/ListOfGlobalStyles.h> LIBSBML_CPP_NAMESPACE_BEGIN class LIBSBML_EXTERN GlobalRenderInformation : public RenderInformationBase { protected: /** @cond doxygenLibsbmlInternal */ ListOfGlobalStyles mGlobalStyles; /** @endcond */ public: /** * Creates a new GlobalRenderInformation using the given SBML Level, Version * and &ldquo;render&rdquo; package version. * * @param level an unsigned int, the SBML Level to assign to this * GlobalRenderInformation. * * @param version an unsigned int, the SBML Version to assign to this * GlobalRenderInformation. * * @param pkgVersion an unsigned int, the SBML Render Version to assign to * this GlobalRenderInformation. * * @copydetails doc_note_setting_lv_pkg */ GlobalRenderInformation( unsigned int level = RenderExtension::getDefaultLevel(), unsigned int version = RenderExtension::getDefaultVersion(), unsigned int pkgVersion = RenderExtension::getDefaultPackageVersion()); /** * Creates a new GlobalRenderInformation using the given RenderPkgNamespaces * object. * * @copydetails doc_what_are_sbml_package_namespaces * * @param renderns the RenderPkgNamespaces object. * * @copydetails doc_note_setting_lv_pkg */ GlobalRenderInformation(RenderPkgNamespaces *renderns); #ifndef OMIT_DEPRECATED /** * Constructor which creates a GlobalRenderInformation with the given @p id * and all lists empty. * * @param renderns the SBMLNamespaces object for the SBML "render" package * @param id the new id for the GlobalRenderInformation. * * @copydetails doc_warning_deprecated_constructor */ GlobalRenderInformation(RenderPkgNamespaces* renderns, const std::string& id); #endif // OMIT_DEPRECATED /** * Copy constructor for GlobalRenderInformation. * * @param orig the GlobalRenderInformation instance to copy. */ GlobalRenderInformation(const GlobalRenderInformation& orig); /** * Assignment operator for GlobalRenderInformation. * * @param rhs the GlobalRenderInformation object whose values are to be used * as the basis of the assignment. */ GlobalRenderInformation& operator=(const GlobalRenderInformation& rhs); /** * Creates and returns a deep copy of this GlobalRenderInformation object. * * @return a (deep) copy of this GlobalRenderInformation object. */ virtual GlobalRenderInformation* clone() const; /** * Destructor for GlobalRenderInformation. */ virtual ~GlobalRenderInformation(); /** * Returns the ListOfGlobalStyles from this GlobalRenderInformation. * * @return the ListOfGlobalStyles from this GlobalRenderInformation. * * @copydetails doc_returned_unowned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getGlobalStyle(unsigned int n) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ const ListOfGlobalStyles* getListOfGlobalStyles() const; /** * Returns the ListOfGlobalStyles from this GlobalRenderInformation. * * @return the ListOfGlobalStyles from this GlobalRenderInformation. * * @copydetails doc_returned_unowned_pointer * * @see addStyle(const GlobalStyle* object) * @see createStyle() * @see getStyle(const std::string& sid) * @see getStyle(unsigned int n) * @see getNumStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ const ListOfGlobalStyles* getListOfStyles() const; /** * Returns the ListOfGlobalStyles from this GlobalRenderInformation. * * @return the ListOfGlobalStyles from this GlobalRenderInformation. * * @copydetails doc_returned_unowned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getGlobalStyle(unsigned int n) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ ListOfGlobalStyles* getListOfGlobalStyles(); /** * Returns the ListOfGlobalStyles from this GlobalRenderInformation. * * @return the ListOfGlobalStyles from this GlobalRenderInformation. * * @copydetails doc_returned_unowned_pointer * * @see addStyle(const GlobalStyle* object) * @see createStyle() * @see getStyle(const std::string& sid) * @see getStyle(unsigned int n) * @see getNumStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ ListOfGlobalStyles* getListOfStyles(); /** * Get a GlobalStyle from the GlobalRenderInformation. * * @param n an unsigned int representing the index of the GlobalStyle to * retrieve. * * @return the nth GlobalStyle in the ListOfGlobalStyles within this * GlobalRenderInformation or @c NULL if no such object exists. * * @copydetails doc_returned_unowned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ GlobalStyle* getGlobalStyle(unsigned int n); /** * Get a GlobalStyle from the GlobalRenderInformation. * * @param n an unsigned int representing the index of the GlobalStyle to * retrieve. * * @return the nth GlobalStyle in the ListOfGlobalStyles within this * GlobalRenderInformation or @c NULL if no such object exists. * * @copydetails doc_returned_unowned_pointer * * @see addStyle(const GlobalStyle* object) * @see createStyle() * @see getStyle(const std::string& sid) * @see getNumStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ GlobalStyle* getStyle(unsigned int n); /** * Get a GlobalStyle from the GlobalRenderInformation. * * @param n an unsigned int representing the index of the GlobalStyle to * retrieve. * * @return the nth GlobalStyle in the ListOfGlobalStyles within this * GlobalRenderInformation or @c NULL if no such object exists. * * @copydetails doc_returned_unowned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ const GlobalStyle* getGlobalStyle(unsigned int n) const; /** * Get a GlobalStyle from the GlobalRenderInformation. * * @param n an unsigned int representing the index of the GlobalStyle to * retrieve. * * @return the nth GlobalStyle in the ListOfGlobalStyles within this * GlobalRenderInformation. * If the index @p n is invalid, @c NULL is returned. * * @copydetails doc_returned_unowned_pointer * * @see addStyle(const GlobalStyle* object) * @see createStyle() * @see getStyle(const std::string& sid) * @see getNumStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ const GlobalStyle* getStyle(unsigned int n) const; /** * Get a GlobalStyle from the GlobalRenderInformation. * * @param id a string representing the identifier of the ColorDefinition to * remove. * * @return the GlobalStyle in this GlobalRenderInformation based on the * identifier or NULL if no such GlobalStyle exists. * * @copydetails doc_warning_returns_owned_pointer * * * @copydetails doc_returned_unowned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ GlobalStyle* getGlobalStyle(const std::string& id); /** * Get a GlobalStyle from the GlobalRenderInformation. * * @param id a string representing the identifier of the ColorDefinition to * remove. * * @return the GlobalStyle in this GlobalRenderInformation based on the * identifier or NULL if no such GlobalStyle exists. * * @copydetails doc_returned_unowned_pointer * * @see addStyle(const GlobalStyle* object) * @see createStyle() * @see getStyle(const std::string& sid) * @see getNumStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ GlobalStyle* getStyle(const std::string& id); /** * Get a GlobalStyle from the GlobalRenderInformation. * * @param id a string representing the identifier of the ColorDefinition to * remove. * * @return the GlobalStyle in this GlobalRenderInformation based on the * identifier or NULL if no such GlobalStyle exists. * * @copydetails doc_returned_unowned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ const GlobalStyle* getGlobalStyle(const std::string& id) const; /** * Get a GlobalStyle from the GlobalRenderInformation. * * @param id a string representing the identifier of the ColorDefinition to * remove. * * @return the GlobalStyle in this GlobalRenderInformation based on the * identifier or NULL if no such GlobalStyle exists. * * @copydetails doc_returned_unowned_pointer * * @see addStyle(const GlobalStyle* object) * @see createStyle() * @see getStyle(const std::string& sid) * @see getNumStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ const GlobalStyle* getStyle(const std::string& id) const; /** * Adds a copy of the given GlobalStyle to this GlobalRenderInformation. * * @param gs the GlobalStyle object to add. * * @copydetails doc_returns_success_code * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_LEVEL_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_VERSION_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_PKG_VERSION_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_DUPLICATE_OBJECT_ID, OperationReturnValues_t} * * @copydetails doc_note_object_is_copied * * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getGlobalStyle(unsigned int n) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ int addGlobalStyle(const GlobalStyle* gs); /** * Adds a copy of the given GlobalStyle to this GlobalRenderInformation. * * @param gs the GlobalStyle object to add. * * @copydetails doc_returns_success_code * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_LEVEL_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_VERSION_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_PKG_VERSION_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_DUPLICATE_OBJECT_ID, OperationReturnValues_t} * * @copydetails doc_note_object_is_copied * * @see createStyle() * @see getStyle(const std::string& sid) * @see getStyle(unsigned int n) * @see getNumStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ int addStyle(const GlobalStyle* gs); /** * Get the number of GlobalStyle objects in this GlobalRenderInformation. * * @return the number of GlobalStyle objects in this GlobalRenderInformation. * * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getGlobalStyle(unsigned int n) * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ unsigned int getNumGlobalStyles() const; /** * Get the number of GlobalStyle objects in this GlobalRenderInformation. * * @return the number of GlobalStyle objects in this GlobalRenderInformation. * * * @see addStyle(const GlobalStyle* object) * @see createStyle() * @see getStyle(const std::string& sid) * @see getStyle(unsigned int n) * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ unsigned int getNumStyles() const; /** * Creates a new GlobalStyle object, adds it to this GlobalRenderInformation * object and returns the GlobalStyle object created. * * @return a new GlobalStyle object instance. * * @copydetails doc_returned_unowned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see getGlobalStyle(const std::string& sid) * @see getGlobalStyle(unsigned int n) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ GlobalStyle* createGlobalStyle(); /** * Creates a new GlobalStyle object with the given id, adds it to this GlobalRenderInformation * object and returns the GlobalStyle object created. * * @return a new GlobalStyle object instance. * * @copydetails doc_returned_unowned_pointer * * @see addStyle(const GlobalStyle* object) * @see getStyle(const std::string& sid) * @see getStyle(unsigned int n) * @see getNumStyles() * @see removeGlobalStyle(const std::string& sid) * @see removeGlobalStyle(unsigned int n) */ GlobalStyle* createStyle(const std::string& id); /** * Removes the nth GlobalStyle from this GlobalRenderInformation and returns * a pointer to it. * * @param n an unsigned int representing the index of the GlobalStyle to * remove. * * @return a pointer to the nth GlobalStyle in this GlobalRenderInformation. * * @copydetails doc_warning_returns_owned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getGlobalStyle(unsigned int n) * @see getNumGlobalStyles() * @see removeGlobalStyle(const std::string& sid) */ GlobalStyle* removeGlobalStyle(unsigned int n); /** * Removes the GlobalStyle with the given id from this GlobalRenderInformation * and returns a pointer to it. * * @param sid the id of the GlobalStyle to remove. * * @return a pointer to the nth GlobalStyle in this GlobalRenderInformation. * * @copydetails doc_warning_returns_owned_pointer * * @see addGlobalStyle(const GlobalStyle* object) * @see createGlobalStyle() * @see getGlobalStyle(const std::string& sid) * @see getGlobalStyle(unsigned int n) * @see getNumGlobalStyles() * @see removeGlobalStyle(unsigned int n) */ GlobalStyle* removeGlobalStyle(const std::string& sid); /** * Removes the nth GlobalStyle from this GlobalRenderInformation and returns * a pointer to it. * * @param n an unsigned int representing the index of the GlobalStyle to * remove. * * @return a pointer to the nth GlobalStyle in this GlobalRenderInformation. * * @copydetails doc_warning_returns_owned_pointer * * @see addStyle(const GlobalStyle* object) * @see createStyle() * @see getStyle(const std::string& sid) * @see getStyle(unsigned int n) * @see getNumStyles() * @see removeGlobalStyle(unsigned int n) * @see removeGlobalStyle(const std::string& sid) */ GlobalStyle* removeStyle(unsigned int n); /** * Returns the XML element name of this GlobalRenderInformation object. * * For GlobalRenderInformation, the XML element name is always * @c "renderInformation". * * @return the name of this element, i.e. @c "renderInformation". */ virtual const std::string& getElementName() const; /** * Returns the libSBML type code for this GlobalRenderInformation object. * * @copydetails doc_what_are_typecodes * * @return the SBML type code for this object: * @sbmlconstant{SBML_RENDER_GLOBALRENDERINFORMATION, SBMLRenderTypeCode_t}. * * @copydetails doc_warning_typecodes_not_unique * * @see getElementName() * @see getPackageName() */ virtual int getTypeCode() const; /** @cond doxygenLibsbmlInternal */ /** * Write any contained elements */ virtual void writeElements(XMLOutputStream& stream) const; /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Accepts the given SBMLVisitor */ virtual bool accept(SBMLVisitor& v) const; /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Sets the parent SBMLDocument */ virtual void setSBMLDocument(SBMLDocument* d); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Connects to child elements */ virtual void connectToChild(); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Enables/disables the given package with this element */ virtual void enablePackageInternal(const std::string& pkgURI, const std::string& pkgPrefix, bool flag); /** @endcond */ #ifndef SWIG /** @cond doxygenLibsbmlInternal */ /** * Creates and returns an new "elementName" object in this * GlobalRenderInformation. * * @param elementName, the name of the element to create. * * @return pointer to the element created. */ virtual SBase* createChildObject(const std::string& elementName); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Adds a new "elementName" object to this GlobalRenderInformation. * * @param elementName, the name of the element to create. * * @param element, pointer to the element to be added. * * @copydetails doc_returns_success_code * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} */ virtual int addChildObject(const std::string& elementName, const SBase* element); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Removes and returns the new "elementName" object with the given id in this * GlobalRenderInformation. * * @param elementName, the name of the element to remove. * * @param id, the id of the element to remove. * * @return pointer to the element removed. */ virtual SBase* removeChildObject(const std::string& elementName, const std::string& id); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Returns the number of "elementName" in this GlobalRenderInformation. * * @param elementName, the name of the element to get number of. * * @return unsigned int number of elements. */ virtual unsigned int getNumObjects(const std::string& elementName); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Returns the nth object of "objectName" in this GlobalRenderInformation. * * @param elementName, the name of the element to get number of. * * @param index, unsigned int the index of the object to retrieve. * * @return pointer to the object. */ virtual SBase* getObject(const std::string& elementName, unsigned int index); /** @endcond */ #endif /* !SWIG */ /** * Returns the first child element that has the given @p id in the model-wide * SId namespace, or @c NULL if no such object is found. * * @param id a string representing the id attribute of the object to * retrieve. * * @return a pointer to the SBase element with the given @p id. If no such * object is found, this method returns @c NULL. */ virtual SBase* getElementBySId(const std::string& id); /** * Returns the first child element that has the given @p metaid, or @c NULL * if no such object is found. * * @param metaid a string representing the metaid attribute of the object to * retrieve. * * @return a pointer to the SBase element with the given @p metaid. If no * such object is found this method returns @c NULL. */ virtual SBase* getElementByMetaId(const std::string& metaid); /** * Returns a List of all child SBase objects, including those nested to an * arbitrary depth. * * @param filter an ElementFilter that may impose restrictions on the objects * to be retrieved. * * @return a List pointer of pointers to all SBase child objects with any * restriction imposed. */ virtual List* getAllElements(ElementFilter * filter = NULL); /** * Parses the xml information in the given node and sets the attributes. * This method should never be called by the user. It is only used to read render * information from annotations. * * @param node the XMLNode object reference that describes the GlobalRenderInformation * object to be instantiated. */ void parseXML(const XMLNode& node); /** * Creates an XMLNode object from this GlobalRenderInformation object. * * @return the XMLNode with the XML representation for the * GlobalRenderInformation object. * */ XMLNode toXML() const; protected: /** @cond doxygenLibsbmlInternal */ /** * Creates a new object from the next XMLToken on the XMLInputStream */ virtual SBase* createObject(XMLInputStream& stream); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Adds the expected attributes for this element */ virtual void addExpectedAttributes(ExpectedAttributes& attributes); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Reads the expected attributes into the member data variables */ virtual void readAttributes(const XMLAttributes& attributes, const ExpectedAttributes& expectedAttributes); /** @endcond */ /** @cond doxygenLibsbmlInternal */ /** * Writes the attributes to the stream */ virtual void writeAttributes(XMLOutputStream& stream) const; /** @endcond */ }; LIBSBML_CPP_NAMESPACE_END #endif /* __cplusplus */ #ifndef SWIG LIBSBML_CPP_NAMESPACE_BEGIN BEGIN_C_DECLS /** * Creates a new GlobalRenderInformation_t using the given SBML Level, Version * and &ldquo;render&rdquo; package version. * * @param level an unsigned int, the SBML Level to assign to this * GlobalRenderInformation_t. * * @param version an unsigned int, the SBML Version to assign to this * GlobalRenderInformation_t. * * @param pkgVersion an unsigned int, the SBML Render Version to assign to this * GlobalRenderInformation_t. * * @copydetails doc_note_setting_lv_pkg * * @copydetails doc_warning_returns_owned_pointer * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN GlobalRenderInformation_t * GlobalRenderInformation_create(unsigned int level, unsigned int version, unsigned int pkgVersion); /** * Creates and returns a deep copy of this GlobalRenderInformation_t object. * * @param gri the GlobalRenderInformation_t structure. * * @return a (deep) copy of this GlobalRenderInformation_t object. * * @copydetails doc_warning_returns_owned_pointer * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN GlobalRenderInformation_t* GlobalRenderInformation_clone(const GlobalRenderInformation_t* gri); /** * Frees this GlobalRenderInformation_t object. * * @param gri the GlobalRenderInformation_t structure. * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN void GlobalRenderInformation_free(GlobalRenderInformation_t* gri); /** * Returns a ListOf_t * containing GlobalStyle_t objects from this * GlobalRenderInformation_t. * * @param gri the GlobalRenderInformation_t structure whose ListOfGlobalStyles * is sought. * * @return the ListOfGlobalStyles from this GlobalRenderInformation_t as a * ListOf_t *. * * @copydetails doc_returned_unowned_pointer * * @see GlobalRenderInformation_addGlobalStyle() * @see GlobalRenderInformation_createGlobalStyle() * @see GlobalRenderInformation_getGlobalStyleById() * @see GlobalRenderInformation_getGlobalStyle() * @see GlobalRenderInformation_getNumGlobalStyles() * @see GlobalRenderInformation_removeGlobalStyleById() * @see GlobalRenderInformation_removeGlobalStyle() * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN ListOf_t* GlobalRenderInformation_getListOfGlobalStyles(GlobalRenderInformation_t* gri); /** * Get a GlobalStyle_t from the GlobalRenderInformation_t. * * @param gri the GlobalRenderInformation_t structure to search. * * @param n an unsigned int representing the index of the GlobalStyle_t to * retrieve. * * @return the nth GlobalStyle_t in the ListOfGlobalStyles within this * GlobalRenderInformation or @c NULL if no such object exists. * * @copydetails doc_returned_unowned_pointer * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN GlobalStyle_t* GlobalRenderInformation_getGlobalStyle(GlobalRenderInformation_t* gri, unsigned int n); /** * Adds a copy of the given GlobalStyle_t to this GlobalRenderInformation_t. * * @param gri the GlobalRenderInformation_t structure to which the * GlobalStyle_t should be added. * * @param gs the GlobalStyle_t object to add. * * @copydetails doc_returns_success_code * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_LEVEL_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_VERSION_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_PKG_VERSION_MISMATCH, OperationReturnValues_t} * @li @sbmlconstant{LIBSBML_DUPLICATE_OBJECT_ID, OperationReturnValues_t} * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN int GlobalRenderInformation_addGlobalStyle(GlobalRenderInformation_t* gri, const GlobalStyle_t* gs); /** * Get the number of GlobalStyle_t objects in this GlobalRenderInformation_t. * * @param gri the GlobalRenderInformation_t structure to query. * * @return the number of GlobalStyle_t objects in this * GlobalRenderInformation_t. * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN unsigned int GlobalRenderInformation_getNumGlobalStyles(GlobalRenderInformation_t* gri); /** * Creates a new GlobalStyle_t object, adds it to this * GlobalRenderInformation_t object and returns the GlobalStyle_t object * created. * * @param gri the GlobalRenderInformation_t structure to which the * GlobalStyle_t should be added. * * @return a new GlobalStyle_t object instance. * * @copydetails doc_returned_unowned_pointer * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN GlobalStyle_t* GlobalRenderInformation_createGlobalStyle(GlobalRenderInformation_t* gri); /** * Removes the nth GlobalStyle_t from this GlobalRenderInformation_t and * returns a pointer to it. * * @param gri the GlobalRenderInformation_t structure to search. * * @param n an unsigned int representing the index of the GlobalStyle_t to * remove. * * @return a pointer to the nth GlobalStyle_t in this * GlobalRenderInformation_t. * * @copydetails doc_warning_returns_owned_pointer * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN GlobalStyle_t* GlobalRenderInformation_removeGlobalStyle(GlobalRenderInformation_t* gri, unsigned int n); /** * Predicate returning @c 1 (true) if all the required attributes for this * GlobalRenderInformation_t object have been set. * * @param gri the GlobalRenderInformation_t structure. * * @return @c 1 (true) to indicate that all the required attributes of this * GlobalRenderInformation_t have been set, otherwise @c 0 (false) is returned. * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN int GlobalRenderInformation_hasRequiredAttributes(const GlobalRenderInformation_t * gri); /** * Predicate returning @c 1 (true) if all the required elements for this * GlobalRenderInformation_t object have been set. * * @param gri the GlobalRenderInformation_t structure. * * @return @c 1 (true) to indicate that all the required elements of this * GlobalRenderInformation_t have been set, otherwise @c 0 (false) is returned. * * * @note The required elements for the GlobalRenderInformation_t object are: * * @memberof GlobalRenderInformation_t */ LIBSBML_EXTERN int GlobalRenderInformation_hasRequiredElements(const GlobalRenderInformation_t * gri); END_C_DECLS LIBSBML_CPP_NAMESPACE_END #endif /* !SWIG */ #ifndef LIBSBML_USE_STRICT_INCLUDES #include <sbml/packages/render/sbml/ListOfGlobalRenderInformation.h> #endif // LIBSBML_USE_STRICT_INCLUDES #endif /* !GlobalRenderInformation_H__ */
28.137069
95
0.717669
[ "render", "object", "model" ]
2a58e5086134a7e726d2c92eec7cf5cd017bab37
1,453
c
C
tools/splash2Prof/barnes/gravsub.c
Artoriasviel/POET
c9b845050e7f9affc84f161351d9794269bc8996
[ "BSD-3-Clause" ]
null
null
null
tools/splash2Prof/barnes/gravsub.c
Artoriasviel/POET
c9b845050e7f9affc84f161351d9794269bc8996
[ "BSD-3-Clause" ]
7
2019-10-26T00:11:19.000Z
2022-03-24T04:07:19.000Z
tools/splash2Prof/barnes/gravsub.c
DeveloperPOET/POET
7bd4b61fe5cc586da7e7d59a8b2c03c1047bb370
[ "BSD-3-Clause" ]
3
2020-05-22T00:00:46.000Z
2022-03-14T19:34:14.000Z
void gravsub(register nodeptr p, long ProcessId) { real drabs, phii, mor3; vector ai; if (p != Local[ProcessId].pmem) { //SUBV(Local[ProcessId].dr, Pos(p), Local[ProcessId].pos0); Local[ProcessId].dr[0] = (Pos(p))[0] - Local[ProcessId].pos0[0]; Local[ProcessId].dr[1] = (Pos(p))[1] - Local[ProcessId].pos0[1]; Local[ProcessId].dr[2] = (Pos(p))[2] - Local[ProcessId].pos0[2]; //DOTVP(Local[ProcessId].drsq, Local[ProcessId].dr, Local[ProcessId].dr); Local[ProcessId].drsq = Local[ProcessId].dr[0] * Local[ProcessId].dr[0] + Local[ProcessId].dr[1] * Local[ProcessId].dr[1] + Local[ProcessId].dr[2] * Local[ProcessId].dr[2]; } Local[ProcessId].drsq += epssq; drabs = sqrt((double) Local[ProcessId].drsq); phii = Mass(p) / drabs; Local[ProcessId].phi0 -= phii; mor3 = phii / Local[ProcessId].drsq; //MULVS(ai, Local[ProcessId].dr, mor3); ai[0] = Local[ProcessId].dr[0] * mor3; ai[1] = Local[ProcessId].dr[1] * mor3; ai[2] = Local[ProcessId].dr[2] * mor3; ADDV(Local[ProcessId].acc0, Local[ProcessId].acc0, ai); if(Type(p) != BODY) { /* a body-cell/leaf interaction? */ Local[ProcessId].mynbcterm++; } else { /* a body-body interaction */ Local[ProcessId].myn2bterm++; } } void main() { }
38.236842
83
0.549209
[ "vector" ]
2a610554b491cb35b6808bd3b6a57723a1792e96
11,397
c
C
aux/autman.c
tulip-control/gr1c
4c73161e7857410b86536f4be9d2a55c581e2e9c
[ "BSD-3-Clause" ]
11
2016-10-11T22:39:27.000Z
2022-03-26T15:28:20.000Z
aux/autman.c
tulip-control/gr1c
4c73161e7857410b86536f4be9d2a55c581e2e9c
[ "BSD-3-Clause" ]
13
2016-07-29T04:39:22.000Z
2021-09-21T08:03:50.000Z
aux/autman.c
tulip-control/gr1c
4c73161e7857410b86536f4be9d2a55c581e2e9c
[ "BSD-3-Clause" ]
2
2017-03-22T08:12:11.000Z
2017-08-12T03:27:14.000Z
/* autman.c -- entry point for a finite-state machine (automaton) manipulator * * Try invoking it with "-h"... * * * SCL; 2014-2015 */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "common.h" #include "logging.h" #include "automaton.h" #include "ptree.h" extern int yyparse( void ); extern void yyrestart( FILE *new_file ); /************************** **** Global variables ****/ extern specification_t spc; /**************************/ /* Output formats */ #define OUTPUT_FORMAT_TEXT 0 #define OUTPUT_FORMAT_TULIP 1 #define OUTPUT_FORMAT_DOT 2 #define OUTPUT_FORMAT_AUT 3 #define OUTPUT_FORMAT_JSON 5 /* Runtime modes */ #define AUTMAN_SYNTAX 1 #define AUTMAN_VARTYPES 2 #define AUTMAN_VERMODEL 3 #define AUTMAN_CONVERT 4 /* Verification model targets */ #define VERMODEL_TARGET_SPIN 1 int main( int argc, char **argv ) { FILE *fp; int i, j; int in_filename_index = -1; FILE *in_fp = NULL; anode_t *head; int version; int state_len = -1; byte format_option = OUTPUT_FORMAT_JSON; byte verification_model = 0; /* For command-line flag "-P". */ unsigned char verbose = 0; bool logging_flag = False; int run_option = AUTMAN_SYNTAX; int spc_file_index = -1; int output_file_index = -1; /* For command-line flag "-o". */ FILE *spc_fp; for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { if (argv[i][2] != '\0' && !(argv[i][1] == 'v' && argv[i][2] == 'v')) { fprintf( stderr, "Invalid flag given. Try \"-h\".\n" ); return 1; } if (argv[i][1] == 'h') { printf( "Usage: %s [-hVvlsP] [-t TYPE] [-L N] [-i FILE] [-o FILE] [FILE]\n\n" "If no input file is given, or if FILE is -, read from stdin. If no action\n" "is requested, then assume -s.\n\n" " -h this help message\n" " -V print version and exit\n" " -v be verbose; use -vv to be more verbose\n" " -l enable logging\n" " -s check syntax and get version;\n" " print format version number, or -1 if error.\n", argv[0] ); /* " -ss extends -s to also check the number of and values\n" " assigned to variables, given specification.\n" */ printf( " -t TYPE convert to format: txt, dot, aut, json, tulip\n" " some of these require a reference specification.\n" " -P create Spin Promela model of strategy\n" " if used with -o, then the LTL formula is printed to stdout.\n" " -L N declare that state vector size is N\n" " -i FILE process strategy with respect to specification FILE\n" " -o FILE output to FILE, rather than stdout (default)\n" ); return 0; } else if (argv[i][1] == 'V') { printf( "gr1c-autman (automaton file manipulator, distributed with" " gr1c v" GR1C_VERSION ")\n\n" GR1C_COPYRIGHT "\n" ); PRINT_LINKED_VERSIONS(); return 0; } else if (argv[i][1] == 'v') { verbose++; j = 2; /* Only support up to "level 2" of verbosity */ while (argv[i][j] == 'v' && j <= 2) { verbose++; j++; } } else if (argv[i][1] == 'l') { logging_flag = True; } else if (argv[i][1] == 's') { if (argv[i][2] == 's') run_option = AUTMAN_VARTYPES; else run_option = AUTMAN_SYNTAX; } else if (argv[i][1] == 't') { run_option = AUTMAN_CONVERT; if (i == argc-1) { fprintf( stderr, "Invalid flag given. Try \"-h\".\n" ); return 1; } if (!strncmp( argv[i+1], "txt", strlen( "txt" ) )) { format_option = OUTPUT_FORMAT_TEXT; } else if (!strncmp( argv[i+1], "tulip", strlen( "tulip" ) )) { format_option = OUTPUT_FORMAT_TULIP; } else if (!strncmp( argv[i+1], "dot", strlen( "dot" ) )) { format_option = OUTPUT_FORMAT_DOT; } else if (!strncmp( argv[i+1], "aut", strlen( "aut" ) )) { format_option = OUTPUT_FORMAT_AUT; } else if (!strncmp( argv[i+1], "json", strlen( "json" ) )) { format_option = OUTPUT_FORMAT_JSON; } else { fprintf( stderr, "Unrecognized output format. Try \"-h\".\n" ); return 1; } i++; } else if (argv[i][1] == 'i') { if (i == argc-1) { fprintf( stderr, "Invalid flag given. Try \"-h\".\n" ); return 1; } spc_file_index = i+1; i++; } else if (argv[i][1] == 'L') { if (i == argc-1) { fprintf( stderr, "Invalid flag given. Try \"-h\".\n" ); return 1; } state_len = strtol( argv[i+1], NULL, 10 ); i++; } else if (argv[i][1] == 'P') { run_option = AUTMAN_VERMODEL; verification_model = VERMODEL_TARGET_SPIN; } else if (argv[i][1] == 'o') { if (i == argc-1) { fprintf( stderr, "Invalid flag given. Try \"-h\".\n" ); return 1; } output_file_index = i+1; i++; } else { fprintf( stderr, "Invalid flag given. Try \"-h\".\n" ); return 1; } } else { in_filename_index = i; } } if (run_option == AUTMAN_VERMODEL && spc_file_index < 0) { fprintf( stderr, "-P flag requires a reference specification to be given" " (-i switch).\n" ); return 1; } if (run_option == AUTMAN_CONVERT && spc_file_index < 0 && (format_option == OUTPUT_FORMAT_DOT || format_option == OUTPUT_FORMAT_JSON || format_option == OUTPUT_FORMAT_TULIP)) { fprintf( stderr, "Conversion of output to selected format requires a" " reference\nspecification to be given (-i switch).\n" ); return 1; } if (spc_file_index < 0 && state_len < 1) { if (state_len < 0) fprintf( stderr, "State vector length must be declared (-L switch)" " when no reference\nspecification is given.\n" ); else fprintf( stderr, "State vector length must be at least 1. Try \"-h\".\n" ); return 1; } /* if (run_option == AUTMAN_VARTYPES && spc_file_index < 0) { fprintf( stderr, "-ss flag requires a reference specification to be given" " (-i switch).\n" ); return 1; } */ if (logging_flag) { openlogfile( NULL ); if (verbose == 0) verbose = 1; } else { setlogstream( stdout ); setlogopt( LOGOPT_NOTIME ); } if (verbose > 0) logprint( "Running with verbosity level %d.", verbose ); /* Parse the specification file if given. */ if (spc_file_index >= 0) { if (verbose > 1) logprint( "Using file \"%s\" for reference specification.", argv[spc_file_index] ); spc_fp = fopen( argv[spc_file_index], "r" ); if (spc_fp == NULL) { perror( "gr1c-autman, fopen" ); return -1; } yyrestart( spc_fp ); if (verbose) logprint( "Parsing reference specification file..." ); SPC_INIT( spc ); if (yyparse()) return 2; if (verbose) logprint( "Done." ); fclose( spc_fp ); spc_fp = NULL; state_len = tree_size( spc.evar_list ) + tree_size( spc.svar_list ); if (verbose) logprint( "Detected state vector length of %d.", state_len ); } if (in_filename_index < 0 || !strncmp( argv[in_filename_index], "-", 1 )) { if (verbose > 1) logprint( "Using stdin for input." ); in_fp = stdin; } else { if (verbose > 1) logprint( "Using file \"%s\" for input.", argv[in_filename_index] ); in_fp = fopen( argv[in_filename_index], "r" ); if (in_fp == NULL) { perror( "autman, fopen" ); return -1; } } if (verbose > 1) logprint( "Loading automaton..." ); head = aut_aut_loadver( state_len, in_fp, &version ); if (head == NULL) { if (verbose) fprintf( stderr, "Error: failed to load aut.\n" ); return 3; } if (verbose > 1) logprint( "Done." ); if (verbose) { logprint( "Detected format version %d.", version ); logprint( "Given automaton has size %d.", aut_size( head ) ); } /* Open output file if specified; else point to stdout. */ if (output_file_index >= 0) { fp = fopen( argv[output_file_index], "w" ); if (fp == NULL) { perror( "gr1c, fopen" ); return -1; } } else { fp = stdout; } switch (run_option) { case AUTMAN_SYNTAX: printf( "%d\n", version ); return 0; case AUTMAN_VERMODEL: /* Currently, only target supported is Spin Promela, so the variable verification_model is not checked. */ spin_aut_dump( head, spc.evar_list, spc.svar_list, spc.env_init, spc.sys_init, spc.env_trans_array, spc.et_array_len, spc.sys_trans_array, spc.st_array_len, spc.env_goals, spc.num_egoals, spc.sys_goals, spc.num_sgoals, fp, stdout ); break; case AUTMAN_CONVERT: if (format_option == OUTPUT_FORMAT_TEXT) { list_aut_dump( head, state_len, fp ); } else if (format_option == OUTPUT_FORMAT_DOT) { dot_aut_dump( head, spc.evar_list, spc.svar_list, DOT_AUT_ATTRIB, fp ); } else if (format_option == OUTPUT_FORMAT_AUT) { aut_aut_dump( head, state_len, fp ); } else if (format_option == OUTPUT_FORMAT_JSON) { json_aut_dump( head, spc.evar_list, spc.svar_list, fp ); } else { /* OUTPUT_FORMAT_TULIP */ tulip_aut_dump( head, spc.evar_list, spc.svar_list, fp ); } break; default: fprintf( stderr, "Unrecognized run option. Try \"-h\".\n" ); return 1; } if (fp != stdout) fclose( fp ); return 0; }
35.067692
102
0.474686
[ "vector", "model" ]
2a6377e792fa746127836e05c22e05f9863c67de
1,508
c
C
src/enemy/render.c
RubenNijhuis/So-Long
ee4cf528dc604059111b5cc39c1d44e153cd84f4
[ "MIT" ]
null
null
null
src/enemy/render.c
RubenNijhuis/So-Long
ee4cf528dc604059111b5cc39c1d44e153cd84f4
[ "MIT" ]
null
null
null
src/enemy/render.c
RubenNijhuis/So-Long
ee4cf528dc604059111b5cc39c1d44e153cd84f4
[ "MIT" ]
null
null
null
/* ************************************************************************** */ /* */ /* :::::::: */ /* render.c :+: :+: */ /* +:+ */ /* By: rubennijhuis <rubennijhuis@student.coda +#+ */ /* +#+ */ /* Created: 2021/11/21 11:40:22 by rubennijhui #+# #+# */ /* Updated: 2021/12/13 16:36:03 by rnijhuis ######## odam.nl */ /* */ /* ************************************************************************** */ #include <so_long.h> #include <mlx.h> #include <stdio.h> /* * Renders correct enemy sprite based on direction */ void render_enemies(t_game_data *gd) { void *img; int i; t_enemy *enemy; i = 0; while (i < gd->amount_enemies) { enemy = gd->enemies[i]; if (enemy->direction == 1) img = gd->enemy_img_up; if (enemy->direction == 2) img = gd->enemy_img_right; if (enemy->direction == 3) img = gd->enemy_img_down; if (enemy->direction == 4) img = gd->enemy_img_left; mlx_put_image_to_window(gd->mlx, gd->win, img, gd->res * enemy->position_x, gd->res * enemy->position_y); i++; } }
35.069767
80
0.33687
[ "render" ]
2a70ab6ad92a6b01c3eca1fc59fcb4c50193ef4a
1,770
h
C
src/connected.h
touchlane/NetapixTrain
568d89d0541b3c4b4bbb9e917867e7f3f40e5dd6
[ "MIT" ]
2
2018-07-25T18:38:49.000Z
2018-07-26T11:37:54.000Z
src/connected.h
touchlane/Netapix
568d89d0541b3c4b4bbb9e917867e7f3f40e5dd6
[ "MIT" ]
null
null
null
src/connected.h
touchlane/Netapix
568d89d0541b3c4b4bbb9e917867e7f3f40e5dd6
[ "MIT" ]
null
null
null
// // connected.h // netapix // // Created by Evgeny Dedovets on 1/11/18. // Copyright © 2018 Touchlane LLC. All rights reserved. // #ifndef connected_h #define connected_h #include "config.h" typedef struct { //Type of layer. layer_type type; //Not activated input with applied delivative of activation function from previous layer. float *input_derivative; //Input array of channels. float *input; //Weights (width = number of outputs, heights = number of inputs). float ***weights; //Vector of bias values (size = number of outputs). float *biases; //Output array of channels (size = number of outputs). float *output; //Output with applied derivative of activation function instead of activation itself //(size = number of outputs). float *output_derivative; //Weights correction (width = number of outputs, heights = number of inputs). float ***corrections; //Batch bias corrections (size = number of outputs). float *biases_corrections; //Error gradients (size = number of outputs). float *gradients; //Previous layer error gradients (size = number of inputs). float *previous_gradients; //Activation type. activation_type activation; //Number of inputs. int input_length; //Number of outputs. int output_length; } connected_layer; connected_layer *make_connected_layer(layer_config config, float *weights, float *prev_gradients, float *input_derivative, float *input, float *corrections); int free_connected_layer(connected_layer *layer, int is_first_layer); void connected_forward(connected_layer *layer); void connected_backward(connected_layer *layer); void calc_connected_corrections(connected_layer *layer); #endif /* connected_h */
33.396226
157
0.722034
[ "vector" ]
2a743960149d73179e43398dad5795c54f1e1a60
3,172
h
C
src/qt/qtwebkit/Source/WebCore/rendering/RenderLayerModelObject.h
viewdy/phantomjs
eddb0db1d253fd0c546060a4555554c8ee08c13c
[ "BSD-3-Clause" ]
1
2015-05-27T13:52:20.000Z
2015-05-27T13:52:20.000Z
src/qt/qtwebkit/Source/WebCore/rendering/RenderLayerModelObject.h
mrampersad/phantomjs
dca6f77a36699eb4e1c46f7600cca618f01b0ac3
[ "BSD-3-Clause" ]
null
null
null
src/qt/qtwebkit/Source/WebCore/rendering/RenderLayerModelObject.h
mrampersad/phantomjs
dca6f77a36699eb4e1c46f7600cca618f01b0ac3
[ "BSD-3-Clause" ]
1
2017-03-19T13:03:23.000Z
2017-03-19T13:03:23.000Z
/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved. * Copyright (C) 2010, 2012 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef RenderLayerModelObject_h #define RenderLayerModelObject_h #include "RenderObject.h" namespace WebCore { class RenderLayer; class RenderLayerModelObject : public RenderObject { public: explicit RenderLayerModelObject(ContainerNode*); virtual ~RenderLayerModelObject(); // Called by RenderObject::willBeDestroyed() and is the only way layers should ever be destroyed void destroyLayer(); bool hasSelfPaintingLayer() const; RenderLayer* layer() const { return m_layer; } virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle) OVERRIDE; virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE; virtual void updateFromStyle() { } virtual bool requiresLayer() const = 0; // Returns true if the background is painted opaque in the given rect. // The query rect is given in local coordinate system. virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { return false; } // This is null for anonymous renderers. ContainerNode* node() const { return toContainerNode(RenderObject::node()); } protected: void ensureLayer(); virtual void willBeDestroyed() OVERRIDE; private: virtual bool isLayerModelObject() const OVERRIDE { return true; } RenderLayer* m_layer; // Used to store state between styleWillChange and styleDidChange static bool s_wasFloating; static bool s_hadLayer; static bool s_hadTransform; static bool s_layerWasSelfPainting; }; inline RenderLayerModelObject* toRenderLayerModelObject(RenderObject* object) { ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isLayerModelObject()); return static_cast<RenderLayerModelObject*>(object); } inline const RenderLayerModelObject* toRenderLayerModelObject(const RenderObject* object) { ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isLayerModelObject()); return static_cast<const RenderLayerModelObject*>(object); } // This will catch anyone doing an unnecessary cast. void toRenderLayerModelObject(const RenderLayerModelObject*); } // namespace WebCore #endif // RenderLayerModelObject_h
34.857143
100
0.75599
[ "object" ]
2a8169dbe0700b6e3d6bf951dd9867494e2a8863
2,330
h
C
Plugins/AdvKitPlugin/Source/AdvKitRuntime/Classes/Actions/Movement/AdvKitCA_Dodge.h
crimsonstrife/velorum-defunct
1a6e1eab9057293da2aa045eff021d069df54c5e
[ "CC0-1.0" ]
null
null
null
Plugins/AdvKitPlugin/Source/AdvKitRuntime/Classes/Actions/Movement/AdvKitCA_Dodge.h
crimsonstrife/velorum-defunct
1a6e1eab9057293da2aa045eff021d069df54c5e
[ "CC0-1.0" ]
null
null
null
Plugins/AdvKitPlugin/Source/AdvKitRuntime/Classes/Actions/Movement/AdvKitCA_Dodge.h
crimsonstrife/velorum-defunct
1a6e1eab9057293da2aa045eff021d069df54c5e
[ "CC0-1.0" ]
null
null
null
// Copyright 2015 Pascal Krabbe #pragma once #include "Object.h" #include "Actions/AdvKitCharacterAction.h" #include "AdvKitCA_Dodge.generated.h" /** * @brief Action that makes the character dodge in a given direction. */ UCLASS(abstract) class ADVKITRUNTIME_API UAdvKitCA_Dodge : public UAdvKitCharacterAction { GENERATED_BODY() public: /** This curve handles the percentage of dodge speed at which to dodge at a given time */ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) FRuntimeFloatCurve DodgeSpeedCurve; /** Direction in which to dodge */ UPROPERTY(BlueprintReadWrite) FVector DodgeDirection; /** How long to dodge in seconds */ UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) float DodgeDuration; /** Current progress of the dodging */ UPROPERTY(BlueprintReadWrite) float DodgeAlpha; /** How fast to dodge (gets multiplied by the dodge speed curve) */ UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) float DodgeSpeed; /** Location the character had before the current dodge move was executed */ FVector LastCharacterLocation; /** * Constructor */ UAdvKitCA_Dodge(const FObjectInitializer& ObjectInitializer); /** * Modifies movement acceleration if character has a target lock to make it move in a circle around the target. * @param OriginalAcceleration The unmodified acceleration * @return Modified acceleration that takes the target into account */ virtual FVector ModifyAccelerationWhenTargetLocked(const FVector& OriginalAcceleration); /** Begin UAdvKitCharacterAction Interface */ virtual FAdvKitActionResponse Start_Implementation(class UAdvKitCharacterAction_Arguments* Arguments = NULL, UAdvKitCharacterAction* InterruptedOther = NULL) override; virtual bool CanBeInterruptedBy_Implementation(const UAdvKitCharacterAction* Other) const override; /** End UAdvKitCharacterAction Interface */ //Begin UActorComponent Interface virtual void TickComponent(float DeltaSeconds, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; //End UActorComponent Interface /** * Creates an arguments object for the dodge action * @param Direction Direction in which to dodge in world space * @return Arguments object containing given parameters */ static class UAdvKitCharacterAction_Arguments* MakeArguments(FVector Direction); };
34.264706
168
0.795279
[ "object" ]
2a81861332dd44bd35a32dcd4f4fbdee1c0e37d9
1,033
h
C
source/core/mining-manager/query-recommendation/PrefixTable.h
izenecloud/sf1r-lite
8de9aa83c38c9cd05a80b216579552e89609f136
[ "Apache-2.0" ]
77
2015-02-12T20:59:20.000Z
2022-03-05T18:40:49.000Z
source/core/mining-manager/query-recommendation/PrefixTable.h
fytzzh/sf1r-lite
8de9aa83c38c9cd05a80b216579552e89609f136
[ "Apache-2.0" ]
1
2017-04-28T08:55:47.000Z
2017-07-10T10:10:53.000Z
source/core/mining-manager/query-recommendation/PrefixTable.h
fytzzh/sf1r-lite
8de9aa83c38c9cd05a80b216579552e89609f136
[ "Apache-2.0" ]
33
2015-01-05T03:03:05.000Z
2022-02-06T04:22:46.000Z
#ifndef SF1R_RECOMMEND_PREFIX_TABLE_H #define SF1R_RECOMMEND_PREFIX_TABLE_H #include <boost/unordered_map.hpp> #include <vector> #include <util/ustring/UString.h> #include "parser/Parser.h" namespace sf1r { namespace Recommend { class PrefixTable { typedef std::vector<UserQueryList> LeveledUQL; public: PrefixTable(const std::string& workdir); ~PrefixTable(); public: void insert(const std::string& userQuery, uint32_t freq); void search(const std::string& userQuery, UserQueryList& uqlist) const; void flush() const; void clear(); static bool isPrefixEnglish(const std::string& userQuery); friend std::ostream& operator<<(std::ostream& out, const PrefixTable& tc); friend std::istream& operator>>(std::istream& in, PrefixTable& tc); private: static void prefix(const izenelib::util::UString& userQuery, izenelib::util::UString& pref); private: boost::unordered_map<std::string, LeveledUQL> table_; static std::size_t PREFIX_SIZE; std::string workdir_; }; } } #endif
24.023256
96
0.727977
[ "vector" ]
2a8db376f77a8eb48832c491061a013a3cabfffa
20,752
h
C
Sources/Elastos/LibCore/inc/elastosx/crypto/CipherSpi.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
7
2017-07-13T10:34:54.000Z
2021-04-16T05:40:35.000Z
Sources/Elastos/LibCore/inc/elastosx/crypto/CipherSpi.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
null
null
null
Sources/Elastos/LibCore/inc/elastosx/crypto/CipherSpi.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
9
2017-07-13T12:33:20.000Z
2021-06-19T02:46:48.000Z
//========================================================================= // Copyright (C) 2012 The Elastos Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //========================================================================= #ifndef __ELASTOSX_CRYPTO_CIPHERSPI_H__ #define __ELASTOSX_CRYPTO_CIPHERSPI_H__ #include "Elastos.CoreLibrary.Extensions.h" #include <elastos/core/Object.h> using Elastos::Core::Object; using Elastos::IO::IByteBuffer; using Elastos::Security::IKey; using Elastos::Security::ISecureRandom; using Elastos::Security::IAlgorithmParameters; using Elastos::Security::Spec::IAlgorithmParameterSpec; namespace Elastosx { namespace Crypto { class ECO_PUBLIC CipherSpi : public Object , public ICipherSpi { public: CAR_INTERFACE_DECL() CipherSpi(); virtual ~CipherSpi(); /** * Creates a new {@code CipherSpi} instance. */ CARAPI constructor(); /** * Sets the mode for this cipher. * * @param mode * the name of the cipher mode. * @throws NoSuchAlgorithmException * if the specified cipher mode is not supported by this * provider. */ virtual CARAPI EngineSetMode( /* [in] */ const String& mode) = 0; /** * Sets the padding method for this cipher. * * @param padding * the name of the padding method. * @throws NoSuchPaddingException * if the specified padding method is not supported by this * cipher. */ virtual CARAPI EngineSetPadding( /* [in] */ const String& padding) = 0; /** * Returns the block size of this cipher (in bytes) * * @return the block size of this cipher, or zero if this cipher is not a * block cipher. */ virtual CARAPI EngineGetBlockSize( /* [out] */ Int32* size) = 0; /** * Returns the size for a buffer (in bytes), that the next call to {@code * update} of {@code doFinal} would return, taking into account any buffered * data from previous {@code update} calls and padding. * <p> * The actual output length of the next call to {@code update} or {@code * doFinal} may be smaller than the length returned by this method. * * @param inputLen * the length of the input (in bytes). * @return the size for a buffer (in bytes). */ virtual CARAPI EngineGetOutputSize( /* [in] */ Int32 inputLen, /* [out] */ Int32* size) = 0; /** * Returns the Initialization Vector (IV) that was used to initialize this * cipher or {@code null} if none was used. * * @return the Initialization Vector (IV), or {@code null} if none was used. */ virtual CARAPI EngineGetIV( /* [out, callee] */ ArrayOf<Byte>** iv) = 0; /** * Returns the parameters that where used to create this cipher instance. * <p> * These may be a the same parameters that were used to create this cipher * instance, or may be a combination of default and random parameters, * depending on the underlying cipher implementation. * * @return the parameters that where used to create this cipher instance, or * {@code null} if this cipher instance does not have any parameters * at all. */ virtual CARAPI EngineGetParameters( /* [out] */ IAlgorithmParameters** param) = 0; /** * Initializes this cipher instance with the specified key and a source of * randomness. * <p> * The cipher will be initialized for the specified operation (one of: * encryption, decryption, key wrapping or key unwrapping) depending on * {@code opmode}. * <p> * If this cipher instance needs any algorithm parameters or random values * that the specified key cannot provide, the underlying implementation of * this cipher is supposed to generate the required parameters (using its * provider or random values). Random values will be generated using {@code * random}; * <p> * When a cipher instance is initialized by a call to any of the {@code * init} methods, the state of the instance is overridden, means it is * equivalent to creating a new instance and calling it {@code init} method. * * @param opmode * the operation this cipher instance should be initialized for * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code * WRAP_MODE} or {@code UNWRAP_MODE}). * @param key * the input key for the operation. * @param random * the source of randomness to use. * @throws InvalidKeyException * if the specified key cannot be used to initialize this cipher * instance. */ virtual CARAPI EngineInit( /* [in] */ Int32 opmode, /* [in] */ IKey* key, /* [in] */ ISecureRandom* random) = 0; /** * Initializes this cipher instance with the specified key, algorithm * parameters and a source of randomness. * <p> * The cipher will be initialized for the specified operation (one of: * encryption, decryption, key wrapping or key unwrapping) depending on * {@code opmode}. * <p> * If this cipher instance needs any algorithm parameters and {@code params} * is {@code null}, the underlying implementation of this cipher is supposed * to generate the required parameters (using its provider or random * values). Random values are generated using {@code random}. * <p> * When a cipher instance is initialized by a call to any of the {@code * init} methods, the state of the instance is overridden, means it is * equivalent to creating a new instance and calling it {@code init} method. * * @param opmode * the operation this cipher instance should be initialized for * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code * WRAP_MODE} or {@code UNWRAP_MODE}). * @param key * the input key for the operation. * @param params * the algorithm parameters. * @param random * the source of randomness to use. * @throws InvalidKeyException * if the specified key cannot be used to initialize this cipher * instance. * @throws InvalidAlgorithmParameterException * it the specified parameters are inappropriate for this * cipher. */ virtual CARAPI EngineInit( /* [in] */ Int32 opmode, /* [in] */ IKey* key, /* [in] */ IAlgorithmParameterSpec* params, /* [in] */ ISecureRandom* random) = 0; /** * Initializes this cipher instance with the specified key, algorithm * parameters and a source of randomness. * <p> * The cipher will be initialized for the specified operation (one of: * encryption, decryption, key wrapping or key unwrapping) depending on * {@code opmode}. * <p> * If this cipher instance needs any algorithm parameters and {@code params} * is {@code null}, the underlying implementation of this cipher is supposed * to generate the required parameters (using its provider or random * values). Random values are generated using {@code random}. * <p> * When a cipher instance is initialized by a call to any of the {@code * init} methods, the state of the instance is overridden, means it is * equivalent to creating a new instance and calling it {@code init} method. * * @param opmode * the operation this cipher instance should be initialized for * (one of: {@code ENCRYPT_MODE}, {@code DECRYPT_MODE}, {@code * WRAP_MODE} or {@code UNWRAP_MODE}). * @param key * the input key for the operation. * @param params * the algorithm parameters. * @param random * the source of randomness to use. * @throws InvalidKeyException * if the specified key cannot be used to initialize this cipher * instance. * @throws InvalidAlgorithmParameterException * if the specified parameters are inappropriate for this * cipher. */ virtual CARAPI EngineInit( /* [in] */ Int32 opmode, /* [in] */ IKey* key, /* [in] */ IAlgorithmParameters* params, /* [in] */ ISecureRandom* random) = 0; /** * Continues a multi-part transformation (encryption or decryption). The * transformed bytes are returned. * * @param input * the input bytes to transform. * @param inputOffset * the offset in the input to start. * @param inputLen * the length of the input to transform. * @return the transformed bytes in a new buffer, or {@code null} if the * input has zero length. * @throws IllegalStateException * if this cipher instance is not initialized for encryption or * decryption. * @throws IllegalArgumentException * if the input is null, or if {@code inputOffset} and {@code * inputLen} do not specify a valid chunk in the input buffer. */ virtual CARAPI EngineUpdate( /* [in] */ ArrayOf<Byte>* input, /* [in] */ Int32 inputOffset, /* [in] */ Int32 inputLen, /* [out, callee] */ ArrayOf<Byte>** output) = 0; /** * Continues a multi-part transformation (encryption or decryption). The * transformed bytes are stored in the {@code output} buffer. * <p> * If the size of the {@code output} buffer is too small to hold the result, * a {@code ShortBufferException} is thrown. Use * {@link Cipher#getOutputSize getOutputSize} to check for the size of the * output buffer. * * @param input * the input bytes to transform. * @param inputOffset * the offset in the input to start. * @param inputLen * the length of the input to transform. * @param output * the output buffer. * @param outputOffset * the offset in the output buffer. * @return the number of bytes placed in output. * @throws ShortBufferException * if the size of the {@code output} buffer is too small. */ virtual CARAPI EngineUpdate( /* [in] */ ArrayOf<Byte>* input, /* [in] */ Int32 inputOffset, /* [in] */ Int32 inputLen, /* [in] */ ArrayOf<Byte>* output, /* [in] */ Int32 outputOffset, /* [out] */ Int32* number) = 0; /** * Continues a multi-part transformation (encryption or decryption). The * {@code input.remaining()} bytes starting at {@code input.position()} are * transformed and stored in the {@code output} buffer. * <p> * If the {@code output.remaining()} is too small to hold the transformed * bytes a {@code ShortBufferException} is thrown. Use * {@link Cipher#getOutputSize getOutputSize} to check for the size of the * output buffer. * * @param input * the input buffer to transform. * @param output * the output buffer to store the result within. * @return the number of bytes stored in the output buffer. * @throws ShortBufferException * if the size of the {@code output} buffer is too small. */ virtual CARAPI EngineUpdate( /* [in] */ IByteBuffer* input, /* [in] */ IByteBuffer* output, /* [out] */ Int32* number); /** * Continues a multi-part transformation (encryption or decryption) with * Authenticated Additional Data (AAD). AAD may only be added after the * {@code Cipher} is initialized and before any data is passed to the * instance. * <p> * This is only usable with cipher modes that support Authenticated * Encryption with Additional Data (AEAD) such as Galois/Counter Mode (GCM). * * @param input bytes of AAD to use with the cipher * @param inputOffset offset within bytes of additional data to add to cipher * @param inputLen length of bytes of additional data to add to cipher * @throws IllegalStateException * if this cipher instance is not initialized for encryption or * decryption. * @throws IllegalArgumentException * if {@code input} is {@code null}, or if {@code inputOffset} and * {@code inputLen} do not specify a valid chunk in the input * buffer. * @throws UnsupportedOperationException if the cipher does not support AEAD * @since 1.7 */ virtual CARAPI EngineUpdateAAD( /* [in] */ ArrayOf<Byte> * input, /* [in] */ Int32 inputOffset, /* [in] */ Int32 inputLen); /** * Continues a multi-part transformation (encryption or decryption). The * {@code input.remaining()} bytes starting at {@code input.position()} are * used for the Additional Authenticated Data (AAD). AAD may only be added * after the {@code Cipher} is initialized and before any data is passed to * the instance. * <p> * This is only usable with cipher modes that support Authenticated * Encryption with Additional Data (AEAD) such as Galois/Counter Mode (GCM). * * @param input the input buffer to transform. * @since 1.7 */ virtual CARAPI EngineUpdateAAD( /* [in] */ IByteBuffer* input); /** * Finishes a multi-part transformation (encryption or decryption). * <p> * Processes the {@code inputLen} bytes in {@code input} buffer at {@code * inputOffset}, and any bytes that have been buffered in previous {@code * update} calls. * * @param input * the input buffer. * @param inputOffset * the offset in the input buffer. * @param inputLen * the length of the input. * @return the final bytes from the transformation. * @throws IllegalBlockSizeException * if the size of the resulting bytes is not a multiple of the * cipher block size. * @throws BadPaddingException * if the padding of the data does not match the padding scheme. */ virtual CARAPI EngineDoFinal( /* [in] */ ArrayOf<Byte>* input, /* [in] */ Int32 inputOffset, /* [in] */ Int32 inputLen, /* [out, callee] */ ArrayOf<Byte>** bytes) = 0; /** * Finishes a multi-part transformation (encryption or decryption). * <p> * Processes the {@code inputLen} bytes in {@code input} buffer at * {@code inputOffset}, and any bytes that have been buffered in previous * {@code update} calls. * * @param input * the input buffer. * @param inputOffset * the offset in the input buffer. * @param inputLen * the length of the input. * @param output * the output buffer for the transformed bytes. * @param outputOffset * the offset in the output buffer. * @return the number of bytes placed in the output buffer. * @throws ShortBufferException * if the size of the {@code output} buffer is too small. * @throws IllegalBlockSizeException * if the size of the resulting bytes is not a multiple of the * cipher block size. * @throws BadPaddingException * if the padding of the data does not match the padding scheme. */ virtual CARAPI EngineDoFinal( /* [in] */ ArrayOf<Byte>* input, /* [in] */ Int32 inputOffset, /* [in] */ Int32 inputLen, /* [in] */ ArrayOf<Byte>* output, /* [in] */ Int32 outputOffset, /* [out] */ Int32* number) = 0; /** * Finishes a multi-part transformation (encryption or decryption). * <p> * Processes the {@code input.remaining()} bytes in {@code input} buffer at * {@code input.position()}, and any bytes that have been buffered in * previous {@code update} calls. The transformed bytes are placed into * {@code output} buffer. * * @param input * the input buffer. * @param output * the output buffer. * @return the number of bytes placed into the output buffer. * @throws ShortBufferException * if the size of the {@code output} buffer is too small. * @throws IllegalBlockSizeException * if the size of the resulting bytes is not a multiple of the * cipher block size. * @throws BadPaddingException * if the padding of the data does not match the padding scheme. * @throws IllegalArgumentException * if the input buffer and the output buffer are the same * object. * @throws IllegalStateException * if this cipher instance is not initialized for encryption or * decryption. */ virtual CARAPI EngineDoFinal( /* [in] */ IByteBuffer* input, /* [in] */ IByteBuffer* output, /* [out] */ Int32* number); /** * Wraps a key using this cipher instance. This method has been added to * this class (for backwards compatibility, it cannot be abstract). If this * method is not overridden, it throws an {@code * UnsupportedOperationException}. * * @param key * the key to wrap. * @return the wrapped key * @throws IllegalBlockSizeException * if the size of the resulting bytes is not a multiple of the * cipher block size. * @throws InvalidKeyException * if this cipher instance cannot wrap this key. */ virtual CARAPI EngineWrap( /* [in] */ IKey* keyToWrap, /* [out, callee] */ ArrayOf<Byte>** wrappedKey); /** * Unwraps a key using this cipher instance. * <p> * This method has been added to this class (for backwards compatibility, it * cannot be abstract). If this method is not overridden, it throws an * {@code UnsupportedOperationException}. * * @param wrappedKey * the wrapped key to unwrap. * @param wrappedKeyAlgorithm * the algorithm for the wrapped key. * @param wrappedKeyType * the type of the wrapped key (one of: {@code SECRET_KEY}, * {@code PRIVATE_KEY} or {@code PUBLIC_KEY}) * @return the unwrapped key. * @throws InvalidKeyException * if the {@code wrappedKey} cannot be unwrapped to a key of * type {@code wrappedKeyType} for the {@code * wrappedKeyAlgorithm}. * @throws NoSuchAlgorithmException * if no provider can be found that can create a key of type * {@code wrappedKeyType} for the {@code wrappedKeyAlgorithm}. */ virtual CARAPI EngineUnwrap( /* [in] */ ArrayOf<Byte>* wrappedKey, /* [in] */ const String& wrappedKeyAlgorithm, /* [in] */ Int32 wrappedKeyType, /* [out] */ IKey** key); /** * Returns the size of a specified key object in bits. This method has been * added to this class (for backwards compatibility, it cannot be abstract). * If this method is not overridden, it throws an {@code * UnsupportedOperationException}. * * @param key * the key to get the size for. * @return the size of a specified key object in bits. * @throws InvalidKeyException * if the size of the key cannot be determined by this * implementation. */ virtual CARAPI EngineGetKeySize( /* [in] */ IKey* key, /* [out] */ Int32* size); }; } } #endif // __ELASTOSX_CRYPTO_CIPHERSPI_H__
39.831094
82
0.601388
[ "object", "vector", "transform" ]
2aa7987710def768c8d5ab585a664d040a33fcbe
1,122
h
C
src/nextfloor/gameplay/input_handler.h
ricofehr/enginepp
5c67083c61247410878f1f80bf2858d3244b2074
[ "MIT" ]
null
null
null
src/nextfloor/gameplay/input_handler.h
ricofehr/enginepp
5c67083c61247410878f1f80bf2858d3244b2074
[ "MIT" ]
null
null
null
src/nextfloor/gameplay/input_handler.h
ricofehr/enginepp
5c67083c61247410878f1f80bf2858d3244b2074
[ "MIT" ]
null
null
null
/** * @file input_handler.h * @brief InputHandler Header File * @author Eric Fehr (ricofehr@nextdeploy.io, github: ricofehr) */ #ifndef NEXTFLOOR_GAMEPLAY_INPUTHANDLER_H_ #define NEXTFLOOR_GAMEPLAY_INPUTHANDLER_H_ #include "nextfloor/gameplay/hid.h" #include "nextfloor/gameplay/action.h" #include "nextfloor/gameplay/action_factory.h" namespace nextfloor { namespace gameplay { /** * @class InputHandler * @brief InputHandler base class for handle player inputs */ class InputHandler { public: virtual ~InputHandler() = default; virtual void InitCommands(const ActionFactory& action_factory) = 0; /** * Get Current State Input * @return Command Object */ virtual Action* HandlerInput() = 0; /** * Get HID Pointer angles changes * @return HIDPointer struct */ virtual HIDPointer RecordHIDPointer(double elapsed_time) = 0; virtual void PollEvents() = 0; virtual void ResetPointer() = 0; virtual bool IsOpenMenuEventOccurs() = 0; }; } // namespace gameplay } // namespace nextfloor #endif // NEXTFLOOR_GAMEPLAY_INPUTHANDLER_H_
22.44
71
0.706774
[ "object" ]
2abff2212b8fe8b295c237fe53a11a4ce967867d
11,486
c
C
suricata-3.2/src/detect-engine-alert.c
wenze1367/suricata-3.2-read-anotaion
0c63a9a4ed1b7654cc74490a9748eb3e33951952
[ "BSD-2-Clause" ]
1
2021-11-26T08:12:42.000Z
2021-11-26T08:12:42.000Z
suricata-3.2/src/detect-engine-alert.c
wenze1367/suricata-3.2-read-anotaion
0c63a9a4ed1b7654cc74490a9748eb3e33951952
[ "BSD-2-Clause" ]
null
null
null
suricata-3.2/src/detect-engine-alert.c
wenze1367/suricata-3.2-read-anotaion
0c63a9a4ed1b7654cc74490a9748eb3e33951952
[ "BSD-2-Clause" ]
1
2021-11-26T08:12:47.000Z
2021-11-26T08:12:47.000Z
/* Copyright (C) 2007-2011 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * version 2 along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #include "suricata-common.h" #include "detect.h" #include "detect-engine-alert.h" #include "detect-engine-threshold.h" #include "detect-engine-tag.h" #include "decode.h" #include "flow.h" #include "flow-private.h" #include "util-profiling.h" /** tag signature we use for tag alerts */ static Signature g_tag_signature; /** tag packet alert structure for tag alerts */ static PacketAlert g_tag_pa; void PacketAlertTagInit(void) { memset(&g_tag_signature, 0x00, sizeof(g_tag_signature)); g_tag_signature.id = TAG_SIG_ID; g_tag_signature.gid = TAG_SIG_GEN; g_tag_signature.num = TAG_SIG_ID; g_tag_signature.rev = 1; g_tag_signature.prio = 2; memset(&g_tag_pa, 0x00, sizeof(g_tag_pa)); g_tag_pa.action = ACTION_ALERT; g_tag_pa.s = &g_tag_signature; } PacketAlert *PacketAlertGetTag(void) { return &g_tag_pa; } /** * \brief Handle a packet and check if needs a threshold logic * Also apply rule action if necessary. * * \param de_ctx Detection Context * \param sig Signature pointer * \param p Packet structure * * \retval 1 alert is not suppressed * \retval 0 alert is suppressed */ static int PacketAlertHandle(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, Packet *p, PacketAlert *pa) { SCEnter(); int ret = 1; const DetectThresholdData *td = NULL; const SigMatch *sm; if (!(PKT_IS_IPV4(p) || PKT_IS_IPV6(p))) { SCReturnInt(1); } /* handle suppressions first */ if (s->sm_lists[DETECT_SM_LIST_SUPPRESS] != NULL) { KEYWORD_PROFILING_SET_LIST(det_ctx, DETECT_SM_LIST_SUPPRESS); sm = NULL; do { td = SigGetThresholdTypeIter(s, p, &sm, DETECT_SM_LIST_SUPPRESS); if (td != NULL) { SCLogDebug("td %p", td); /* PacketAlertThreshold returns 2 if the alert is suppressed but * we do need to apply rule actions to the packet. */ KEYWORD_PROFILING_START; ret = PacketAlertThreshold(de_ctx, det_ctx, td, p, s, pa); if (ret == 0 || ret == 2) { KEYWORD_PROFILING_END(det_ctx, DETECT_THRESHOLD, 0); /* It doesn't match threshold, remove it */ SCReturnInt(ret); } KEYWORD_PROFILING_END(det_ctx, DETECT_THRESHOLD, 1); } } while (sm != NULL); } /* if we're still here, consider thresholding */ if (s->sm_lists[DETECT_SM_LIST_THRESHOLD] != NULL) { KEYWORD_PROFILING_SET_LIST(det_ctx, DETECT_SM_LIST_THRESHOLD); sm = NULL; do { td = SigGetThresholdTypeIter(s, p, &sm, DETECT_SM_LIST_THRESHOLD); if (td != NULL) { SCLogDebug("td %p", td); /* PacketAlertThreshold returns 2 if the alert is suppressed but * we do need to apply rule actions to the packet. */ KEYWORD_PROFILING_START; ret = PacketAlertThreshold(de_ctx, det_ctx, td, p, s, pa); if (ret == 0 || ret == 2) { KEYWORD_PROFILING_END(det_ctx, DETECT_THRESHOLD ,0); /* It doesn't match threshold, remove it */ SCReturnInt(ret); } KEYWORD_PROFILING_END(det_ctx, DETECT_THRESHOLD, 1); } } while (sm != NULL); } SCReturnInt(1); } /** * \brief Check if a certain sid alerted, this is used in the test functions * * \param p Packet on which we want to check if the signature alerted or not * \param sid Signature id of the signature that thas to be checked for a match * * \retval match A value > 0 on a match; 0 on no match */ int PacketAlertCheck(Packet *p, uint32_t sid) { uint16_t i = 0; int match = 0; for (i = 0; i < p->alerts.cnt; i++) { if (p->alerts.alerts[i].s == NULL) continue; if (p->alerts.alerts[i].s->id == sid) match++; } return match; } /** * \brief Remove alert from the p->alerts.alerts array at pos * \param p Pointer to the Packet * \param pos Position in the array * \retval 0 if the number of alerts is less than pos * 1 if all goes well */ int PacketAlertRemove(Packet *p, uint16_t pos) { uint16_t i = 0; int match = 0; if (pos > p->alerts.cnt) { SCLogDebug("removing %u failed, pos > cnt %u", pos, p->alerts.cnt); return 0; } for (i = pos; i <= p->alerts.cnt - 1; i++) { memcpy(&p->alerts.alerts[i], &p->alerts.alerts[i + 1], sizeof(PacketAlert)); } // Update it, since we removed 1 p->alerts.cnt--; return match; } /** \brief append a signature match to a packet * * \param det_ctx thread detection engine ctx * \param s the signature that matched * \param p packet * \param flags alert flags * \param alert_msg ptr to StreamMsg object that the signature matched on */ int PacketAlertAppend(DetectEngineThreadCtx *det_ctx, Signature *s, Packet *p, uint64_t tx_id, uint8_t flags) { int i = 0; if (p->alerts.cnt == PACKET_ALERT_MAX) return 0; SCLogDebug("sid %"PRIu32"", s->id); /* It should be usually the last, so check it before iterating */ if (p->alerts.cnt == 0 || (p->alerts.cnt > 0 && p->alerts.alerts[p->alerts.cnt - 1].num < s->num)) { /* We just add it */ p->alerts.alerts[p->alerts.cnt].num = s->num; p->alerts.alerts[p->alerts.cnt].action = s->action; p->alerts.alerts[p->alerts.cnt].flags = flags; p->alerts.alerts[p->alerts.cnt].s = s; p->alerts.alerts[p->alerts.cnt].tx_id = tx_id; } else { /* We need to make room for this s->num (a bit ugly with memcpy but we are planning changes here)*/ for (i = p->alerts.cnt - 1; i >= 0 && p->alerts.alerts[i].num > s->num; i--) { memcpy(&p->alerts.alerts[i + 1], &p->alerts.alerts[i], sizeof(PacketAlert)); } i++; /* The right place to store the alert */ p->alerts.alerts[i].num = s->num; p->alerts.alerts[i].action = s->action; p->alerts.alerts[i].flags = flags; p->alerts.alerts[i].s = s; p->alerts.alerts[i].tx_id = tx_id; } /* Update the count */ p->alerts.cnt++; return 0; } /** * \brief Check the threshold of the sigs that match, set actions, break on pass action * This function iterate the packet alerts array, removing those that didn't match * the threshold, and those that match after a signature with the action "pass". * The array is sorted by action priority/order * \param de_ctx detection engine context * \param det_ctx detection engine thread context * \param p pointer to the packet */ void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p) { SCEnter(); int i = 0; SigMatch *sm = NULL; while (i < p->alerts.cnt) { SCLogDebug("Sig->num: %"PRIu16, p->alerts.alerts[i].num); const Signature *s = de_ctx->sig_array[p->alerts.alerts[i].num]; int res = PacketAlertHandle(de_ctx, det_ctx, s, p, &p->alerts.alerts[i]); if (res > 0) { /* Now, if we have an alert, we have to check if we want * to tag this session or src/dst host */ KEYWORD_PROFILING_SET_LIST(det_ctx, DETECT_SM_LIST_TMATCH); sm = s->sm_lists[DETECT_SM_LIST_TMATCH]; while (sm) { /* tags are set only for alerts */ KEYWORD_PROFILING_START; sigmatch_table[sm->type].Match(NULL, det_ctx, p, (Signature *)s, sm->ctx); KEYWORD_PROFILING_END(det_ctx, sm->type, 1); sm = sm->next; } if (s->flags & SIG_FLAG_IPONLY) { if (((p->flowflags & FLOW_PKT_TOSERVER) && !(p->flowflags & FLOW_PKT_TOSERVER_IPONLY_SET)) || ((p->flowflags & FLOW_PKT_TOCLIENT) && !(p->flowflags & FLOW_PKT_TOCLIENT_IPONLY_SET))) { SCLogDebug("testing against \"ip-only\" signatures"); if (p->flow != NULL) { /* Update flow flags for iponly */ FlowSetIPOnlyFlag(p->flow, (p->flowflags & FLOW_PKT_TOSERVER) ? 1 : 0); if (s->action & ACTION_DROP) p->flow->flags |= FLOW_ACTION_DROP; if (s->action & ACTION_REJECT) p->flow->flags |= FLOW_ACTION_DROP; if (s->action & ACTION_REJECT_DST) p->flow->flags |= FLOW_ACTION_DROP; if (s->action & ACTION_REJECT_BOTH) p->flow->flags |= FLOW_ACTION_DROP; if (s->action & ACTION_PASS) { FlowSetNoPacketInspectionFlag(p->flow); } } } } /* set actions on packet */ DetectSignatureApplyActions(p, p->alerts.alerts[i].s); if (PACKET_TEST_ACTION(p, ACTION_PASS)) { /* Ok, reset the alert cnt to end in the previous of pass * so we ignore the rest with less prio */ p->alerts.cnt = i; /* if an stream/app-layer match we enforce the pass for the flow */ if ((p->flow != NULL) && (p->alerts.alerts[i].flags & (PACKET_ALERT_FLAG_STATE_MATCH|PACKET_ALERT_FLAG_STREAM_MATCH))) { FlowSetNoPacketInspectionFlag(p->flow); } break; /* if the signature wants to drop, check if the * PACKET_ALERT_FLAG_DROP_FLOW flag is set. */ } else if ((PACKET_TEST_ACTION(p, ACTION_DROP)) && ((p->alerts.alerts[i].flags & PACKET_ALERT_FLAG_DROP_FLOW) || (s->flags & SIG_FLAG_APPLAYER)) && p->flow != NULL) { /* This will apply only on IPS mode (check StreamTcpPacket) */ p->flow->flags |= FLOW_ACTION_DROP; // XXX API? } } /* Thresholding removes this alert */ if (res == 0 || res == 2) { PacketAlertRemove(p, i); if (p->alerts.cnt == 0) break; } else { i++; } } /* At this point, we should have all the new alerts. Now check the tag * keyword context for sessions and hosts */ if (!(p->flags & PKT_PSEUDO_STREAM_END)) TagHandlePacket(de_ctx, det_ctx, p); }
34.492492
109
0.572436
[ "object" ]
2accf0960cc321402174a3c0cf93b3f692f1f259
966
h
C
serialthread.h
josefrcm/imu_calibration
ec9d868f93f3382382976c5d5e67481558a06c39
[ "MIT" ]
1
2020-04-07T08:47:53.000Z
2020-04-07T08:47:53.000Z
serialthread.h
josefrcm/imu_calibration
ec9d868f93f3382382976c5d5e67481558a06c39
[ "MIT" ]
null
null
null
serialthread.h
josefrcm/imu_calibration
ec9d868f93f3382382976c5d5e67481558a06c39
[ "MIT" ]
null
null
null
#pragma once #include <QSerialPort> #include <QSerialPortInfo> #include <QThread> #include "Render/types.h" /// /// \brief Hilo para la lectura del estado del IMU. /// class SerialThread : public QThread { Q_OBJECT public: explicit SerialThread(const QSerialPortInfo& info, QObject* parent = 0); ~SerialThread(); void run(); const QString& getUID() const; void setMode(IMUMode mode); void recalibrate(const QMatrix4x4& acc, const QMatrix4x4& mag); signals: void readOrientation(QQuaternion ori); void readForce(QVector4D force); void readRawSensors(QVector3D gyr, QVector3D acc, QVector3D mag); void readRawAnalog(float values[6]); private: QSerialPortInfo m_info; QSerialPort* m_port; QString m_uid; QMatrix4x4 m_acc_calib, m_mag_calib; bool m_write_calib, m_change_mode; IMUMode m_mode; QStringList sendCommand(const QByteArray& command); };
23
77
0.686335
[ "render" ]
2ad19031719938343406243df20b323a08a4b099
3,329
c
C
src/engine.c
0metecey1/ldms
3fcf25259446137d4d7b818a7a5aa35d74f94a3b
[ "MIT" ]
2
2021-02-20T17:15:20.000Z
2021-02-20T17:17:48.000Z
src/engine.c
0metecey1/ldms
3fcf25259446137d4d7b818a7a5aa35d74f94a3b
[ "MIT" ]
null
null
null
src/engine.c
0metecey1/ldms
3fcf25259446137d4d7b818a7a5aa35d74f94a3b
[ "MIT" ]
1
2021-03-05T02:17:32.000Z
2021-03-05T02:17:32.000Z
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <lua.h> #include <lauxlib.h> #include <lualib.h> static const char *progname = "lua"; /* ** Prints an error message, adding the program name in front of it ** (if present) */ static void l_message (const char *pname, const char *msg) { if (pname) lua_writestringerror("%s: ", pname); lua_writestringerror("%s\n", msg); fflush(stderr); } /* ** Check whether 'status' is not OK and, if so, prints the error ** message on the top of the stack. It assumes that the error object ** is a string, as it was either generated by Lua or by 'msghandler'. */ static int report (lua_State *L, int status, char *errbuf) { if (status != LUA_OK) { const char *msg = lua_tostring(L, -1); l_message(progname, msg); sprintf(errbuf, "%s", msg); lua_pop(L, 1); /* remove message */ } return status; } /* ** Message handler used to run all chunks */ static int msghandler (lua_State *L) { const char *msg = lua_tostring(L, 1); if (msg == NULL) { /* is error object not a string? */ if (luaL_callmeta(L, 1, "__tostring") && /* does it have a metamethod */ lua_type(L, -1) == LUA_TSTRING) /* that produces a string? */ return 1; /* that is the message */ else msg = lua_pushfstring(L, "(error object is a %s value)", luaL_typename(L, 1)); } luaL_traceback(L, L, msg, 1); /* append a standard traceback */ return 1; /* return the traceback */ } /* ** Interface to 'lua_pcall', which sets appropriate message function ** and C-signal handler. Used to run all chunks. */ static int docall (lua_State *L, int narg, int nres) { int status; int base = lua_gettop(L) - narg; /* function index */ lua_pushcfunction(L, msghandler); /* push message handler */ lua_insert(L, base); /* put it under function and args */ status = lua_pcall(L, narg, nres, base); lua_remove(L, base); /* remove message handler from the stack */ return status; } static int dochunk (lua_State *L, int status, char *errbuf) { if (status == LUA_OK) status = docall(L, 0, 0); return report(L, status, errbuf); } static int dochunkcoop (lua_State *L, int status, char *errbuf) { if (status == LUA_OK) { status = docall(L, 0, 0); } return report(L, status, errbuf); } int engine_dofile (lua_State *L, const char *name, char *errbuf) { return dochunk(L, luaL_loadfile(L, name), errbuf); } int engine_dostring (lua_State *L, const char *s, const char *name, char *errbuf, int concurrent) { if (concurrent) { // It is assumed that s contains a lua function // Wrap this function with 'runProcess(s)' and do the call const char *chunkprep = "runProcess("; const char *chunkapp = ")"; /* Wrap 'runProcess()' arround the chunk of Lua code received */ char *lchunk = (char *)malloc(strlen(s) + strlen(chunkprep) + strlen(chunkapp) + 1); strcpy(lchunk, chunkprep); strcat(lchunk, s); strcat(lchunk, chunkapp); return dochunkcoop(L, luaL_loadbuffer(L, lchunk, strlen(lchunk), name), errbuf); } else return dochunk(L, luaL_loadbuffer(L, s, strlen(s), name), errbuf); }
32.960396
99
0.618204
[ "object" ]
2adb9985e81ee9323a85d9c8befb0f836fda450f
1,168
h
C
src/Core/Resource/Factory/CMaterialLoader.h
henriquegemignani/PrimeWorldEditor
741185e8d695c5bc86b7efbfadaf4e5dcd67d4d9
[ "MIT" ]
1
2018-12-25T02:09:27.000Z
2018-12-25T02:09:27.000Z
src/Core/Resource/Factory/CMaterialLoader.h
henriquegemignani/PrimeWorldEditor
741185e8d695c5bc86b7efbfadaf4e5dcd67d4d9
[ "MIT" ]
null
null
null
src/Core/Resource/Factory/CMaterialLoader.h
henriquegemignani/PrimeWorldEditor
741185e8d695c5bc86b7efbfadaf4e5dcd67d4d9
[ "MIT" ]
1
2020-02-21T15:22:56.000Z
2020-02-21T15:22:56.000Z
#ifndef CMATERIALLOADER_H #define CMATERIALLOADER_H #include "Core/GameProject/CResourceStore.h" #include "Core/Resource/CMaterialSet.h" #include <Common/EGame.h> #include <Common/FileIO.h> #include <assimp/scene.h> class CMaterialLoader { // Material data CMaterialSet *mpSet; IInputStream *mpFile; EGame mVersion; std::vector<TResPtr<CTexture>> mTextures; bool mHasOPAC; bool mHas0x400; CColor mCorruptionColors[4]; uint8 mCorruptionInts[5]; uint32 mCorruptionFlags; std::vector<uint32> mPassOffsets; CMaterialLoader(); ~CMaterialLoader(); FVertexDescription ConvertToVertexDescription(uint32 VertexFlags); // Load Functions void ReadPrimeMatSet(); CMaterial* ReadPrimeMaterial(); void ReadCorruptionMatSet(); CMaterial* ReadCorruptionMaterial(); void CreateCorruptionPasses(CMaterial *pMat); CMaterial* LoadAssimpMaterial(const aiMaterial *pAiMat); // Static public: static CMaterialSet* LoadMaterialSet(IInputStream& rMat, EGame Version); static CMaterialSet* ImportAssimpMaterials(const aiScene *pScene, EGame TargetVersion); }; #endif // CMATERIALLOADER_H
24.851064
91
0.741438
[ "vector" ]
2ae1b2eec0cc4da40e59cd820d3df63b69399085
590
h
C
TextGo/Game.h
OpenKastle/textgo
2ae768f95918aafe5c5a76a143e0f3f690625ba7
[ "MIT" ]
null
null
null
TextGo/Game.h
OpenKastle/textgo
2ae768f95918aafe5c5a76a143e0f3f690625ba7
[ "MIT" ]
null
null
null
TextGo/Game.h
OpenKastle/textgo
2ae768f95918aafe5c5a76a143e0f3f690625ba7
[ "MIT" ]
null
null
null
#pragma once #include "Board.h" #include "Actions.h" #include <vector> #include <memory> class AbstractAction; enum class Handicap { Two, Three, Four, Five, Six, Seven, Eight, Nine }; class Game { public: Game(); Game(Handicap handicap); ~Game() = default; void Start(); private: void AddHistory(std::unique_ptr<AbstractAction> action); Board m_board; Stone m_turn = Stone::Black; std::string m_failureCondition; std::vector<std::unique_ptr<AbstractAction>> m_history; unsigned int m_historyIndex = 0; };
14.047619
60
0.638983
[ "vector" ]
2af5a9f1ec8a89ee8380ffb14dd7982ee8b16390
953
h
C
src/ColorBuffer.h
eaymerich/cateye
8939a9cca3f3e4e04ec9e7ed7da60e3d4a5acb51
[ "MIT" ]
null
null
null
src/ColorBuffer.h
eaymerich/cateye
8939a9cca3f3e4e04ec9e7ed7da60e3d4a5acb51
[ "MIT" ]
null
null
null
src/ColorBuffer.h
eaymerich/cateye
8939a9cca3f3e4e04ec9e7ed7da60e3d4a5acb51
[ "MIT" ]
null
null
null
/***************************************************************************** * File: ColorBuffer.h * Author: Edward Aymerich Sanchez * Year: 2020 *****************************************************************************/ #ifndef __COLOR_BUFFER_H__ #define __COLOR_BUFFER_H__ #include <vector> #include "Color.h" class ColorBuffer { public: ColorBuffer(unsigned int width, unsigned int height); ~ColorBuffer() = default; void set(unsigned int x, unsigned int y, const Color &color); Color get(unsigned int x, unsigned int y) const; void clear(const Color &color); Color& operator[](std::size_t idx) { return colors[idx]; } const Color& operator[](std::size_t idx) const { return colors[idx]; } unsigned int getWidth() { return width; }; unsigned int getHeight() { return height; }; private: std::vector<Color> colors; unsigned int width; unsigned int height; }; #endif // __COLOR_BUFFER_H__
28.878788
78
0.578174
[ "vector" ]
2af9ae13e3c98b58de58a7ba195b410971fb1fe5
2,532
h
C
samples/hellovr_vulkan/vrsystem.h
marijnfs/openvr
0cb1d00d2e034fcfdfea289ecc4dcd033c6de882
[ "BSD-3-Clause" ]
null
null
null
samples/hellovr_vulkan/vrsystem.h
marijnfs/openvr
0cb1d00d2e034fcfdfea289ecc4dcd033c6de882
[ "BSD-3-Clause" ]
null
null
null
samples/hellovr_vulkan/vrsystem.h
marijnfs/openvr
0cb1d00d2e034fcfdfea289ecc4dcd033c6de882
[ "BSD-3-Clause" ]
null
null
null
#ifndef __VRSYSTEM_H__ #define __VRSYSTEM_H__ #include <vector> #include <string> #include <openvr.h> #include "shared/Matrices.h" #include "buffer.h" #include "vulkansystem.h" #include "scene.h" #include "framerenderbuffer.h" #include <vulkan/vulkan.h> struct TrackedController { Matrix4 t; bool pressed = false; std::vector<float> get_pos(); void set_t(Matrix4 &t); }; struct VRSystem { vr::IVRSystem *ivrsystem = 0; vr::IVRRenderModels *render_models = 0; std::string driver_str, display_str; //tracking vars vr::TrackedDevicePose_t tracked_pose[ vr::k_unMaxTrackedDeviceCount ]; Matrix4 tracked_pose_mat4[ vr::k_unMaxTrackedDeviceCount ]; vr::TrackedDeviceClass device_class[ vr::k_unMaxTrackedDeviceCount ]; //common matrices Matrix4 hmd_pose, hmd_pose_inverse; Matrix4 eye_pos_left, eye_pos_right, eye_pose_center; Matrix4 projection_left, projection_right; //controllers; TrackedController left_controller, right_controller; //render targets FrameRenderBuffer *left_eye_fb = 0, *right_eye_fb = 0; //Buffer left_eye_buf, right_eye_buf; //void *left_eye_mvp, *right_eye_mvp; ////buffers //std::vector<Buffer> eye_pos_buffer; uint32_t render_width = 0, render_height = 0; float near_clip = 0, far_clip = 0; DrawVisitor draw_visitor; //visitor pattern to draw the scene Image dst_image_left, dst_image_right; VRSystem(); ~VRSystem(); void init(); void init_headless(); void init_full(); void setup(); Matrix4 get_eye_transform( vr::Hmd_Eye eye ); Matrix4 get_hmd_projection( vr::Hmd_Eye eye ); Matrix4 get_view_projection( vr::Hmd_Eye eye ); void request_poses(); void update_track_pose(); void wait_frame(); void render(Scene &scene, bool headless = false, std::vector<float> *img_ptr = 0); void render_stereo_targets(Scene &scene); void render_companion_window(); void copy_image_to_cpu(std::vector<float> &img); std::vector<float> get_image_data(); void submit_to_hmd(); void presentKHR(); void to_present(); void setup_render_models(); void setup_render_model_for_device(int d); void setup_render_targets(); uint64_t get_output_device(VkInstance v_inst); std::string query_str(vr::TrackedDeviceIndex_t devidx, vr::TrackedDeviceProperty prop); std::vector<std::string> get_inst_ext_required(); std::vector<std::string> get_dev_ext_required(); std::vector<std::string> get_inst_ext_required_verified(); std::vector<std::string> get_dev_ext_required_verified(); }; #endif
25.575758
89
0.740126
[ "render", "vector" ]
6301b296e007b5b213e225d82c35a63624dc6737
1,657
h
C
Model.h
olegyadrov/softwarerenderer
e5437095f87c874b8e44d8f443dfa3d3a6d8bafe
[ "BSD-3-Clause" ]
8
2020-12-28T03:43:23.000Z
2022-02-05T02:13:43.000Z
Model.h
olegyadrov/softwarerenderer
e5437095f87c874b8e44d8f443dfa3d3a6d8bafe
[ "BSD-3-Clause" ]
null
null
null
Model.h
olegyadrov/softwarerenderer
e5437095f87c874b8e44d8f443dfa3d3a6d8bafe
[ "BSD-3-Clause" ]
null
null
null
#ifndef MODEL_H #define MODEL_H #include <QVector3D> #include <QVector2D> #include <QVector> #include <QImage> class Face { public: Face() : vertexA(0) , vertexB(0) , vertexC(0) , textureCoordinateA(0) , textureCoordinateB(0) , textureCoordinateC(0) , normalA(0) , normalB(0) , normalC(0) {} Face(int vertexA, int vertexB, int vertexC, int textureCoordinateA, int textureCoordinateB, int textureCoordinateC, int normalA, int normalB, int normalC) : vertexA(vertexA) , vertexB(vertexB) , vertexC(vertexC) , textureCoordinateA(textureCoordinateA) , textureCoordinateB(textureCoordinateB) , textureCoordinateC(textureCoordinateC) , normalA(normalA) , normalB(normalB) , normalC(normalC) {} int vertexA; int vertexB; int vertexC; int textureCoordinateA; int textureCoordinateB; int textureCoordinateC; int normalA; int normalB; int normalC; }; class Model { public: Model(); bool loadVertexData(const QString &source); bool loadTexture(const QString &source); bool hasVertexData() const; bool hasTexture() const; QVector<QVector3D> vertices() const; QVector<Face> faces() const; QVector<QVector2D> uvs() const; QVector<QVector3D> normals() const; QImage texture() const; private: void clearVertexData(); void clearTexture(); QVector<QVector3D> m_vertices; QVector<Face> m_faces; QVector<QVector2D> m_uvs; QVector<QVector3D> m_normals; QImage m_texture; }; #endif // MODEL_H
23.338028
80
0.640314
[ "model" ]
6304fa8c8df0560ee0ed35f1d302db72ac6c7196
3,855
h
C
Code/Components/Player.h
ShadowGameStudio/Project-Unknown
e9e25d192d65b97a5c9c751ccf99a5ea8f901c65
[ "MIT" ]
null
null
null
Code/Components/Player.h
ShadowGameStudio/Project-Unknown
e9e25d192d65b97a5c9c751ccf99a5ea8f901c65
[ "MIT" ]
null
null
null
Code/Components/Player.h
ShadowGameStudio/Project-Unknown
e9e25d192d65b97a5c9c751ccf99a5ea8f901c65
[ "MIT" ]
null
null
null
#pragma once #include <array> #include <numeric> #include <CryEntitySystem/IEntityComponent.h> #include <CryMath/Cry_Camera.h> #include <ICryMannequin.h> #include <DefaultComponents/Cameras/CameraComponent.h> #include <DefaultComponents/Physics/CharacterControllerComponent.h> #include <DefaultComponents/Geometry/AdvancedAnimationComponent.h> #include <DefaultComponents/Input/InputComponent.h> #include "ItemComponent.h" #include "InventoryComponent.h" //////////////////////////////////////////////////////// // Represents a player participating in gameplay //////////////////////////////////////////////////////// class CPlayerComponent final : public IEntityComponent { enum class EInputFlagType { Hold = 0, Toggle }; typedef uint8 TInputFlags; enum class EInputFlag : TInputFlags { MoveLeft = 1 << 0, MoveRight = 1 << 1, MoveForward = 1 << 2, MoveBack = 1 << 3 }; template<typename T, size_t SAMPLES_COUNT> class MovingAverage { static_assert(SAMPLES_COUNT > 0, "SAMPLES_COUNT shall be larger than zero!"); public: MovingAverage() : m_values() , m_cursor(SAMPLES_COUNT) , m_accumulator() { } MovingAverage& Push(const T& value) { if (m_cursor == SAMPLES_COUNT) { m_values.fill(value); m_cursor = 0; m_accumulator = std::accumulate(m_values.begin(), m_values.end(), T(0)); } else { m_accumulator -= m_values[m_cursor]; m_values[m_cursor] = value; m_accumulator += m_values[m_cursor]; m_cursor = (m_cursor + 1) % SAMPLES_COUNT; } return *this; } T Get() const { return m_accumulator / T(SAMPLES_COUNT); } void Reset() { m_cursor = SAMPLES_COUNT; } private: std::array<T, SAMPLES_COUNT> m_values; size_t m_cursor; T m_accumulator; }; public: CPlayerComponent() = default; virtual ~CPlayerComponent() {} // IEntityComponent virtual void Initialize() override; virtual uint64 GetEventMask() const override; virtual void ProcessEvent(const SEntityEvent& event) override; // ~IEntityComponent // Reflect type to set a unique identifier for this component static void ReflectType(Schematyc::CTypeDesc<CPlayerComponent>& desc) { desc.SetGUID("{63F4C0C6-32AF-4ACB-8FB0-57D45DD14725}"_cry_guid); } void Revive(); //Getting Cry::DefaultComponents::CAdvancedAnimationComponent *GetAnimations() { return m_pAnimationComponent; } CInventoryComponent *GetInventory() { return m_pInventoryComponent; } protected: //Update void UpdateMovementRequest(float frameTime); void UpdateLookDirectionRequest(float frameTime); void UpdateAnimation(float frameTime); void UpdateCamera(float frameTime); void Update(float frameTime); void CheckForPickup(); void ShowMessage(string name); //Input void InitializeInput(); void HandleInputFlagChange(TInputFlags flags, int activationMode, EInputFlagType type = EInputFlagType::Hold); //Actions void Action_Use(int activationMode); //Main void SpawnAtSpawnPoint(); void Pickup(SItemComponent *pNewItem); protected: Cry::DefaultComponents::CCameraComponent* m_pCameraComponent = nullptr; Cry::DefaultComponents::CCharacterControllerComponent* m_pCharacterController = nullptr; Cry::DefaultComponents::CAdvancedAnimationComponent* m_pAnimationComponent = nullptr; Cry::DefaultComponents::CInputComponent* m_pInputComponent = nullptr; CInventoryComponent* m_pInventoryComponent = nullptr; SItemComponent* m_pTargetItem = nullptr; FragmentID m_idleFragmentId; FragmentID m_walkFragmentId; TagID m_rotateTagId; TInputFlags m_inputFlags; Vec2 m_mouseDeltaRotation; MovingAverage<Vec2, 10> m_mouseDeltaSmoothingFilter; FragmentID m_activeFragmentId; Quat m_lookOrientation; //!< Should translate to head orientation in the future float m_horizontalAngularVelocity; MovingAverage<float, 10> m_averagedHorizontalAngularVelocity; };
23.944099
111
0.735149
[ "geometry" ]
630e2be5c231e1d06bd83fb9d8733c8775889e8f
691
h
C
src/gui/models/main_map_model.h
robhendriks/city-defence
6567222087fc74bf374423d4aab5512cbe86ac07
[ "MIT" ]
null
null
null
src/gui/models/main_map_model.h
robhendriks/city-defence
6567222087fc74bf374423d4aab5512cbe86ac07
[ "MIT" ]
null
null
null
src/gui/models/main_map_model.h
robhendriks/city-defence
6567222087fc74bf374423d4aab5512cbe86ac07
[ "MIT" ]
1
2022-03-29T02:01:56.000Z
2022-03-29T02:01:56.000Z
// // Created by robbie on 1-11-2016. // #ifndef CITY_DEFENCE_MAIN_MAP_MODEL_H #define CITY_DEFENCE_MAIN_MAP_MODEL_H #include <vector> #include <memory> #include "../../domain/gameworld/game_world.h" namespace gui { namespace models { struct main_map_model { domain::gameworld::game_world *world; bool paused = false; void reset() { if (world != nullptr) { delete world; world = nullptr; } paused = false; } ~main_map_model() { reset(); } }; } } #endif //CITY_DEFENCE_MAIN_MAP_MODEL_H
20.323529
49
0.513748
[ "vector" ]
4642a994469d1be58c3861f8bb2c3388e9c88002
2,507
h
C
vpc/include/huaweicloud/vpc/v2/model/SubnetIpAvailability.h
yangzhaofeng/huaweicloud-sdk-cpp-v3
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
[ "Apache-2.0" ]
5
2021-03-03T08:23:43.000Z
2022-02-16T02:16:39.000Z
vpc/include/huaweicloud/vpc/v2/model/SubnetIpAvailability.h
yangzhaofeng/huaweicloud-sdk-cpp-v3
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
[ "Apache-2.0" ]
null
null
null
vpc/include/huaweicloud/vpc/v2/model/SubnetIpAvailability.h
yangzhaofeng/huaweicloud-sdk-cpp-v3
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
[ "Apache-2.0" ]
7
2021-02-26T13:53:35.000Z
2022-03-18T02:36:43.000Z
#ifndef HUAWEICLOUD_SDK_VPC_V2_MODEL_SubnetIpAvailability_H_ #define HUAWEICLOUD_SDK_VPC_V2_MODEL_SubnetIpAvailability_H_ #include <huaweicloud/vpc/v2/VpcExport.h> #include <huaweicloud/core/utils/ModelBase.h> #include <huaweicloud/core/http/HttpResponse.h> #include <string> namespace HuaweiCloud { namespace Sdk { namespace Vpc { namespace V2 { namespace Model { using namespace HuaweiCloud::Sdk::Core::Utils; using namespace HuaweiCloud::Sdk::Core::Http; /// <summary> /// /// </summary> class HUAWEICLOUD_VPC_V2_EXPORT SubnetIpAvailability : public ModelBase { public: SubnetIpAvailability(); virtual ~SubnetIpAvailability(); ///////////////////////////////////////////// /// ModelBase overrides void validate() override; web::json::value toJson() const override; bool fromJson(const web::json::value& json) override; ///////////////////////////////////////////// /// SubnetIpAvailability members /// <summary> /// 子网中已经使用的IP数目(不包含系统预留地址) /// </summary> int32_t getUsedIps() const; bool usedIpsIsSet() const; void unsetusedIps(); void setUsedIps(int32_t value); /// <summary> /// 子网ID /// </summary> std::string getSubnetId() const; bool subnetIdIsSet() const; void unsetsubnetId(); void setSubnetId(const std::string& value); /// <summary> /// 子网名称 /// </summary> std::string getSubnetName() const; bool subnetNameIsSet() const; void unsetsubnetName(); void setSubnetName(const std::string& value); /// <summary> /// 子网的IP版本,取值为4或者6 /// </summary> int32_t getIpVersion() const; bool ipVersionIsSet() const; void unsetipVersion(); void setIpVersion(int32_t value); /// <summary> /// 子网的CIDR /// </summary> std::string getCidr() const; bool cidrIsSet() const; void unsetcidr(); void setCidr(const std::string& value); /// <summary> /// 子网中IP总数(不包含系统预留地址) /// </summary> int32_t getTotalIps() const; bool totalIpsIsSet() const; void unsettotalIps(); void setTotalIps(int32_t value); protected: int32_t usedIps_; bool usedIpsIsSet_; std::string subnetId_; bool subnetIdIsSet_; std::string subnetName_; bool subnetNameIsSet_; int32_t ipVersion_; bool ipVersionIsSet_; std::string cidr_; bool cidrIsSet_; int32_t totalIps_; bool totalIpsIsSet_; }; } } } } } #endif // HUAWEICLOUD_SDK_VPC_V2_MODEL_SubnetIpAvailability_H_
20.719008
62
0.647786
[ "model" ]
4646e6408aec711145d407aff0a48b38d5d5c384
2,648
h
C
src/alias_table.h
Jack2313/LightLDA
c7e362393a9b1612a2ca7e9c34cfcaa974bb2250
[ "MIT" ]
413
2016-10-22T07:01:00.000Z
2019-04-30T03:24:59.000Z
src/alias_table.h
Jack2313/LightLDA
c7e362393a9b1612a2ca7e9c34cfcaa974bb2250
[ "MIT" ]
46
2016-10-24T08:20:25.000Z
2019-04-19T07:38:17.000Z
src/alias_table.h
Jack2313/LightLDA
c7e362393a9b1612a2ca7e9c34cfcaa974bb2250
[ "MIT" ]
126
2016-10-25T14:35:47.000Z
2019-05-05T03:47:54.000Z
/*! * \file alias_table.h * \brief Defines alias table */ #ifndef LIGHTLDA_ALIAS_TABLE_H_ #define LIGHTLDA_ALIAS_TABLE_H_ #include <memory> #include <mutex> #include <vector> #if defined(_WIN32) || defined(_WIN64) // vs currently not support c++11 keyword thread_local #define _THREAD_LOCAL __declspec(thread) #else #define _THREAD_LOCAL thread_local #endif namespace multiverso { namespace lightlda { class ModelBase; class xorshift_rng; class AliasTableIndex; /*! * \brief AliasTable is the storage for alias tables used for fast sampling * from lightlda word proposal distribution. It optimize memory usage * through a hybrid storage by exploiting the sparsity of word proposal. * AliasTable containes two part: 1) a memory pool to store the alias * 2) an index table to access each row */ class AliasTable { public: AliasTable(); ~AliasTable(); /*! * \brief Set the table index. Must call this method before */ void Init(AliasTableIndex* table_index); /*! * \brief Build alias table for a word * \param word word to bulid * \param model access * \return success of not */ int Build(int word, ModelBase* model); /*! * \brief sample from word proposal distribution * \param word word to sample * \param rng random number generator * \return sample proposed from the distribution */ int Propose(int word, xorshift_rng& rng); /*! \brief Clear the alias table */ void Clear(); private: void AliasMultinomialRNG(int32_t size, float mass, int32_t& height, int32_t* kv_vector); int* memory_block_; int64_t memory_size_; AliasTableIndex* table_index_; std::vector<int32_t> height_; std::vector<float> mass_; int32_t beta_height_; float beta_mass_; int32_t* beta_kv_vector_; // thread local storage used for building alias _THREAD_LOCAL static std::vector<float>* q_w_proportion_; _THREAD_LOCAL static std::vector<int>* q_w_proportion_int_; _THREAD_LOCAL static std::vector<std::pair<int, int>>* L_; _THREAD_LOCAL static std::vector<std::pair<int, int>>* H_; int num_vocabs_; int num_topics_; float beta_; float beta_sum_; // No copying allowed AliasTable(const AliasTable&); void operator=(const AliasTable&); }; } // namespace lightlda } // namespace multiverso #endif // LIGHTLDA_ALIAS_TABLE_H_
29.422222
79
0.638595
[ "vector", "model" ]
465606ecc9e7e42865857f489784c1b4943c9a11
3,343
h
C
src/COLLADALoader.h
LeifNode/World-Generator
f9818fb6c5d507eede76141c2687a66f090cbdc1
[ "MIT" ]
16
2015-02-12T20:56:01.000Z
2021-05-31T21:05:41.000Z
src/COLLADALoader.h
LeifNode/World-Generator
f9818fb6c5d507eede76141c2687a66f090cbdc1
[ "MIT" ]
null
null
null
src/COLLADALoader.h
LeifNode/World-Generator
f9818fb6c5d507eede76141c2687a66f090cbdc1
[ "MIT" ]
3
2017-02-05T15:52:34.000Z
2018-02-09T08:51:00.000Z
//The MIT License (MIT) // //Copyright (c) 2014 Leif Erkenbrach // //Permission is hereby granted, free of charge, to any person obtaining a copy //of this software and associated documentation files (the "Software"), to deal //in the Software without restriction, including without limitation the rights //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell //copies of the Software, and to permit persons to whom the Software is //furnished to do so, subject to the following conditions: // //The above copyright notice and this permission notice shall be included in //all copies or substantial portions of the Software. // //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN //THE SOFTWARE. #pragma once #include "glStd.h" #include "Geometry.h" #include "COLLADATypes.h" #include <tinyxml2\tinyxml2.h> class COLLADALoader { public: COLLADALoader(const char* filePath); ~COLLADALoader(); void clear(); void loadDocument(); void parse(); const collada::Model* getModel(const std::string& id) const; const collada::Effect* getEffect(const std::string& id) const; collada::SceneNode* getRootNode() const { return mpRootNode; } std::map<std::string, collada::Model*>::const_iterator modelsBegin() const { return mModels.begin(); } std::map<std::string, collada::Model*>::const_iterator modelsEnd() const { return mModels.end(); } private: void loadAssetParameters(); void loadModels(); void loadEffects(); void loadMaterials(); void loadImages(); void loadSceneNodes(); void loadNode(collada::SceneNode* parent, tinyxml2::XMLElement* nodeElement); void loadNewParamElements(tinyxml2::XMLElement* profileElement, std::map<std::string, collada::Surface>& surfaceMap, std::map<std::string, collada::Sampler>& samplerMap); void readMeshSourceElement(tinyxml2::XMLElement* element, collada::MeshSource* storage); void readFloatArrayElement(tinyxml2::XMLElement* element, std::vector<float>& storage); void readIntArrayElement(tinyxml2::XMLElement* element, std::vector<int>& storage, int expectedSize = 0); void readColor(tinyxml2::XMLElement* element, vec4& out); void associateAccessors(tinyxml2::XMLElement* meshElement, collada::MeshAccessor* sourceArray); void constructModelGeometry(tinyxml2::XMLElement* geometryElement); int getInputIndexStride(tinyxml2::XMLElement* primitiveElement); std::string getExtensionFromPath(const char* path); void generateTangents(); private: collada::UpAxis mUpAxis; std::string mUnitScaleName; float mScalingFactor; //Corresponds to asset/unit/meter in collada spec collada::SceneNode* mpRootNode; std::map<std::string, collada::Model*> mModels; std::map<std::string, collada::Material> mMaterials; std::map<std::string, collada::Effect*> mEffects; std::map<std::string, collada::Image> mImages; std::string mFilePath; tinyxml2::XMLDocument mSceneDocument; std::map<std::string, collada::MeshSource*> mMeshSources; };
35.189474
171
0.763386
[ "geometry", "vector", "model" ]
465c8d167ea54ae5862e6c86a8506819573cf6ed
600,959
c
C
squeak2_2_c/interp.c
daitangio/jsqueak
64bf5fc36cd5d85d8aeabed19bddfdec3a97b292
[ "MIT" ]
3
2015-05-12T16:03:23.000Z
2021-04-01T10:31:17.000Z
squeak2_2_c/interp.c
daitangio/jsqueak
64bf5fc36cd5d85d8aeabed19bddfdec3a97b292
[ "MIT" ]
null
null
null
squeak2_2_c/interp.c
daitangio/jsqueak
64bf5fc36cd5d85d8aeabed19bddfdec3a97b292
[ "MIT" ]
1
2020-12-26T18:06:30.000Z
2020-12-26T18:06:30.000Z
/* Automatically generated from Squeak on (2 October 1998 6:43:42 pm ) */ #include "sq.h" #include "sqMachDep.h" /* needed only by the JIT virtual machine */ /* memory access macros */ #define byteAt(i) (*((unsigned char *) (i))) #define byteAtput(i, val) (*((unsigned char *) (i)) = val) #define longAt(i) (*((int *) (i))) #define longAtput(i, val) (*((int *) (i)) = val) int printCallStack(void); void error(char *s); void error(char *s) { /* Print an error message and exit. */ static int printingStack = false; printf("\n%s\n\n", s); if (!printingStack) { /* flag prevents recursive error when trying to print a broken stack */ printingStack = true; printCallStack(); } exit(-1); } /*** Variables ***/ int activeContext; int affectedB; int affectedL; int affectedR; int affectedT; int allocationCount; int allocationsBetweenGCs; int argumentCount; int bbH; int bbW; int bitBltOop; int bitCount; int checkAssertions; int child; int clipHeight; int clipWidth; int clipX; int clipY; int cmBitsPerColor; int colorMap; int combinationRule; int compEnd; int compStart; int deferDisplayUpdates; int destBits; int destDelta; int destForm; int destIndex; int destMask; int destPixSize; int destRaster; int destX; int destY; int displayBits; int dx; int dy; int endOfMemory; int falseObj; int field; int freeBlock; int freeLargeContexts; int freeSmallContexts; int fullScreenFlag; int fwdTableLast; int fwdTableNext; int hDir; int halftoneBase; int halftoneForm; int halftoneHeight; int height; int instructionPointer; int interpreterProxy; int interruptCheckCounter; int interruptKeycode; int interruptPending; int lastHash; int lastTick; int lowSpaceThreshold; int mask1; int mask2; int mcProbe; unsigned char *memory; int memoryLimit; int messageSelector; int method; int methodCache[2049]; int nWords; int newMethod; int nextPollTick; int nextWakeupTick; int nilObj; int noHalftone; int noSource; int opTable[35]; int parentField; int pixPerWord; int preload; int primitiveIndex; int receiver; int reclaimableContextCount; int remapBuffer[26]; int remapBufferCount; int rootTable[1001]; int rootTableCount; int savedWindowSize; int scanDisplayFlag; int scanRightX; int scanStart; int scanStop; int scanStopArray; int scanString; int scanXTable; int semaphoresToSignal[26]; int semaphoresToSignalCount; int signalLowSpace; int skew; int sourceAlpha; int sourceBits; int sourceDelta; int sourceForm; int sourceIndex; int sourcePixSize; int sourceRaster; int sourceX; int sourceY; int specialObjectsOop; int srcBitIndex; int srcHeight; int srcWidth; int stackPointer; int statFullGCMSecs; int statFullGCs; int statIncrGCMSecs; int statIncrGCs; int statRootTableOverflows; int statTenures; int stopCode; int successFlag; int sx; int sy; int tenuringThreshold; int theHomeContext; int trueObj; int vDir; int width; int youngStart; /*** Function Prototypes ***/ int OLDrgbDiffwith(int sourceWord, int destinationWord); int OLDtallyIntoMapwith(int sourceWord, int destinationWord); int aComment(void); int accessibleObjectAfter(int oop); int activateNewMethod(void); int addLastLinktoList(int proc, int aList); int addToMethodCacheSelclassmethodprimIndex(int selector, int class, int meth, int primIndex); int addWordwith(int sourceWord, int destinationWord); int adjustAllOopsBy(int bytesToShift); int adjustFieldsAndClassOfby(int oop, int offsetBytes); int affectedBottom(void); int affectedLeft(void); int affectedRight(void); int affectedTop(void); int allAccessibleObjectsOkay(void); int allYoungand(int array1, int array2); int allocateheaderSizeh1h2h3fill(int byteSize, int hdrSize, int baseHeader, int classOop, int extendedSize, int fillWord); int allocateChunk(int byteSize); int allocateOrRecycleContext(int smallContextWanted); int alphaBlendwith(int sourceWord, int destinationWord); int alphaBlendConstwith(int sourceWord, int destinationWord); int alphaBlendConstwithpaintMode(int sourceWord, int destinationWord, int paintMode); int alphaPaintConstwith(int sourceWord, int destinationWord); int areIntegersand(int oop1, int oop2); int argCount(void); int argumentCountOf(int methodPointer); int argumentCountOfBlock(int blockPointer); void * arrayValueOf(int arrayOop); int asciiDirectoryDelimiter(void); int asciiOfCharacter(int characterObj); int assertClassOfis(int oop, int classOop); int assertFloatand(int oop1, int oop2); AsyncFile * asyncFileValueOf(int oop); int baseHeader(int oop); int beRootIfOld(int oop); int beRootWhileForwarding(int oop); int becomewith(int array1, int array2); int bitAndwith(int sourceWord, int destinationWord); int bitAndInvertwith(int sourceWord, int destinationWord); int bitInvertAndwith(int sourceWord, int destinationWord); int bitInvertAndInvertwith(int sourceWord, int destinationWord); int bitInvertDestinationwith(int sourceWord, int destinationWord); int bitInvertOrwith(int sourceWord, int destinationWord); int bitInvertOrInvertwith(int sourceWord, int destinationWord); int bitInvertSourcewith(int sourceWord, int destinationWord); int bitInvertXorwith(int sourceWord, int destinationWord); int bitOrwith(int sourceWord, int destinationWord); int bitOrInvertwith(int sourceWord, int destinationWord); int bitXorwith(int sourceWord, int destinationWord); int booleanValueOf(int obj); int byteLengthOf(int oop); int byteSwapByteObjects(void); int byteSwapped(int w); int caller(void); int characterForAscii(int integerObj); int checkAddress(int byteAddress); int checkBooleanResultfrom(int result, int primIndex); int checkForInterrupts(void); int checkImageVersionFrom(sqImageFile f); int checkIntegerResultfrom(int integerResult, int primIndex); int checkSourceOverlap(void); int checkedByteAt(int byteAddress); int checkedByteAtput(int byteAddress, int byte); int checkedIntegerValueOf(int intOop); int checkedLongAt(int byteAddress); int checkedLongAtput(int byteAddress, int a32BitInteger); int chunkFromOop(int oop); int classHeader(int oop); int clearRootsTable(void); int clearWordwith(int source, int destination); int clipRange(void); int clone(int oop); int commonAt(int stringy); int commonAtPut(int stringy); int compare31or32Bitsequal(int obj1, int obj2); int containOnlyOopsand(int array1, int array2); int copyBits(void); int copyLoop(void); int copyLoopNoSource(void); int copyLoopPixMap(void); int cr(void); int createActualMessage(void); int deltaFromtonSteps(int x1, int x2, int n); int destMaskAndPointerInit(void); int destinationWordwith(int sourceWord, int destinationWord); int drawLoopXY(int xDelta, int yDelta); int exchangeHashBitswith(int oop1, int oop2); int executeNewMethod(void); int extraHeaderBytes(int oopOrChunk); int failSpecialPrim(int primIndex); int failed(void); void * fetchArrayofObject(int fieldIndex, int objectPointer); int fetchByteofObject(int byteIndex, int oop); int fetchClassOf(int oop); int fetchContextRegisters(int activeCntx); double fetchFloatofObject(int fieldIndex, int objectPointer); int fetchIntegerofObject(int fieldIndex, int objectPointer); int fetchIntegerOrTruncFloatofObject(int fieldIndex, int objectPointer); int fetchPointerofObject(int fieldIndex, int oop); int fetchWordofObject(int fieldIndex, int oop); int fetchWordLengthOf(int objectPointer); int fileRecordSize(void); SQFile * fileValueOf(int objectPointer); int findClassOfMethodforReceiver(int meth, int rcvr); int findNewMethodInClass(int class); int findSelectorOfMethodforReceiver(int meth, int rcvr); int firstAccessibleObject(void); int firstObject(void); int fixedFieldsOfformatlength(int oop, int fmt, int wordLength); double floatValueOf(int oop); int flushMethodCache(void); int formatOf(int oop); int formatOfClass(int classPointer); int fullCompaction(void); int fullDisplayUpdate(void); int fullGC(void); int fwdBlockGet(void); int fwdBlockValidate(int addr); int fwdTableInit(void); int getCurrentBytecode(void); int getLongFromFileswap(sqImageFile f, int swapFlag); int hashBitsOf(int oop); int headerOf(int methodPointer); int headerType(int oop); int ignoreSourceOrHalftone(int formPointer); int imageFormatVersion(void); int incCompBody(void); int incCompMakeFwd(void); int incCompMove(int bytesFreed); int incrementalCompaction(void); int incrementalGC(void); int initBBOpTable(void); int initForwardBlockmappingto(int fwdBlock, int oop, int newOop); int initialInstanceOf(int classPointer); int initializeInterpreter(int bytesToShift); int initializeMemoryFirstFree(int firstFree); int initializeObjectMemory(int bytesToShift); int instanceAfter(int objectPointer); int instantiateClassindexableSize(int classPointer, int size); int instantiateSmallClasssizeInBytesfill(int classPointer, int sizeInBytes, int fillValue); int intToNetAddress(int addr); int integerObjectOf(int value); int integerValueOf(int objectPointer); int interpret(void); int isBytes(int oop); int isEmptyList(int aLinkedList); int isFreeObject(int oop); int isIntegerObject(int objectPointer); int isIntegerValue(int intValue); int isObjectForwarded(int oop); int isPointers(int oop); int isWords(int oop); int isWordsOrBytes(int oop); int lastPointerOf(int objectPointer); int lastPointerWhileForwarding(int oop); int lengthOf(int oop); int lengthOfbaseHeaderformat(int oop, int hdr, int fmt); int literal(int offset); int literalofMethod(int offset, int methodPointer); int literalCountOf(int methodPointer); int literalCountOfHeader(int headerPointer); int loadBitBltFrom(int bbObj); int loadInitialContext(void); int loadScannerFromstartstopstringrightXstopArraydisplayFlag(int bbObj, int start, int stop, int string, int rightX, int stopArray, int displayFlag); int lookupInMethodCacheSelclass(int selector, int class); int lookupMethodInClass(int class); int lookupMethodInDictionary(int dictionary); int lowestFreeAfter(int chunk); int makeDirEntryNamesizecreateDatemodDateisDirfileSize(char *entryName, int entryNameSize, int createDate, int modifiedDate, int dirFlag, int fileSize); int makePointwithxValueyValue(int xValue, int yValue); int mapInterpreterOops(void); int mapPointersInObjectsFromto(int memStart, int memEnd); int markAndTrace(int oop); int markAndTraceInterpreterOops(void); int markPhase(void); int mergewith(int sourceWord, int destinationWord); int methodClassOf(int methodPointer); int netAddressToInt(int oop); int newActiveContext(int aContext); int newObjectHash(void); int nilObject(void); int objectAfter(int oop); int objectAfterWhileForwarding(int oop); int okArrayClass(int cl); int okStreamArrayClass(int cl); int okayActiveProcessStack(void); int okayFields(int oop); int okayInterpreterObjects(void); int okayOop(int oop); int oopFromChunk(int chunk); int oopHasOkayClass(int oop); int partitionedANDtonBitsnPartitions(int word1, int word2, int nBits, int nParts); int partitionedAddtonBitsnPartitions(int word1, int word2, int nBits, int nParts); int partitionedMaxwithnBitsnPartitions(int word1, int word2, int nBits, int nParts); int partitionedMinwithnBitsnPartitions(int word1, int word2, int nBits, int nParts); int partitionedSubfromnBitsnPartitions(int word1, int word2, int nBits, int nParts); int pickSourcePixelsnullMapsrcMaskdestMask(int nPix, int nullMap, int sourcePixMask, int destPixMask); int pickSourcePixelssrcMaskdestMask(int nPix, int sourcePixMask, int destPixMask); int pickSourcePixelsNullMapsrcMaskdestMask(int nPix, int sourcePixMask, int destPixMask); int pickSourcePixelsRGBnullMapsrcMaskdestMask(int nPix, int nullMap, int sourcePixMask, int destPixMask); int pixMaskwith(int sourceWord, int destinationWord); int pixPaintwith(int sourceWord, int destinationWord); int pop(int nItems); int popthenPush(int nItems, int oop); double popFloat(void); int popInteger(void); int popPos32BitInteger(void); int popRemappableOop(void); int popStack(void); int positive32BitIntegerFor(int integerValue); int positive32BitValueOf(int oop); int possibleRootStoreIntovalue(int oop, int valueObj); int postGCAction(void); int preGCAction(int fullGCFlag); int prepareForwardingTableForBecomingwith(int array1, int array2); int primIndex(void); int primitiveAdd(void); int primitiveArctan(void); int primitiveArrayBecome(void); int primitiveAsFloat(void); int primitiveAsOop(void); int primitiveAsyncFileClose(void); int primitiveAsyncFileOpen(void); int primitiveAsyncFileReadResult(void); int primitiveAsyncFileReadStart(void); int primitiveAsyncFileWriteResult(void); int primitiveAsyncFileWriteStart(void); int primitiveAt(void); int primitiveAtEnd(void); int primitiveAtPut(void); int primitiveBeCursor(void); int primitiveBeDisplay(void); int primitiveBeep(void); int primitiveBitAnd(void); int primitiveBitOr(void); int primitiveBitShift(void); int primitiveBitXor(void); int primitiveBlockCopy(void); int primitiveBytesLeft(void); int primitiveClass(void); int primitiveClipboardText(void); int primitiveClone(void); int primitiveConstantFill(void); int primitiveCopyBits(void); int primitiveDeferDisplayUpdates(void); int primitiveDirectoryCreate(void); int primitiveDirectoryDelimitor(void); int primitiveDirectoryLookup(void); int primitiveDirectorySetMacTypeAndCreator(void); int primitiveDiv(void); int primitiveDivide(void); int primitiveDoPrimitiveWithArgs(void); int primitiveDrawLoop(void); int primitiveEqual(void); int primitiveEquivalent(void); int primitiveExitToDebugger(void); int primitiveExp(void); int primitiveExponent(void); int primitiveFail(void); int primitiveFileAtEnd(void); int primitiveFileClose(void); int primitiveFileDelete(void); int primitiveFileGetPosition(void); int primitiveFileOpen(void); int primitiveFileRead(void); int primitiveFileRename(void); int primitiveFileSetPosition(void); int primitiveFileSize(void); int primitiveFileWrite(void); int primitiveFloatAdd(void); int primitiveFloatDivide(void); int primitiveFloatEqual(void); int primitiveFloatGreaterOrEqual(void); int primitiveFloatGreaterThan(void); int primitiveFloatLessOrEqual(void); int primitiveFloatLessThan(void); int primitiveFloatMultiply(void); int primitiveFloatNotEqual(void); int primitiveFloatSubtract(void); int primitiveFlushCache(void); int primitiveFlushCacheSelective(void); int primitiveForceDisplayUpdate(void); int primitiveFormPrint(void); int primitiveFractionalPart(void); int primitiveFullGC(void); int primitiveGetAttribute(void); int primitiveGreaterOrEqual(void); int primitiveGreaterThan(void); int primitiveImageName(void); int primitiveIncrementalGC(void); int primitiveIndexOf(int methodPointer); int primitiveInitializeNetwork(void); int primitiveInputSemaphore(void); int primitiveInputWord(void); int primitiveInstVarAt(void); int primitiveInstVarAtPut(void); int primitiveInterruptSemaphore(void); int primitiveKbdNext(void); int primitiveKbdPeek(void); int primitiveLessOrEqual(void); int primitiveLessThan(void); int primitiveLoadInstVar(void); int primitiveLogN(void); int primitiveLowSpaceSemaphore(void); int primitiveMIDIClosePort(void); int primitiveMIDIGetClock(void); int primitiveMIDIGetPortCount(void); int primitiveMIDIGetPortDirectionality(void); int primitiveMIDIGetPortName(void); int primitiveMIDIOpenPort(void); int primitiveMIDIParameterGetOrSet(void); int primitiveMIDIRead(void); int primitiveMIDIWrite(void); int primitiveMakePoint(void); int primitiveMillisecondClock(void); int primitiveMod(void); int primitiveMouseButtons(void); int primitiveMousePoint(void); int primitiveMultiply(void); int primitiveNew(void); int primitiveNewMethod(void); int primitiveNewWithArg(void); int primitiveNext(void); int primitiveNextInstance(void); int primitiveNextObject(void); int primitiveNextPut(void); int primitiveNoop(void); int primitiveNotEqual(void); int primitiveObjectAt(void); int primitiveObjectAtPut(void); int primitiveObjectPointsTo(void); int primitivePerform(void); int primitivePerformWithArgs(void); int primitivePointX(void); int primitivePointY(void); int primitivePushFalse(void); int primitivePushMinusOne(void); int primitivePushNil(void); int primitivePushOne(void); int primitivePushSelf(void); int primitivePushTrue(void); int primitivePushTwo(void); int primitivePushZero(void); int primitiveQuit(void); int primitiveQuo(void); int primitiveReadJoystick(void); int primitiveRelinquishProcessor(void); int primitiveResolverAbortLookup(void); int primitiveResolverAddressLookupResult(void); int primitiveResolverError(void); int primitiveResolverLocalAddress(void); int primitiveResolverNameLookupResult(void); int primitiveResolverStartAddressLookup(void); int primitiveResolverStartNameLookup(void); int primitiveResolverStatus(void); int primitiveResponse(void); int primitiveResume(void); int primitiveScanCharacters(void); int primitiveScreenSize(void); int primitiveSecondsClock(void); int primitiveSerialPortClose(void); int primitiveSerialPortOpen(void); int primitiveSerialPortRead(void); int primitiveSerialPortWrite(void); int primitiveSetFullScreen(void); int primitiveSetInterruptKey(void); int primitiveShortAt(void); int primitiveShortAtPut(void); int primitiveShowDisplayRect(void); int primitiveSignal(void); int primitiveSignalAtBytesLeft(void); int primitiveSignalAtMilliseconds(void); int primitiveSine(void); int primitiveSize(void); int primitiveSnapshot(void); int primitiveSocketAbortConnection(void); int primitiveSocketCloseConnection(void); int primitiveSocketConnectToPort(void); int primitiveSocketConnectionStatus(void); int primitiveSocketCreate(void); int primitiveSocketDestroy(void); int primitiveSocketError(void); int primitiveSocketListenOnPort(void); int primitiveSocketLocalAddress(void); int primitiveSocketLocalPort(void); int primitiveSocketReceiveDataAvailable(void); int primitiveSocketReceiveDataBufCount(void); int primitiveSocketRemoteAddress(void); int primitiveSocketRemotePort(void); int primitiveSocketSendDataBufCount(void); int primitiveSocketSendDone(void); int primitiveSomeInstance(void); int primitiveSomeObject(void); int primitiveSoundAvailableSpace(void); int primitiveSoundGetRecordingSampleRate(void); int primitiveSoundInsertSamples(void); int primitiveSoundPlaySamples(void); int primitiveSoundPlaySilence(void); int primitiveSoundRecordSamples(void); int primitiveSoundSetRecordLevel(void); int primitiveSoundStart(void); int primitiveSoundStartRecording(void); int primitiveSoundStartWithSemaphore(void); int primitiveSoundStop(void); int primitiveSoundStopRecording(void); int primitiveSpecialObjectsOop(void); int primitiveSquareRoot(void); int primitiveStringAt(void); int primitiveStringAtPut(void); int primitiveStringReplace(void); int primitiveSubtract(void); int primitiveSuspend(void); int primitiveTimesTwoPower(void); int primitiveTruncated(void); int primitiveVMParameter(void); int primitiveVMPath(void); int primitiveValue(void); int primitiveValueWithArgs(void); int primitiveWait(void); int primitiveWarpBits(void); int print(char *s); int printCallStack(void); int printChar(int aByte); int printNameOfClasscount(int classOop, int cnt); int printNum(int n); int printStringOf(int oop); int push(int object); int pushBool(int trueOrFalse); int pushFloat(double f); int pushInteger(int integerValue); int pushRemappableOop(int oop); int putLongtoFile(int n, sqImageFile f); int putToSleep(int aProcess); int quickCheckForInterrupts(void); int quickFetchIntegerofObject(int fieldIndex, int objectPointer); int readImageFromFileHeapSize(sqImageFile f, int desiredHeapSize); int recycleContextIfPossiblemethodContextClass(int cntxOop, int methodCntxClass); int remap(int oop); int remapClassOf(int oop); int remapFieldsAndClassOf(int oop); int removeFirstLinkOfList(int aList); int reportContexts(void); int restoreHeaderOf(int oop); int restoreHeadersAfterBecomingwith(int list1, int list2); int resume(int aProcess); int returnAtlastIndexlefttop(int stopIndex, int lastIndex, int left, int top); int reverseBytesFromto(int startAddr, int stopAddr); int reverseBytesInImage(void); int rgbAddwith(int sourceWord, int destinationWord); int rgbDiffwith(int sourceWord, int destinationWord); int rgbMapfromto(int sourcePixel, int nBitsIn, int nBitsOut); int rgbMaxwith(int sourceWord, int destinationWord); int rgbMinwith(int sourceWord, int destinationWord); int rgbMinInvertwith(int wordToInvert, int destinationWord); int rgbSubwith(int sourceWord, int destinationWord); int rightType(int headerWord); int scanCharacters(void); int schedulerPointer(void); int sendSelectorToClass(int classPointer); int sender(void); int setInterpreter(int anInterpreter); int setSizeOfFreeto(int chunk, int byteSize); int showDisplayBits(void); int signExtend16(int int16); int signalSemaphoreWithIndex(int index); int sizeBitsOf(int oop); int sizeBitsOfSafe(int oop); int sizeHeader(int oop); int sizeOfFree(int oop); int sizeOfSTArrayFromCPrimitive(void *cPtr); int smoothPixatXfyfdxhdyhdxvdyvpixPerWordpixelMasksourceMap(int n, int xf, int yf, int dxh, int dyh, int dxv, int dyv, int srcPixPerWord, int sourcePixMask, int sourceMap); int socketRecordSize(void); SQSocket * socketValueOf(int socketOop); int sourcePixAtXypixPerWord(int x, int y, int srcPixPerWord); int sourceSkewAndPointerInit(void); int sourceWordwith(int sourceWord, int destinationWord); int specialSelector(int index); int splObj(int index); int stObjectat(int array, int index); int stObjectatput(int array, int index, int value); int stSizeOf(int oop); int stackIntegerValue(int offset); int stackObjectValue(int offset); int stackPointerIndex(void); int stackTop(void); int stackValue(int offset); int startField(void); int startObj(void); int startOfMemory(void); int stopReason(void); int storeByteofObjectwithValue(int byteIndex, int oop, int valueByte); int storeContextRegisters(int activeCntx); int storeInstructionPointerValueinContext(int value, int contextPointer); int storeIntegerofObjectwithValue(int fieldIndex, int objectPointer, int integerValue); int storePointerofObjectwithValue(int fieldIndex, int oop, int valuePointer); int storePointerUncheckedofObjectwithValue(int fieldIndex, int oop, int valuePointer); int storeStackPointerValueinContext(int value, int contextPointer); int storeWordofObjectwithValue(int fieldIndex, int oop, int valueWord); int subWordwith(int sourceWord, int destinationWord); int subscriptwithformat(int array, int index, int fmt); int subscriptwithstoringformat(int array, int index, int oopToStore, int fmt); int success(int successValue); int sufficientSpaceAfterGC(int minFree); int sufficientSpaceToAllocate(int bytes); int sufficientSpaceToInstantiateindexableSize(int classOop, int size); int superclassOf(int classPointer); int sweepPhase(void); int synchronousSignal(int aSemaphore); int tallyIntoMapwith(int sourceWord, int destinationWord); int targetForm(void); int temporary(int offset); int transferfromIndexofObjecttoIndexofObject(int count, int firstFrom, int fromOop, int firstTo, int toOop); int transferTo(int newProc); int unPop(int nItems); int unknownBytecode(void); int upward(void); int wakeHighestPriority(void); int warpBits(void); int warpLoop(void); int warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(int nPix, int xDeltah, int yDeltah, int xDeltav, int yDeltav, int n, int sourceMapOop); int writeImageFile(int imageBytes); int OLDrgbDiffwith(int sourceWord, int destinationWord) { int diff; int pixMask; if (destPixSize < 16) { diff = sourceWord ^ destinationWord; pixMask = (((destPixSize < 0) ? ((unsigned) 1 >> -destPixSize) : ((unsigned) 1 << destPixSize))) - 1; while (!(diff == 0)) { if ((diff & pixMask) != 0) { bitCount += 1; } diff = ((unsigned) diff) >> destPixSize; } return destinationWord; } if (destPixSize == 16) { diff = partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 5, 3); bitCount = ((bitCount + (diff & 31)) + ((((unsigned) diff) >> 5) & 31)) + ((((unsigned) diff) >> 10) & 31); diff = partitionedSubfromnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3); bitCount = ((bitCount + (diff & 31)) + ((((unsigned) diff) >> 5) & 31)) + ((((unsigned) diff) >> 10) & 31); } else { diff = partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 8, 3); bitCount = ((bitCount + (diff & 255)) + ((((unsigned) diff) >> 8) & 255)) + ((((unsigned) diff) >> 16) & 255); } return destinationWord; } int OLDtallyIntoMapwith(int sourceWord, int destinationWord) { int mapIndex; int pixMask; int shiftWord; int i; int mask; int srcPix; int destPix; int d; int mask3; int srcPix1; int destPix1; int d1; int mask4; int srcPix2; int destPix2; int d2; if (colorMap == nilObj) { return destinationWord; } if (destPixSize < 16) { pixMask = (1 << destPixSize) - 1; shiftWord = destinationWord; for (i = 1; i <= pixPerWord; i += 1) { mapIndex = shiftWord & pixMask; longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); shiftWord = ((unsigned) shiftWord) >> destPixSize; } return destinationWord; } if (destPixSize == 16) { /* begin rgbMap:from:to: */ if ((d = cmBitsPerColor - 5) > 0) { mask = (1 << 5) - 1; srcPix = (destinationWord & 65535) << d; mask = mask << d; destPix = srcPix & mask; mask = mask << cmBitsPerColor; srcPix = srcPix << d; mapIndex = (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << cmBitsPerColor)); goto l1; } else { if (d == 0) { mapIndex = destinationWord & 65535; goto l1; } if ((destinationWord & 65535) == 0) { mapIndex = destinationWord & 65535; goto l1; } d = 5 - cmBitsPerColor; mask = (1 << cmBitsPerColor) - 1; srcPix = ((unsigned) (destinationWord & 65535)) >> d; destPix = srcPix & mask; mask = mask << cmBitsPerColor; srcPix = ((unsigned) srcPix) >> d; destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << cmBitsPerColor)); if (destPix == 0) { mapIndex = 1; goto l1; } mapIndex = destPix; goto l1; } l1: /* end rgbMap:from:to: */; longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); /* begin rgbMap:from:to: */ if ((d1 = cmBitsPerColor - 5) > 0) { mask3 = (1 << 5) - 1; srcPix1 = (((unsigned) destinationWord) >> 16) << d1; mask3 = mask3 << d1; destPix1 = srcPix1 & mask3; mask3 = mask3 << cmBitsPerColor; srcPix1 = srcPix1 << d1; mapIndex = (destPix1 + (srcPix1 & mask3)) + ((srcPix1 << d1) & (mask3 << cmBitsPerColor)); goto l2; } else { if (d1 == 0) { mapIndex = ((unsigned) destinationWord) >> 16; goto l2; } if ((((unsigned) destinationWord) >> 16) == 0) { mapIndex = ((unsigned) destinationWord) >> 16; goto l2; } d1 = 5 - cmBitsPerColor; mask3 = (1 << cmBitsPerColor) - 1; srcPix1 = ((unsigned) (((unsigned) destinationWord) >> 16)) >> d1; destPix1 = srcPix1 & mask3; mask3 = mask3 << cmBitsPerColor; srcPix1 = ((unsigned) srcPix1) >> d1; destPix1 = (destPix1 + (srcPix1 & mask3)) + ((((unsigned) srcPix1) >> d1) & (mask3 << cmBitsPerColor)); if (destPix1 == 0) { mapIndex = 1; goto l2; } mapIndex = destPix1; goto l2; } l2: /* end rgbMap:from:to: */; longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); } else { /* begin rgbMap:from:to: */ if ((d2 = cmBitsPerColor - 8) > 0) { mask4 = (1 << 8) - 1; srcPix2 = destinationWord << d2; mask4 = mask4 << d2; destPix2 = srcPix2 & mask4; mask4 = mask4 << cmBitsPerColor; srcPix2 = srcPix2 << d2; mapIndex = (destPix2 + (srcPix2 & mask4)) + ((srcPix2 << d2) & (mask4 << cmBitsPerColor)); goto l3; } else { if (d2 == 0) { mapIndex = destinationWord; goto l3; } if (destinationWord == 0) { mapIndex = destinationWord; goto l3; } d2 = 8 - cmBitsPerColor; mask4 = (1 << cmBitsPerColor) - 1; srcPix2 = ((unsigned) destinationWord) >> d2; destPix2 = srcPix2 & mask4; mask4 = mask4 << cmBitsPerColor; srcPix2 = ((unsigned) srcPix2) >> d2; destPix2 = (destPix2 + (srcPix2 & mask4)) + ((((unsigned) srcPix2) >> d2) & (mask4 << cmBitsPerColor)); if (destPix2 == 0) { mapIndex = 1; goto l3; } mapIndex = destPix2; goto l3; } l3: /* end rgbMap:from:to: */; longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); } return destinationWord; } int aComment(void) { } int accessibleObjectAfter(int oop) { int obj; int sz; int header; int extra; int type; int extra1; int sz1; int header1; int extra2; int type1; int extra11; /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz1 = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header1 = longAt(oop); if ((header1 & 3) == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; goto l2; } else { sz1 = header1 & 252; goto l2; } l2: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(oop + sz1)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; obj = (oop + sz1) + extra2; while (obj < endOfMemory) { if (!(((longAt(obj)) & 3) == 2)) { return obj; } /* begin objectAfter: */ if (checkAssertions) { if (obj >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(obj)) & 3) == 2) { sz = (longAt(obj)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(obj); if ((header & 3) == 0) { sz = (longAt(obj - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type = (longAt(obj + sz)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; obj = (obj + sz) + extra; } return null; } int activateNewMethod(void) { int methodHeader; int smallContext; char * toIndex; int nilOop; int tempCount; int newContext; int initialIP; char * fromIndex; char * lastIndex; int cntxt; int tmp; methodHeader = longAt(((((char *) newMethod)) + 4) + (0 << 2)); smallContext = ((((unsigned) methodHeader) >> 18) & 1) == 0; /* begin allocateOrRecycleContext: */ if (smallContext) { if (freeSmallContexts != 1) { cntxt = freeSmallContexts; freeSmallContexts = longAt(((((char *) cntxt)) + 4) + (0 << 2)); } else { cntxt = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)), 76, nilObj); } } else { if (freeLargeContexts != 1) { cntxt = freeLargeContexts; freeLargeContexts = longAt(((((char *) cntxt)) + 4) + (0 << 2)); } else { cntxt = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)), 156, nilObj); } } newContext = cntxt; initialIP = ((1 + ((((unsigned) methodHeader) >> 10) & 255)) * 4) + 1; tempCount = (((unsigned) methodHeader) >> 19) & 63; longAtput(((((char *) newContext)) + 4) + (0 << 2), activeContext); longAtput(((((char *) newContext)) + 4) + (1 << 2), ((initialIP << 1) | 1)); longAtput(((((char *) newContext)) + 4) + (2 << 2), ((tempCount << 1) | 1)); longAtput(((((char *) newContext)) + 4) + (3 << 2), newMethod); fromIndex = (((char *) activeContext)) + (((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - argumentCount) * 4); toIndex = (((char *) newContext)) + (5 * 4); lastIndex = fromIndex + ((argumentCount + 1) * 4); while (fromIndex < lastIndex) { fromIndex += 4; toIndex += 4; longAtput(toIndex, longAt(fromIndex)); } nilOop = nilObj; if (smallContext) { lastIndex = ((((char *) newContext)) + 76) - 4; } else { lastIndex = ((((char *) newContext)) + 156) - 4; } while (toIndex < lastIndex) { toIndex += 4; longAtput(toIndex, nilOop); } /* begin pop: */ stackPointer -= (argumentCount + 1) * 4; reclaimableContextCount += 1; /* begin newActiveContext: */ /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); if (newContext < youngStart) { beRootIfOld(newContext); } activeContext = newContext; /* begin fetchContextRegisters: */ tmp = longAt(((((char *) newContext)) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) newContext)) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = newContext; } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) newContext)) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) newContext)) + 4) + (2 << 2))) >> 1); stackPointer = (newContext + 4) + (((6 + tmp) - 1) * 4); } int addLastLinktoList(int proc, int aList) { int lastLink; if ((longAt(((((char *) aList)) + 4) + (0 << 2))) == nilObj) { /* begin storePointer:ofObject:withValue: */ if (aList < youngStart) { possibleRootStoreIntovalue(aList, proc); } longAtput(((((char *) aList)) + 4) + (0 << 2), proc); } else { lastLink = longAt(((((char *) aList)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ if (lastLink < youngStart) { possibleRootStoreIntovalue(lastLink, proc); } longAtput(((((char *) lastLink)) + 4) + (0 << 2), proc); } /* begin storePointer:ofObject:withValue: */ if (aList < youngStart) { possibleRootStoreIntovalue(aList, proc); } longAtput(((((char *) aList)) + 4) + (1 << 2), proc); /* begin storePointer:ofObject:withValue: */ if (proc < youngStart) { possibleRootStoreIntovalue(proc, aList); } longAtput(((((char *) proc)) + 4) + (3 << 2), aList); } int addToMethodCacheSelclassmethodprimIndex(int selector, int class, int meth, int primIndex) { int probe; mcProbe = (mcProbe + 1) % 3; probe = ((((unsigned) (selector ^ class)) >> (mcProbe + 2)) & 511) + 1; methodCache[probe] = selector; methodCache[probe + 512] = class; methodCache[probe + (512 * 2)] = meth; methodCache[probe + (512 * 3)] = primIndex; } int addWordwith(int sourceWord, int destinationWord) { return sourceWord + destinationWord; } int adjustAllOopsBy(int bytesToShift) { int oop; int last; int newClassOop; int fieldAddr; int fieldOop; int classHeader; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; if (bytesToShift == 0) { return null; } /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; oop = chunk + extra; while (oop < endOfMemory) { if (!(((longAt(oop)) & 3) == 2)) { /* begin adjustFieldsAndClassOf:by: */ fieldAddr = oop + (lastPointerOf(oop)); while (fieldAddr > oop) { fieldOop = longAt(fieldAddr); if (!((fieldOop & 1))) { longAtput(fieldAddr, fieldOop + bytesToShift); } fieldAddr -= 4; } if (((longAt(oop)) & 3) != 3) { classHeader = longAt(oop - 4); newClassOop = (classHeader & 4294967292U) + bytesToShift; longAtput(oop - 4, newClassOop | (classHeader & 3)); } } last = oop; /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(oop + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = (oop + sz) + extra2; } } int adjustFieldsAndClassOfby(int oop, int offsetBytes) { int newClassOop; int fieldAddr; int fieldOop; int classHeader; fieldAddr = oop + (lastPointerOf(oop)); while (fieldAddr > oop) { fieldOop = longAt(fieldAddr); if (!((fieldOop & 1))) { longAtput(fieldAddr, fieldOop + offsetBytes); } fieldAddr -= 4; } if (((longAt(oop)) & 3) != 3) { classHeader = longAt(oop - 4); newClassOop = (classHeader & 4294967292U) + offsetBytes; longAtput(oop - 4, newClassOop | (classHeader & 3)); } } int affectedBottom(void) { return affectedB; } int affectedLeft(void) { return affectedL; } int affectedRight(void) { return affectedR; } int affectedTop(void) { return affectedT; } int allAccessibleObjectsOkay(void) { int oop; int obj; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; /* begin firstAccessibleObject */ /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; obj = chunk + extra; while (obj < endOfMemory) { if (!(((longAt(obj)) & 3) == 2)) { oop = obj; goto l2; } /* begin objectAfter: */ if (checkAssertions) { if (obj >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(obj)) & 3) == 2) { sz = (longAt(obj)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(obj); if ((header & 3) == 0) { sz = (longAt(obj - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(obj + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; obj = (obj + sz) + extra2; } error("heap is empty"); l2: /* end firstAccessibleObject */; while (!(oop == null)) { okayFields(oop); oop = accessibleObjectAfter(oop); } } int allYoungand(int array1, int array2) { int fieldOffset; int methodHeader; int sz; int fmt; int header; int type; if (array1 < youngStart) { return false; } if (array2 < youngStart) { return false; } /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(array1))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header = longAt(array1); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l2; } else { if ((header & 126976) == 0) { type = 1; goto l2; } else { type = 3; goto l2; } } l2: /* end rightType: */; if (type == 0) { sz = (longAt(array1 - 8)) & 4294967292U; goto l3; } else { sz = header & 252; goto l3; } l3: /* end sizeBitsOfSafe: */; fieldOffset = sz - 4; goto l1; } if (fmt < 12) { fieldOffset = 0; goto l1; } methodHeader = longAt(array1 + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerOf: */; while (fieldOffset >= 4) { if ((longAt(array1 + fieldOffset)) < youngStart) { return false; } if ((longAt(array2 + fieldOffset)) < youngStart) { return false; } fieldOffset -= 4; } return true; } int allocateheaderSizeh1h2h3fill(int byteSize, int hdrSize, int baseHeader, int classOop, int extendedSize, int fillWord) { int i; int newObj; int remappedClassOop; int end; int oop; int newFreeSize; int enoughSpace; int newChunk; int minFree; if (hdrSize > 1) { /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = classOop; } /* begin allocateChunk: */ if (allocationCount >= allocationsBetweenGCs) { incrementalGC(); } /* begin sufficientSpaceToAllocate: */ minFree = (lowSpaceThreshold + (byteSize + ((hdrSize - 1) * 4))) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { enoughSpace = true; goto l1; } else { enoughSpace = sufficientSpaceAfterGC(minFree); goto l1; } l1: /* end sufficientSpaceToAllocate: */; if (!(enoughSpace)) { signalLowSpace = true; lowSpaceThreshold = 0; interruptCheckCounter = 0; } if (((longAt(freeBlock)) & 536870908) < ((byteSize + ((hdrSize - 1) * 4)) + 4)) { error("out of memory"); } newFreeSize = ((longAt(freeBlock)) & 536870908) - (byteSize + ((hdrSize - 1) * 4)); newChunk = freeBlock; freeBlock += byteSize + ((hdrSize - 1) * 4); /* begin setSizeOfFree:to: */ longAtput(freeBlock, (newFreeSize & 536870908) | 2); allocationCount += 1; newObj = newChunk; if (hdrSize > 1) { /* begin popRemappableOop */ oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; remappedClassOop = oop; } if (hdrSize == 3) { longAtput(newObj, extendedSize | 0); longAtput(newObj + 4, remappedClassOop | 0); longAtput(newObj + 8, baseHeader | 0); newObj += 8; } if (hdrSize == 2) { longAtput(newObj, remappedClassOop | 1); longAtput(newObj + 4, baseHeader | 1); newObj += 4; } if (hdrSize == 1) { longAtput(newObj, baseHeader | 3); } end = newObj + byteSize; i = newObj + 4; while (i < end) { longAtput(i, fillWord); i += 4; } if (checkAssertions) { okayOop(newObj); oopHasOkayClass(newObj); if (!((objectAfter(newObj)) == freeBlock)) { error("allocate bug: did not set header of new oop correctly"); } if (!((objectAfter(freeBlock)) == endOfMemory)) { error("allocate bug: did not set header of freeBlock correctly"); } } return newObj; } int allocateChunk(int byteSize) { int newFreeSize; int enoughSpace; int newChunk; int minFree; if (allocationCount >= allocationsBetweenGCs) { incrementalGC(); } /* begin sufficientSpaceToAllocate: */ minFree = (lowSpaceThreshold + byteSize) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { enoughSpace = true; goto l1; } else { enoughSpace = sufficientSpaceAfterGC(minFree); goto l1; } l1: /* end sufficientSpaceToAllocate: */; if (!(enoughSpace)) { signalLowSpace = true; lowSpaceThreshold = 0; interruptCheckCounter = 0; } if (((longAt(freeBlock)) & 536870908) < (byteSize + 4)) { error("out of memory"); } newFreeSize = ((longAt(freeBlock)) & 536870908) - byteSize; newChunk = freeBlock; freeBlock += byteSize; /* begin setSizeOfFree:to: */ longAtput(freeBlock, (newFreeSize & 536870908) | 2); allocationCount += 1; return newChunk; } int allocateOrRecycleContext(int smallContextWanted) { int cntxt; if (smallContextWanted) { if (freeSmallContexts != 1) { cntxt = freeSmallContexts; freeSmallContexts = longAt(((((char *) cntxt)) + 4) + (0 << 2)); } else { cntxt = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)), 76, nilObj); } } else { if (freeLargeContexts != 1) { cntxt = freeLargeContexts; freeLargeContexts = longAt(((((char *) cntxt)) + 4) + (0 << 2)); } else { cntxt = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)), 156, nilObj); } } return cntxt; } int alphaBlendwith(int sourceWord, int destinationWord) { int shift; int alpha; int i; int blend; int unAlpha; int result; int colorMask; alpha = ((unsigned) sourceWord) >> 24; unAlpha = 255 - alpha; colorMask = 255; result = 0; for (i = 1; i <= 3; i += 1) { shift = (i - 1) * 8; blend = ((((((((unsigned) sourceWord) >> shift) & colorMask) * alpha) + (((((unsigned) destinationWord) >> shift) & colorMask) * unAlpha)) + 254) / 255) & colorMask; result = result | (blend << shift); } return result; } int alphaBlendConstwith(int sourceWord, int destinationWord) { return alphaBlendConstwithpaintMode(sourceWord, destinationWord, false); } int alphaBlendConstwithpaintMode(int sourceWord, int destinationWord, int paintMode) { int j; int destPixVal; int pixMask; int destShifted; int sourceShifted; int sourcePixVal; int pixBlend; int shift; int blend; int maskShifted; int bitsPerColor; int i; int unAlpha; int result; int rgbMask; if (destPixSize < 16) { return destinationWord; } unAlpha = 255 - sourceAlpha; pixMask = (1 << destPixSize) - 1; if (destPixSize == 16) { bitsPerColor = 5; } else { bitsPerColor = 8; } rgbMask = (1 << bitsPerColor) - 1; maskShifted = destMask; destShifted = destinationWord; sourceShifted = sourceWord; result = destinationWord; for (j = 1; j <= pixPerWord; j += 1) { sourcePixVal = sourceShifted & pixMask; if (!(((maskShifted & pixMask) == 0) || (paintMode && (sourcePixVal == 0)))) { destPixVal = destShifted & pixMask; pixBlend = 0; for (i = 1; i <= 3; i += 1) { shift = (i - 1) * bitsPerColor; blend = ((((((((unsigned) sourcePixVal) >> shift) & rgbMask) * sourceAlpha) + (((((unsigned) destPixVal) >> shift) & rgbMask) * unAlpha)) + 254) / 255) & rgbMask; pixBlend = pixBlend | (blend << shift); } if (destPixSize == 16) { result = (result & (~(pixMask << ((j - 1) * 16)))) | (pixBlend << ((j - 1) * 16)); } else { result = pixBlend; } } maskShifted = ((unsigned) maskShifted) >> destPixSize; sourceShifted = ((unsigned) sourceShifted) >> destPixSize; destShifted = ((unsigned) destShifted) >> destPixSize; } return result; } int alphaPaintConstwith(int sourceWord, int destinationWord) { if (sourceWord == 0) { return destinationWord; } return alphaBlendConstwithpaintMode(sourceWord, destinationWord, true); } int areIntegersand(int oop1, int oop2) { return ((oop1 & oop2) & 1) != 0; } int argCount(void) { return argumentCount; } int argumentCountOf(int methodPointer) { return (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 25) & 31; } int argumentCountOfBlock(int blockPointer) { int argCount; argCount = longAt(((((char *) blockPointer)) + 4) + (3 << 2)); if ((argCount & 1)) { return (argCount >> 1); } else { primitiveFail(); return 0; } } void * arrayValueOf(int arrayOop) { if ((!((arrayOop & 1))) && (isWordsOrBytes(arrayOop))) { return (void *) (arrayOop + 4); } primitiveFail(); } int asciiDirectoryDelimiter(void) { return dir_Delimitor(); } int asciiOfCharacter(int characterObj) { int ccIndex; int cl; /* begin assertClassOf:is: */ if ((characterObj & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(characterObj))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(characterObj - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (19 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { return longAt(((((char *) characterObj)) + 4) + (0 << 2)); } else { return 1; } } int assertClassOfis(int oop, int classOop) { int ccIndex; int cl; if ((oop & 1)) { successFlag = false; return null; } ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(oop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == classOop) && successFlag; } int assertFloatand(int oop1, int oop2) { int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; if (((oop1 | oop2) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((oop1 & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(oop1))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(oop1 - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((oop2 & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(oop2))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(oop2 - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } } AsyncFile * asyncFileValueOf(int oop) { int successValue; /* begin success: */ successValue = (!((oop & 1))) && ((((((unsigned) (longAt(oop))) >> 8) & 15) >= 8) && ((lengthOf(oop)) == (sizeof(AsyncFile)))); successFlag = successValue && successFlag; if (!(successFlag)) { return null; } return (AsyncFile *) (oop + 4); } int baseHeader(int oop) { return longAt(oop); } int beRootIfOld(int oop) { int header; if ((oop < youngStart) && (!((oop & 1)))) { header = longAt(oop); if ((header & 1073741824) == 0) { if (rootTableCount < 1000) { rootTableCount += 1; rootTable[rootTableCount] = oop; longAtput(oop, header | 1073741824); } } } } int beRootWhileForwarding(int oop) { int fwdBlock; int forwarding; int header; int newHeader; header = longAt(oop); if ((header & 2147483648U) != 0) { forwarding = true; fwdBlock = header & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } header = longAt(fwdBlock + 4); } else { forwarding = false; } if ((header & 1073741824) == 0) { if (rootTableCount < 1000) { rootTableCount += 1; rootTable[rootTableCount] = oop; newHeader = header | 1073741824; if (forwarding) { longAtput(fwdBlock + 4, newHeader); } else { longAtput(oop, newHeader); } } } } int becomewith(int array1, int array2) { int fieldOffset; int oop1; int oop2; int hdr1; int hdr2; int fwdBlock; int fwdHeader; int fwdBlock1; int fwdHeader1; int methodHeader; int sz; int fmt; int header; int type; if (!((fetchClassOf(array1)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2))))) { return false; } if (!((fetchClassOf(array2)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2))))) { return false; } if (!((lastPointerOf(array1)) == (lastPointerOf(array2)))) { return false; } if (!(containOnlyOopsand(array1, array2))) { return false; } if (!(prepareForwardingTableForBecomingwith(array1, array2))) { return false; } if (allYoungand(array1, array2)) { mapPointersInObjectsFromto(youngStart, endOfMemory); } else { mapPointersInObjectsFromto(startOfMemory(), endOfMemory); } /* begin restoreHeadersAfterBecoming:with: */ /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(array1))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header = longAt(array1); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l2; } else { if ((header & 126976) == 0) { type = 1; goto l2; } else { type = 3; goto l2; } } l2: /* end rightType: */; if (type == 0) { sz = (longAt(array1 - 8)) & 4294967292U; goto l3; } else { sz = header & 252; goto l3; } l3: /* end sizeBitsOfSafe: */; fieldOffset = sz - 4; goto l1; } if (fmt < 12) { fieldOffset = 0; goto l1; } methodHeader = longAt(array1 + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerOf: */; while (fieldOffset >= 4) { oop1 = longAt(array1 + fieldOffset); oop2 = longAt(array2 + fieldOffset); /* begin restoreHeaderOf: */ fwdHeader = longAt(oop1); fwdBlock = fwdHeader & 2147483644; if (checkAssertions) { if ((fwdHeader & 2147483648U) == 0) { error("attempting to restore the header of an object that has no forwarding block"); } /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } longAtput(oop1, longAt(fwdBlock + 4)); /* begin restoreHeaderOf: */ fwdHeader1 = longAt(oop2); fwdBlock1 = fwdHeader1 & 2147483644; if (checkAssertions) { if ((fwdHeader1 & 2147483648U) == 0) { error("attempting to restore the header of an object that has no forwarding block"); } /* begin fwdBlockValidate: */ if (!((fwdBlock1 > endOfMemory) && ((fwdBlock1 <= fwdTableNext) && ((fwdBlock1 & 3) == 0)))) { error("invalid fwd table entry"); } } longAtput(oop2, longAt(fwdBlock1 + 4)); /* begin exchangeHashBits:with: */ hdr1 = longAt(oop1); hdr2 = longAt(oop2); longAtput(oop1, (hdr1 & 3758227455U) | (hdr2 & 536739840)); longAtput(oop2, (hdr2 & 3758227455U) | (hdr1 & 536739840)); fieldOffset -= 4; } initializeMemoryFirstFree(freeBlock); return true; } int bitAndwith(int sourceWord, int destinationWord) { return sourceWord & destinationWord; } int bitAndInvertwith(int sourceWord, int destinationWord) { return sourceWord & (~destinationWord); } int bitInvertAndwith(int sourceWord, int destinationWord) { return (~sourceWord) & destinationWord; } int bitInvertAndInvertwith(int sourceWord, int destinationWord) { return (~sourceWord) & (~destinationWord); } int bitInvertDestinationwith(int sourceWord, int destinationWord) { return ~destinationWord; } int bitInvertOrwith(int sourceWord, int destinationWord) { return (~sourceWord) | destinationWord; } int bitInvertOrInvertwith(int sourceWord, int destinationWord) { return (~sourceWord) | (~destinationWord); } int bitInvertSourcewith(int sourceWord, int destinationWord) { return ~sourceWord; } int bitInvertXorwith(int sourceWord, int destinationWord) { return (~sourceWord) ^ destinationWord; } int bitOrwith(int sourceWord, int destinationWord) { return sourceWord | destinationWord; } int bitOrInvertwith(int sourceWord, int destinationWord) { return sourceWord | (~destinationWord); } int bitXorwith(int sourceWord, int destinationWord) { return sourceWord ^ destinationWord; } int booleanValueOf(int obj) { if (obj == trueObj) { return true; } if (obj == falseObj) { return false; } successFlag = false; return null; } int byteLengthOf(int oop) { int sz; int header; int fmt; header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { return sz - 4; } else { return (sz - 4) - (fmt & 3); } } int byteSwapByteObjects(void) { int methodHeader; int wordAddr; int oop; int fmt; int stopAddr; int addr; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; oop = chunk + extra; while (oop < endOfMemory) { if (!(((longAt(oop)) & 3) == 2)) { fmt = (((unsigned) (longAt(oop))) >> 8) & 15; if (fmt >= 8) { wordAddr = oop + 4; if (fmt >= 12) { methodHeader = longAt(oop + 4); wordAddr = (wordAddr + 4) + (((((unsigned) methodHeader) >> 10) & 255) * 4); } /* begin reverseBytesFrom:to: */ stopAddr = oop + (sizeBitsOf(oop)); addr = wordAddr; while (addr < stopAddr) { longAtput(addr, ((((((unsigned) (longAt(addr)) >> 24)) & 255) + ((((unsigned) (longAt(addr)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr)) << 24)) & 4278190080U)); addr += 4; } } } /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(oop + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = (oop + sz) + extra2; } } int byteSwapped(int w) { return ((((((unsigned) w >> 24)) & 255) + ((((unsigned) w >> 8)) & 65280)) + ((((unsigned) w << 8)) & 16711680)) + ((((unsigned) w << 24)) & 4278190080U); } int caller(void) { return longAt(((((char *) activeContext)) + 4) + (0 << 2)); } int characterForAscii(int integerObj) { return longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (((integerObj >> 1)) << 2)); } int checkAddress(int byteAddress) { if (byteAddress < (startOfMemory())) { error("bad address: negative"); } if (byteAddress >= memoryLimit) { error("bad address: past end of heap"); } } int checkBooleanResultfrom(int result, int primIndex) { int sp; int sp1; if (successFlag) { /* begin pushBool: */ if (result) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(primIndex); } } int checkForInterrupts(void) { int sema; int semaClass; int i; int now; int externalObjects; int index; interruptCheckCounter = 1000; now = (ioMSecs()) & 536870911; if (now < lastTick) { nextPollTick = now + (nextPollTick - lastTick); if (nextWakeupTick != 0) { nextWakeupTick = now + (nextWakeupTick - lastTick); } } lastTick = now; if (signalLowSpace) { signalLowSpace = false; sema = longAt(((((char *) specialObjectsOop)) + 4) + (17 << 2)); if (!(sema == nilObj)) { synchronousSignal(sema); } } if (now >= nextPollTick) { ioProcessEvents(); nextPollTick = now + 500; } if (interruptPending) { interruptPending = false; sema = longAt(((((char *) specialObjectsOop)) + 4) + (30 << 2)); if (!(sema == nilObj)) { synchronousSignal(sema); } } if ((nextWakeupTick != 0) && (now >= nextWakeupTick)) { nextWakeupTick = 0; sema = longAt(((((char *) specialObjectsOop)) + 4) + (29 << 2)); if (!(sema == nilObj)) { synchronousSignal(sema); } } if (semaphoresToSignalCount > 0) { externalObjects = longAt(((((char *) specialObjectsOop)) + 4) + (38 << 2)); semaClass = longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)); for (i = 1; i <= semaphoresToSignalCount; i += 1) { index = semaphoresToSignal[i]; sema = longAt(((((char *) externalObjects)) + 4) + ((index - 1) << 2)); if ((fetchClassOf(sema)) == semaClass) { synchronousSignal(sema); } } semaphoresToSignalCount = 0; } } int checkImageVersionFrom(sqImageFile f) { int version; int expectedVersion; int firstVersion; expectedVersion = 6502; sqImageFileSeek(f, 0); version = firstVersion = getLongFromFileswap(f, false); if (version == expectedVersion) { return false; } sqImageFileSeek(f, 0); version = getLongFromFileswap(f, true); if (version == expectedVersion) { return true; } sqImageFileSeek(f, 512); version = getLongFromFileswap(f, false); if (version == expectedVersion) { return false; } sqImageFileSeek(f, 512); version = getLongFromFileswap(f, true); if (version == expectedVersion) { return true; } print("This interpreter (vers. "); printNum(expectedVersion); print(" cannot read image file (vers. "); printNum(firstVersion); /* begin cr */ printf("\n"); ioExit(); } int checkIntegerResultfrom(int integerResult, int primIndex) { int sp; if (successFlag && ((integerResult ^ (integerResult << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((integerResult << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(primIndex); } } int checkSourceOverlap(void) { int t; if ((sourceForm == destForm) && (dy >= sy)) { if (dy > sy) { vDir = -1; sy = (sy + bbH) - 1; dy = (dy + bbH) - 1; } else { if ((dy == sy) && (dx > sx)) { hDir = -1; sx = (sx + bbW) - 1; dx = (dx + bbW) - 1; if (nWords > 1) { t = mask1; mask1 = mask2; mask2 = t; } } } destIndex = (destBits + 4) + (((dy * destRaster) + (dx / pixPerWord)) * 4); destDelta = 4 * ((destRaster * vDir) - (nWords * hDir)); } } int checkedByteAt(int byteAddress) { /* begin checkAddress: */ if (byteAddress < (startOfMemory())) { error("bad address: negative"); } if (byteAddress >= memoryLimit) { error("bad address: past end of heap"); } return byteAt(byteAddress); } int checkedByteAtput(int byteAddress, int byte) { /* begin checkAddress: */ if (byteAddress < (startOfMemory())) { error("bad address: negative"); } if (byteAddress >= memoryLimit) { error("bad address: past end of heap"); } byteAtput(byteAddress, byte); } int checkedIntegerValueOf(int intOop) { if ((intOop & 1)) { return (intOop >> 1); } else { primitiveFail(); return 0; } } int checkedLongAt(int byteAddress) { /* begin checkAddress: */ if (byteAddress < (startOfMemory())) { error("bad address: negative"); } if (byteAddress >= memoryLimit) { error("bad address: past end of heap"); } /* begin checkAddress: */ if ((byteAddress + 3) < (startOfMemory())) { error("bad address: negative"); } if ((byteAddress + 3) >= memoryLimit) { error("bad address: past end of heap"); } return longAt(byteAddress); } int checkedLongAtput(int byteAddress, int a32BitInteger) { /* begin checkAddress: */ if (byteAddress < (startOfMemory())) { error("bad address: negative"); } if (byteAddress >= memoryLimit) { error("bad address: past end of heap"); } /* begin checkAddress: */ if ((byteAddress + 3) < (startOfMemory())) { error("bad address: negative"); } if ((byteAddress + 3) >= memoryLimit) { error("bad address: past end of heap"); } longAtput(byteAddress, a32BitInteger); } int chunkFromOop(int oop) { int extra; int type; int extra1; /* begin extraHeaderBytes: */ type = (longAt(oop)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; return oop - extra; } int classHeader(int oop) { return longAt(oop - 4); } int clearRootsTable(void) { int oop; int i; for (i = 1; i <= rootTableCount; i += 1) { oop = rootTable[i]; longAtput(oop, (longAt(oop)) & 3221225471U); rootTable[i] = 0; } rootTableCount = 0; } int clearWordwith(int source, int destination) { return 0; } int clipRange(void) { if (destX >= clipX) { sx = sourceX; dx = destX; bbW = width; } else { sx = sourceX + (clipX - destX); bbW = width - (clipX - destX); dx = clipX; } if ((dx + bbW) > (clipX + clipWidth)) { bbW -= (dx + bbW) - (clipX + clipWidth); } if (destY >= clipY) { sy = sourceY; dy = destY; bbH = height; } else { sy = (sourceY + clipY) - destY; bbH = height - (clipY - destY); dy = clipY; } if ((dy + bbH) > (clipY + clipHeight)) { bbH -= (dy + bbH) - (clipY + clipHeight); } if (noSource) { return null; } if (sx < 0) { dx -= sx; bbW += sx; sx = 0; } if ((sx + bbW) > srcWidth) { bbW -= (sx + bbW) - srcWidth; } if (sy < 0) { dy -= sy; bbH += sy; sy = 0; } if ((sy + bbH) > srcHeight) { bbH -= (sy + bbH) - srcHeight; } } int clone(int oop) { int newOop; int header; int hash; int fromIndex; int lastFrom; int extraHdrBytes; int bytes; int remappedOop; int newChunk; int toIndex; int oop1; int type; int extra; int header1; int newFreeSize; int enoughSpace; int newChunk1; int minFree; /* begin extraHeaderBytes: */ type = (longAt(oop)) & 3; if (type > 1) { extra = 0; } else { if (type == 1) { extra = 4; } else { extra = 8; } } extraHdrBytes = extra; /* begin sizeBitsOf: */ header1 = longAt(oop); if ((header1 & 3) == 0) { bytes = (longAt(oop - 8)) & 4294967292U; goto l1; } else { bytes = header1 & 252; goto l1; } l1: /* end sizeBitsOf: */; bytes += extraHdrBytes; /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = oop; /* begin allocateChunk: */ if (allocationCount >= allocationsBetweenGCs) { incrementalGC(); } /* begin sufficientSpaceToAllocate: */ minFree = (lowSpaceThreshold + bytes) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { enoughSpace = true; goto l2; } else { enoughSpace = sufficientSpaceAfterGC(minFree); goto l2; } l2: /* end sufficientSpaceToAllocate: */; if (!(enoughSpace)) { signalLowSpace = true; lowSpaceThreshold = 0; interruptCheckCounter = 0; } if (((longAt(freeBlock)) & 536870908) < (bytes + 4)) { error("out of memory"); } newFreeSize = ((longAt(freeBlock)) & 536870908) - bytes; newChunk1 = freeBlock; freeBlock += bytes; /* begin setSizeOfFree:to: */ longAtput(freeBlock, (newFreeSize & 536870908) | 2); allocationCount += 1; newChunk = newChunk1; /* begin popRemappableOop */ oop1 = remapBuffer[remapBufferCount]; remapBufferCount -= 1; remappedOop = oop1; toIndex = newChunk - 4; fromIndex = (remappedOop - extraHdrBytes) - 4; lastFrom = fromIndex + bytes; while (fromIndex < lastFrom) { longAtput(toIndex += 4, longAt(fromIndex += 4)); } newOop = newChunk + extraHdrBytes; /* begin newObjectHash */ lastHash = (13849 + (27181 * lastHash)) & 65535; hash = lastHash; header = (longAt(newOop)) & 131071; header = header | ((hash << 17) & 536739840); longAtput(newOop, header); return newOop; } int commonAt(int stringy) { int index; int result; int rcvr; int sp; index = longAt(stackPointer); rcvr = longAt(stackPointer - (1 * 4)); if (((index & 1)) && (!((rcvr & 1)))) { index = (index >> 1); result = stObjectat(rcvr, index); if (stringy && (successFlag)) { result = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (((result >> 1)) << 2)); } } else { successFlag = false; } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), result); stackPointer = sp; } else { if (stringy) { failSpecialPrim(63); } else { failSpecialPrim(60); } } } int commonAtPut(int stringy) { int value; int valToStore; int index; int rcvr; int sp; value = valToStore = longAt(stackPointer); index = longAt(stackPointer - (1 * 4)); rcvr = longAt(stackPointer - (2 * 4)); if (((index & 1)) && (!((rcvr & 1)))) { index = (index >> 1); if (stringy) { valToStore = asciiOfCharacter(value); } stObjectatput(rcvr, index, valToStore); } else { successFlag = false; } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((3 - 1) * 4), value); stackPointer = sp; } else { if (stringy) { failSpecialPrim(64); } else { failSpecialPrim(61); } } } int compare31or32Bitsequal(int obj1, int obj2) { if (((obj1 & 1)) && ((obj2 & 1))) { return obj1 == obj2; } return (positive32BitValueOf(obj1)) == (positive32BitValueOf(obj2)); } int containOnlyOopsand(int array1, int array2) { int fieldOffset; int methodHeader; int sz; int fmt; int header; int type; /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(array1))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header = longAt(array1); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l2; } else { if ((header & 126976) == 0) { type = 1; goto l2; } else { type = 3; goto l2; } } l2: /* end rightType: */; if (type == 0) { sz = (longAt(array1 - 8)) & 4294967292U; goto l3; } else { sz = header & 252; goto l3; } l3: /* end sizeBitsOfSafe: */; fieldOffset = sz - 4; goto l1; } if (fmt < 12) { fieldOffset = 0; goto l1; } methodHeader = longAt(array1 + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerOf: */; while (fieldOffset >= 4) { if (((longAt(array1 + fieldOffset)) & 1)) { return false; } if (((longAt(array2 + fieldOffset)) & 1)) { return false; } fieldOffset -= 4; } return true; } int copyBits(void) { int integerPointer; int dWid; int sxLowBits; int dxLowBits; int pixPerM1; int t; int sp; clipRange(); if ((bbW <= 0) || (bbH <= 0)) { affectedL = affectedR = affectedT = affectedB = 0; return null; } destMaskAndPointerInit(); bitCount = 0; if ((combinationRule == 30) || (combinationRule == 31)) { if (argumentCount == 1) { /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { sourceAlpha = (integerPointer >> 1); goto l1; } else { primitiveFail(); sourceAlpha = 0; goto l1; } l1: /* end stackIntegerValue: */; if ((!(!successFlag)) && ((sourceAlpha >= 0) && (sourceAlpha <= 255))) { /* begin pop: */ stackPointer -= 1 * 4; } else { return primitiveFail(); } } else { return primitiveFail(); } } if (noSource) { copyLoopNoSource(); } else { /* begin checkSourceOverlap */ if ((sourceForm == destForm) && (dy >= sy)) { if (dy > sy) { vDir = -1; sy = (sy + bbH) - 1; dy = (dy + bbH) - 1; } else { if ((dy == sy) && (dx > sx)) { hDir = -1; sx = (sx + bbW) - 1; dx = (dx + bbW) - 1; if (nWords > 1) { t = mask1; mask1 = mask2; mask2 = t; } } } destIndex = (destBits + 4) + (((dy * destRaster) + (dx / pixPerWord)) * 4); destDelta = 4 * ((destRaster * vDir) - (nWords * hDir)); } if ((sourcePixSize != destPixSize) || (colorMap != nilObj)) { copyLoopPixMap(); } else { /* begin sourceSkewAndPointerInit */ pixPerM1 = pixPerWord - 1; sxLowBits = sx & pixPerM1; dxLowBits = dx & pixPerM1; if (hDir > 0) { dWid = ((bbW < (pixPerWord - dxLowBits)) ? bbW : (pixPerWord - dxLowBits)); preload = (sxLowBits + dWid) > pixPerM1; } else { dWid = ((bbW < (dxLowBits + 1)) ? bbW : (dxLowBits + 1)); preload = ((sxLowBits - dWid) + 1) < 0; } skew = (sxLowBits - dxLowBits) * destPixSize; if (preload) { if (skew < 0) { skew += 32; } else { skew -= 32; } } sourceIndex = (sourceBits + 4) + (((sy * sourceRaster) + (sx / (32 / sourcePixSize))) * 4); sourceDelta = 4 * ((sourceRaster * vDir) - (nWords * hDir)); if (preload) { sourceDelta -= 4 * hDir; } copyLoop(); } } if ((combinationRule == 22) || (combinationRule == 32)) { affectedL = affectedR = affectedT = affectedB = 0; /* begin pop: */ stackPointer -= 1 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((bitCount << 1) | 1)); stackPointer = sp; return null; } if (hDir > 0) { affectedL = dx; affectedR = dx + bbW; } else { affectedL = (dx - bbW) + 1; affectedR = dx + 1; } if (vDir > 0) { affectedT = dy; affectedB = dy + bbH; } else { affectedT = (dy - bbH) + 1; affectedB = dy + 1; } } int copyLoop(void) { int y; int prevWord; int skewWord; int mergeWord; int skewMask; int (*mergeFnwith)(int, int); int hInc; int i; int thisWord; int word; int halftoneWord; int notSkewMask; int unskew; mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); mergeFnwith; hInc = hDir * 4; if (skew == -32) { skew = unskew = skewMask = 0; } else { if (skew < 0) { unskew = skew + 32; skewMask = 4294967295U << (0 - skew); } else { if (skew == 0) { unskew = 0; skewMask = 4294967295U; } else { unskew = skew - 32; skewMask = ((unsigned) 4294967295U) >> skew; } } } notSkewMask = ~skewMask; if (noHalftone) { halftoneWord = 4294967295U; halftoneHeight = 0; } else { halftoneWord = longAt(halftoneBase); } y = dy; for (i = 1; i <= bbH; i += 1) { if (halftoneHeight > 1) { halftoneWord = longAt(halftoneBase + ((y % halftoneHeight) * 4)); y += vDir; } if (preload) { prevWord = longAt(sourceIndex); sourceIndex += hInc; } else { prevWord = 0; } destMask = mask1; thisWord = longAt(sourceIndex); sourceIndex += hInc; skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); prevWord = thisWord; mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); destIndex += hInc; destMask = 4294967295U; if (combinationRule == 3) { if (noHalftone && (notSkewMask == 0)) { for (word = 2; word <= (nWords - 1); word += 1) { thisWord = longAt(sourceIndex); sourceIndex += hInc; longAtput(destIndex, thisWord); destIndex += hInc; } } else { for (word = 2; word <= (nWords - 1); word += 1) { thisWord = longAt(sourceIndex); sourceIndex += hInc; skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); prevWord = thisWord; longAtput(destIndex, skewWord & halftoneWord); destIndex += hInc; } } } else { for (word = 2; word <= (nWords - 1); word += 1) { thisWord = longAt(sourceIndex); sourceIndex += hInc; skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); prevWord = thisWord; mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); longAtput(destIndex, mergeWord); destIndex += hInc; } } if (nWords > 1) { destMask = mask2; thisWord = longAt(sourceIndex); sourceIndex += hInc; skewWord = (((unskew < 0) ? ((unsigned) (prevWord & notSkewMask) >> -unskew) : ((unsigned) (prevWord & notSkewMask) << unskew))) | (((skew < 0) ? ((unsigned) (thisWord & skewMask) >> -skew) : ((unsigned) (thisWord & skewMask) << skew))); mergeWord = mergeFnwith(skewWord & halftoneWord, longAt(destIndex)); longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); destIndex += hInc; } sourceIndex += sourceDelta; destIndex += destDelta; } } int copyLoopNoSource(void) { int mergeWord; int (*mergeFnwith)(int, int); int i; int word; int halftoneWord; mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); mergeFnwith; for (i = 1; i <= bbH; i += 1) { if (noHalftone) { halftoneWord = 4294967295U; } else { halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); } destMask = mask1; mergeWord = mergeFnwith(halftoneWord, longAt(destIndex)); longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); destIndex += 4; destMask = 4294967295U; if (combinationRule == 3) { for (word = 2; word <= (nWords - 1); word += 1) { longAtput(destIndex, halftoneWord); destIndex += 4; } } else { for (word = 2; word <= (nWords - 1); word += 1) { mergeWord = mergeFnwith(halftoneWord, longAt(destIndex)); longAtput(destIndex, mergeWord); destIndex += 4; } } if (nWords > 1) { destMask = mask2; mergeWord = mergeFnwith(halftoneWord, longAt(destIndex)); longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); destIndex += 4; } destIndex += destDelta; } } int copyLoopPixMap(void) { int skewWord; int mergeWord; int srcPixPerWord; int scrStartBits; int nSourceIncs; int startBits; int sourcePixMask; int destPixMask; int nullMap; int endBits; int (*mergeFnwith)(int, int); int halftoneWord; int i; int word; int nPix; int nPix1; mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); mergeFnwith; srcPixPerWord = 32 / sourcePixSize; if (sourcePixSize == 32) { sourcePixMask = -1; } else { sourcePixMask = (1 << sourcePixSize) - 1; } if (destPixSize == 32) { destPixMask = -1; } else { destPixMask = (1 << destPixSize) - 1; } nullMap = colorMap == nilObj; sourceIndex = (sourceBits + 4) + (((sy * sourceRaster) + (sx / srcPixPerWord)) * 4); scrStartBits = srcPixPerWord - (sx & (srcPixPerWord - 1)); if (bbW < scrStartBits) { nSourceIncs = 0; } else { nSourceIncs = ((bbW - scrStartBits) / srcPixPerWord) + 1; } sourceDelta = (sourceRaster - nSourceIncs) * 4; startBits = pixPerWord - (dx & (pixPerWord - 1)); endBits = (((dx + bbW) - 1) & (pixPerWord - 1)) + 1; for (i = 1; i <= bbH; i += 1) { if (noHalftone) { halftoneWord = 4294967295U; } else { halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); } srcBitIndex = (sx & (srcPixPerWord - 1)) * sourcePixSize; destMask = mask1; if (bbW < startBits) { /* begin pickSourcePixels:nullMap:srcMask:destMask: */ nPix = bbW; if (sourcePixSize >= 16) { skewWord = pickSourcePixelsRGBnullMapsrcMaskdestMask(nPix, nullMap, sourcePixMask, destPixMask); goto l1; } if (nullMap) { skewWord = pickSourcePixelsNullMapsrcMaskdestMask(nPix, sourcePixMask, destPixMask); goto l1; } skewWord = pickSourcePixelssrcMaskdestMask(nPix, sourcePixMask, destPixMask); l1: /* end pickSourcePixels:nullMap:srcMask:destMask: */; skewWord = ((((startBits - bbW) * destPixSize) < 0) ? ((unsigned) skewWord >> -((startBits - bbW) * destPixSize)) : ((unsigned) skewWord << ((startBits - bbW) * destPixSize))); } else { /* begin pickSourcePixels:nullMap:srcMask:destMask: */ if (sourcePixSize >= 16) { skewWord = pickSourcePixelsRGBnullMapsrcMaskdestMask(startBits, nullMap, sourcePixMask, destPixMask); goto l2; } if (nullMap) { skewWord = pickSourcePixelsNullMapsrcMaskdestMask(startBits, sourcePixMask, destPixMask); goto l2; } skewWord = pickSourcePixelssrcMaskdestMask(startBits, sourcePixMask, destPixMask); l2: /* end pickSourcePixels:nullMap:srcMask:destMask: */; } for (word = 1; word <= nWords; word += 1) { mergeWord = mergeFnwith(skewWord & halftoneWord, (longAt(destIndex)) & destMask); longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); destIndex += 4; if (word >= (nWords - 1)) { if (!(word == nWords)) { destMask = mask2; /* begin pickSourcePixels:nullMap:srcMask:destMask: */ if (sourcePixSize >= 16) { skewWord = pickSourcePixelsRGBnullMapsrcMaskdestMask(endBits, nullMap, sourcePixMask, destPixMask); goto l3; } if (nullMap) { skewWord = pickSourcePixelsNullMapsrcMaskdestMask(endBits, sourcePixMask, destPixMask); goto l3; } skewWord = pickSourcePixelssrcMaskdestMask(endBits, sourcePixMask, destPixMask); l3: /* end pickSourcePixels:nullMap:srcMask:destMask: */; skewWord = ((((pixPerWord - endBits) * destPixSize) < 0) ? ((unsigned) skewWord >> -((pixPerWord - endBits) * destPixSize)) : ((unsigned) skewWord << ((pixPerWord - endBits) * destPixSize))); } } else { destMask = 4294967295U; /* begin pickSourcePixels:nullMap:srcMask:destMask: */ nPix1 = pixPerWord; if (sourcePixSize >= 16) { skewWord = pickSourcePixelsRGBnullMapsrcMaskdestMask(nPix1, nullMap, sourcePixMask, destPixMask); goto l4; } if (nullMap) { skewWord = pickSourcePixelsNullMapsrcMaskdestMask(nPix1, sourcePixMask, destPixMask); goto l4; } skewWord = pickSourcePixelssrcMaskdestMask(nPix1, sourcePixMask, destPixMask); l4: /* end pickSourcePixels:nullMap:srcMask:destMask: */; } } sourceIndex += sourceDelta; destIndex += destDelta; } } int cr(void) { printf("\n"); } int createActualMessage(void) { int argumentArray; int message; int oop; int valuePointer; int toIndex; int fromIndex; int lastFrom; int sp; argumentArray = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)), argumentCount); /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = argumentArray; message = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (15 << 2)), 0); /* begin popRemappableOop */ oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; argumentArray = oop; if (argumentArray < youngStart) { beRootIfOld(argumentArray); } /* begin storePointer:ofObject:withValue: */ valuePointer = messageSelector; if (message < youngStart) { possibleRootStoreIntovalue(message, valuePointer); } longAtput(((((char *) message)) + 4) + (0 << 2), valuePointer); /* begin storePointer:ofObject:withValue: */ if (message < youngStart) { possibleRootStoreIntovalue(message, argumentArray); } longAtput(((((char *) message)) + 4) + (1 << 2), argumentArray); /* begin transfer:fromIndex:ofObject:toIndex:ofObject: */ fromIndex = activeContext + (((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - (argumentCount - 1)) * 4); toIndex = argumentArray + (0 * 4); lastFrom = fromIndex + (argumentCount * 4); while (fromIndex < lastFrom) { fromIndex += 4; toIndex += 4; longAtput(toIndex, longAt(fromIndex)); } /* begin pop: */ stackPointer -= argumentCount * 4; /* begin push: */ longAtput(sp = stackPointer + 4, message); stackPointer = sp; argumentCount = 1; } int deltaFromtonSteps(int x1, int x2, int n) { if (x2 > x1) { return (((x2 - x1) + 16384) / (n + 1)) + 1; } else { if (x2 == x1) { return 0; } return 0 - ((((x1 - x2) + 16384) / (n + 1)) + 1); } } int destMaskAndPointerInit(void) { int startBits; int endBits; int pixPerM1; pixPerM1 = pixPerWord - 1; startBits = pixPerWord - (dx & pixPerM1); mask1 = ((unsigned) 4294967295U) >> (32 - (startBits * destPixSize)); endBits = (((dx + bbW) - 1) & pixPerM1) + 1; mask2 = 4294967295U << (32 - (endBits * destPixSize)); if (bbW < startBits) { mask1 = mask1 & mask2; mask2 = 0; nWords = 1; } else { nWords = (((bbW - startBits) + pixPerM1) / pixPerWord) + 1; } hDir = vDir = 1; destIndex = (destBits + 4) + (((dy * destRaster) + (dx / pixPerWord)) * 4); destDelta = 4 * ((destRaster * vDir) - (nWords * hDir)); } int destinationWordwith(int sourceWord, int destinationWord) { return destinationWord; } int drawLoopXY(int xDelta, int yDelta) { int affL; int dx1; int dy1; int px; int py; int affR; int affT; int affB; int i; int P; int objectPointer; int integerValue; int objectPointer1; int integerValue1; if (xDelta > 0) { dx1 = 1; } else { if (xDelta == 0) { dx1 = 0; } else { dx1 = -1; } } if (yDelta > 0) { dy1 = 1; } else { if (yDelta == 0) { dy1 = 0; } else { dy1 = -1; } } px = abs(yDelta); py = abs(xDelta); affL = affT = 9999; affR = affB = -9999; if (py > px) { P = ((int) py >> 1); for (i = 1; i <= py; i += 1) { destX += dx1; if ((P -= px) < 0) { destY += dy1; P += py; } if (i < py) { copyBits(); if ((affectedL < affectedR) && (affectedT < affectedB)) { affL = ((affL < affectedL) ? affL : affectedL); affR = ((affR < affectedR) ? affectedR : affR); affT = ((affT < affectedT) ? affT : affectedT); affB = ((affB < affectedB) ? affectedB : affB); if (((affR - affL) * (affB - affT)) > 4000) { affectedL = affL; affectedR = affR; affectedT = affT; affectedB = affB; showDisplayBits(); affL = affT = 9999; affR = affB = -9999; } } } } } else { P = ((int) px >> 1); for (i = 1; i <= px; i += 1) { destY += dy1; if ((P -= py) < 0) { destX += dx1; P += px; } if (i < px) { copyBits(); if ((affectedL < affectedR) && (affectedT < affectedB)) { affL = ((affL < affectedL) ? affL : affectedL); affR = ((affR < affectedR) ? affectedR : affR); affT = ((affT < affectedT) ? affT : affectedT); affB = ((affB < affectedB) ? affectedB : affB); if (((affR - affL) * (affB - affT)) > 4000) { affectedL = affL; affectedR = affR; affectedT = affT; affectedB = affB; showDisplayBits(); affL = affT = 9999; affR = affB = -9999; } } } } } affectedL = affL; affectedR = affR; affectedT = affT; affectedB = affB; /* begin storeInteger:ofObject:withValue: */ objectPointer = bitBltOop; integerValue = destX; if ((integerValue ^ (integerValue << 1)) >= 0) { longAtput(((((char *) objectPointer)) + 4) + (4 << 2), ((integerValue << 1) | 1)); } else { primitiveFail(); } /* begin storeInteger:ofObject:withValue: */ objectPointer1 = bitBltOop; integerValue1 = destY; if ((integerValue1 ^ (integerValue1 << 1)) >= 0) { longAtput(((((char *) objectPointer1)) + 4) + (5 << 2), ((integerValue1 << 1) | 1)); } else { primitiveFail(); } } int exchangeHashBitswith(int oop1, int oop2) { int hdr1; int hdr2; hdr1 = longAt(oop1); hdr2 = longAt(oop2); longAtput(oop1, (hdr1 & 3758227455U) | (hdr2 & 536739840)); longAtput(oop2, (hdr2 & 3758227455U) | (hdr1 & 536739840)); } int executeNewMethod(void) { if ((primitiveIndex == 0) || (!(primitiveResponse()))) { activateNewMethod(); /* begin quickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { checkForInterrupts(); } } } int extraHeaderBytes(int oopOrChunk) { int type; int extra; type = (longAt(oopOrChunk)) & 3; if (type > 1) { extra = 0; } else { if (type == 1) { extra = 4; } else { extra = 8; } } return extra; } int failSpecialPrim(int primIndex) { int selectorIndex; int bytecode; int newReceiver; int rcvrClass; int ccIndex; int ok; int probe; int p; int hash; int primBits; bytecode = byteAt(instructionPointer); if ((bytecode < 176) || (bytecode > 207)) { return primitiveFail(); } selectorIndex = (bytecode - 176) * 2; messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + (selectorIndex << 2)); argumentCount = ((longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((selectorIndex + 1) << 2))) >> 1); newReceiver = longAt(stackPointer - (argumentCount * 4)); /* begin fetchClassOf: */ if ((newReceiver & 1)) { rcvrClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(newReceiver))) >> 12) & 31) - 1; if (ccIndex < 0) { rcvrClass = (longAt(newReceiver - 4)) & 4294967292U; goto l1; } else { rcvrClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; /* begin findNewMethodInClass: */ /* begin lookupInMethodCacheSel:class: */ hash = ((unsigned) (messageSelector ^ rcvrClass)) >> 2; probe = (hash & 511) + 1; for (p = 1; p <= 3; p += 1) { if (((methodCache[probe]) == messageSelector) && ((methodCache[probe + 512]) == rcvrClass)) { newMethod = methodCache[probe + (512 * 2)]; primitiveIndex = methodCache[probe + (512 * 3)]; ok = true; goto l3; } probe = ((((unsigned) hash) >> p) & 511) + 1; } ok = false; l3: /* end lookupInMethodCacheSel:class: */; if (!(ok)) { lookupMethodInClass(rcvrClass); /* begin primitiveIndexOf: */ primBits = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; if (primBits > 511) { primitiveIndex = (primBits & 511) + (((unsigned) primBits) >> 19); goto l2; } else { primitiveIndex = primBits; goto l2; } l2: /* end primitiveIndexOf: */; addToMethodCacheSelclassmethodprimIndex(messageSelector, rcvrClass, newMethod, primitiveIndex); } if ((primitiveIndex > 37) && (primitiveIndex != primIndex)) { /* begin executeNewMethod */ if ((primitiveIndex == 0) || (!(primitiveResponse()))) { activateNewMethod(); /* begin quickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { checkForInterrupts(); } } } else { activateNewMethod(); } } int failed(void) { return !successFlag; } void * fetchArrayofObject(int fieldIndex, int objectPointer) { int arrayOop; arrayOop = longAt(((((char *) objectPointer)) + 4) + (fieldIndex << 2)); return arrayValueOf(arrayOop); } int fetchByteofObject(int byteIndex, int oop) { return byteAt(((((char *) oop)) + 4) + byteIndex); } int fetchClassOf(int oop) { int ccIndex; if ((oop & 1)) { return longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); } ccIndex = ((((unsigned) (longAt(oop))) >> 12) & 31) - 1; if (ccIndex < 0) { return (longAt(oop - 4)) & 4294967292U; } else { return longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); } } int fetchContextRegisters(int activeCntx) { int tmp; tmp = longAt(((((char *) activeCntx)) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) activeCntx)) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = activeCntx; } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) activeCntx)) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) activeCntx)) + 4) + (2 << 2))) >> 1); stackPointer = (activeCntx + 4) + (((6 + tmp) - 1) * 4); } double fetchFloatofObject(int fieldIndex, int objectPointer) { int floatOop; floatOop = longAt(((((char *) objectPointer)) + 4) + (fieldIndex << 2)); return floatValueOf(floatOop); } int fetchIntegerofObject(int fieldIndex, int objectPointer) { int intOop; intOop = longAt(((((char *) objectPointer)) + 4) + (fieldIndex << 2)); if ((intOop & 1)) { return (intOop >> 1); } else { primitiveFail(); return 0; } } int fetchIntegerOrTruncFloatofObject(int fieldIndex, int objectPointer) { double trunc; double frac; double floatVal; int intOrFloat; int ccIndex; int cl; intOrFloat = longAt(((((char *) objectPointer)) + 4) + (fieldIndex << 2)); if ((intOrFloat & 1)) { return (intOrFloat >> 1); } /* begin assertClassOf:is: */ if ((intOrFloat & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(intOrFloat))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(intOrFloat - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { fetchFloatAtinto(intOrFloat + 4, floatVal); frac = modf(floatVal, &trunc); success((-2147483648.0 <= trunc) && (trunc <= 2147483647.0)); } if (successFlag) { return ((int) trunc); } else { return 0; } } int fetchPointerofObject(int fieldIndex, int oop) { return longAt(((((char *) oop)) + 4) + (fieldIndex << 2)); } int fetchWordofObject(int fieldIndex, int oop) { return longAt(((((char *) oop)) + 4) + (fieldIndex << 2)); } int fetchWordLengthOf(int objectPointer) { int sz; int header; /* begin sizeBitsOf: */ header = longAt(objectPointer); if ((header & 3) == 0) { sz = (longAt(objectPointer - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; return ((unsigned) (sz - 4)) >> 2; } int fileRecordSize(void) { return sizeof(SQFile); } SQFile * fileValueOf(int objectPointer) { int fileIndex; int successValue; /* begin success: */ successValue = (((((unsigned) (longAt(objectPointer))) >> 8) & 15) >= 8) && ((lengthOf(objectPointer)) == (fileRecordSize())); successFlag = successValue && successFlag; if (successFlag) { fileIndex = objectPointer + 4; return (SQFile *) fileIndex; } else { return null; } } int findClassOfMethodforReceiver(int meth, int rcvr) { int methodArray; int done; int i; int classDict; int currClass; int classDictSize; int sz; int header; int ccIndex; int ccIndex1; /* begin fetchClassOf: */ if ((rcvr & 1)) { currClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l2; } ccIndex = ((((unsigned) (longAt(rcvr))) >> 12) & 31) - 1; if (ccIndex < 0) { currClass = (longAt(rcvr - 4)) & 4294967292U; goto l2; } else { currClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l2; } l2: /* end fetchClassOf: */; done = false; while (!(done)) { classDict = longAt(((((char *) currClass)) + 4) + (1 << 2)); /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(classDict); if ((header & 3) == 0) { sz = (longAt(classDict - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; classDictSize = ((unsigned) (sz - 4)) >> 2; methodArray = longAt(((((char *) classDict)) + 4) + (1 << 2)); i = 0; while (i < (classDictSize - 2)) { if (meth == (longAt(((((char *) methodArray)) + 4) + (i << 2)))) { return currClass; } i += 1; } currClass = longAt(((((char *) currClass)) + 4) + (0 << 2)); done = currClass == nilObj; } /* begin fetchClassOf: */ if ((rcvr & 1)) { return longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); } ccIndex1 = ((((unsigned) (longAt(rcvr))) >> 12) & 31) - 1; if (ccIndex1 < 0) { return (longAt(rcvr - 4)) & 4294967292U; } else { return longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex1 << 2)); } return null; } int findNewMethodInClass(int class) { int ok; int probe; int p; int hash; int primBits; /* begin lookupInMethodCacheSel:class: */ hash = ((unsigned) (messageSelector ^ class)) >> 2; probe = (hash & 511) + 1; for (p = 1; p <= 3; p += 1) { if (((methodCache[probe]) == messageSelector) && ((methodCache[probe + 512]) == class)) { newMethod = methodCache[probe + (512 * 2)]; primitiveIndex = methodCache[probe + (512 * 3)]; ok = true; goto l1; } probe = ((((unsigned) hash) >> p) & 511) + 1; } ok = false; l1: /* end lookupInMethodCacheSel:class: */; if (!(ok)) { lookupMethodInClass(class); /* begin primitiveIndexOf: */ primBits = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; if (primBits > 511) { primitiveIndex = (primBits & 511) + (((unsigned) primBits) >> 19); goto l2; } else { primitiveIndex = primBits; goto l2; } l2: /* end primitiveIndexOf: */; addToMethodCacheSelclassmethodprimIndex(messageSelector, class, newMethod, primitiveIndex); } } int findSelectorOfMethodforReceiver(int meth, int rcvr) { int methodArray; int done; int i; int classDict; int currClass; int classDictSize; int sz; int header; int ccIndex; /* begin fetchClassOf: */ if ((rcvr & 1)) { currClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l2; } ccIndex = ((((unsigned) (longAt(rcvr))) >> 12) & 31) - 1; if (ccIndex < 0) { currClass = (longAt(rcvr - 4)) & 4294967292U; goto l2; } else { currClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l2; } l2: /* end fetchClassOf: */; done = false; while (!(done)) { classDict = longAt(((((char *) currClass)) + 4) + (1 << 2)); /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(classDict); if ((header & 3) == 0) { sz = (longAt(classDict - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; classDictSize = ((unsigned) (sz - 4)) >> 2; methodArray = longAt(((((char *) classDict)) + 4) + (1 << 2)); i = 0; while (i <= (classDictSize - 2)) { if (meth == (longAt(((((char *) methodArray)) + 4) + (i << 2)))) { return longAt(((((char *) classDict)) + 4) + ((i + 2) << 2)); } i += 1; } currClass = longAt(((((char *) currClass)) + 4) + (0 << 2)); done = currClass == nilObj; } return longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)); } int firstAccessibleObject(void) { int obj; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; obj = chunk + extra; while (obj < endOfMemory) { if (!(((longAt(obj)) & 3) == 2)) { return obj; } /* begin objectAfter: */ if (checkAssertions) { if (obj >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(obj)) & 3) == 2) { sz = (longAt(obj)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(obj); if ((header & 3) == 0) { sz = (longAt(obj - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(obj + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; obj = (obj + sz) + extra2; } error("heap is empty"); } int firstObject(void) { int chunk; int extra; int type; int extra1; /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; return chunk + extra; } int fixedFieldsOfformatlength(int oop, int fmt, int wordLength) { int classFormat; int class; int ccIndex; if ((fmt > 3) || (fmt == 2)) { return 0; } if (fmt < 2) { return wordLength; } /* begin fetchClassOf: */ if ((oop & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(oop))) >> 12) & 31) - 1; if (ccIndex < 0) { class = (longAt(oop - 4)) & 4294967292U; goto l1; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; return (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; } double floatValueOf(int oop) { double result; int ccIndex; int cl; /* begin assertClassOf:is: */ if ((oop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(oop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { fetchFloatAtinto(oop + 4, result); } else { result = 0.0; } return result; } int flushMethodCache(void) { int i; for (i = 1; i <= 2048; i += 1) { methodCache[i] = 0; } mcProbe = 0; } int formatOf(int oop) { return (((unsigned) (longAt(oop))) >> 8) & 15; } int formatOfClass(int classPointer) { return (longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1; } int fullCompaction(void) { compStart = lowestFreeAfter(startOfMemory()); if (compStart == freeBlock) { return initializeMemoryFirstFree(freeBlock); } while (compStart < freeBlock) { compStart = incCompBody(); } } int fullDisplayUpdate(void) { int displayObj; int dispBits; int dispBitsIndex; int h; int w; int d; displayObj = longAt(((((char *) specialObjectsOop)) + 4) + (14 << 2)); if ((((((unsigned) (longAt(displayObj))) >> 8) & 15) <= 4) && ((lengthOf(displayObj)) >= 4)) { dispBits = longAt(((((char *) displayObj)) + 4) + (0 << 2)); w = fetchIntegerofObject(1, displayObj); h = fetchIntegerofObject(2, displayObj); d = fetchIntegerofObject(3, displayObj); dispBitsIndex = dispBits + 4; ioShowDisplay(dispBitsIndex, w, h, d, 0, w, 0, h); } } int fullGC(void) { int startTime; int oop; int i; /* begin preGCAction: */ startTime = ioMicroMSecs(); /* begin clearRootsTable */ for (i = 1; i <= rootTableCount; i += 1) { oop = rootTable[i]; longAtput(oop, (longAt(oop)) & 3221225471U); rootTable[i] = 0; } rootTableCount = 0; youngStart = startOfMemory(); markPhase(); sweepPhase(); /* begin fullCompaction */ compStart = lowestFreeAfter(startOfMemory()); if (compStart == freeBlock) { initializeMemoryFirstFree(freeBlock); goto l1; } while (compStart < freeBlock) { compStart = incCompBody(); } l1: /* end fullCompaction */; allocationCount = 0; statFullGCs += 1; statFullGCMSecs += (ioMicroMSecs()) - startTime; youngStart = freeBlock; /* begin postGCAction */ if (activeContext < youngStart) { beRootIfOld(activeContext); } if (theHomeContext < youngStart) { beRootIfOld(theHomeContext); } } int fwdBlockGet(void) { fwdTableNext += 8; if (fwdTableNext <= fwdTableLast) { return fwdTableNext; } else { return null; } } int fwdBlockValidate(int addr) { if (!((addr > endOfMemory) && ((addr <= fwdTableNext) && ((addr & 3) == 0)))) { error("invalid fwd table entry"); } } int fwdTableInit(void) { /* begin setSizeOfFree:to: */ longAtput(freeBlock, (4 & 536870908) | 2); endOfMemory = freeBlock + 4; /* begin setSizeOfFree:to: */ longAtput(endOfMemory, (4 & 536870908) | 2); fwdTableNext = endOfMemory + 4; fwdTableLast = memoryLimit - 8; if (checkAssertions && ((fwdTableLast & 2147483648U) != 0)) { error("fwd table must be in low half of the 32-bit address space"); } return ((int) (fwdTableLast - fwdTableNext) >> 3); } int getCurrentBytecode(void) { return byteAt(instructionPointer); } int getLongFromFileswap(sqImageFile f, int swapFlag) { int w; sqImageFileRead(&w, sizeof(char), 4, f); if (swapFlag) { return ((((((unsigned) w >> 24)) & 255) + ((((unsigned) w >> 8)) & 65280)) + ((((unsigned) w << 8)) & 16711680)) + ((((unsigned) w << 24)) & 4278190080U); } else { return w; } } int hashBitsOf(int oop) { return (((unsigned) (longAt(oop))) >> 17) & 4095; } int headerOf(int methodPointer) { return longAt(((((char *) methodPointer)) + 4) + (0 << 2)); } int headerType(int oop) { return (longAt(oop)) & 3; } int ignoreSourceOrHalftone(int formPointer) { if (formPointer == nilObj) { return true; } if (combinationRule == 0) { return true; } if (combinationRule == 5) { return true; } if (combinationRule == 10) { return true; } if (combinationRule == 15) { return true; } return false; } int imageFormatVersion(void) { return 6502; } int incCompBody(void) { int bytesFreed; int fwdBlock; int oop; int bytesFreed1; int newOop; int extra; int type; int extra1; int originalHeader; int originalHeaderType; int extra2; int type1; int extra11; int sz; int header; int newOop1; int newFreeChunk; int next; int bytesToMove; int w; int fwdBlock1; int oop1; int firstWord; int lastWord; int header1; int extra3; int type2; int extra12; int extra21; int type11; int extra111; int sz2; int fwdBlock2; int realHeader; int header2; int extra4; int type3; int extra13; int sz1; int header11; int extra22; int type12; int extra112; int sz3; int fwdBlock3; int realHeader1; int header3; int extra5; int type4; int extra14; int sz11; int header12; int extra23; int type13; int extra113; fwdTableInit(); /* begin incCompMakeFwd */ bytesFreed1 = 0; /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(compStart)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = compStart + extra2; while (oop < endOfMemory) { if (((longAt(oop)) & 3) == 2) { bytesFreed1 += (longAt(oop)) & 536870908; } else { /* begin fwdBlockGet */ fwdTableNext += 8; if (fwdTableNext <= fwdTableLast) { fwdBlock = fwdTableNext; goto l1; } else { fwdBlock = null; goto l1; } l1: /* end fwdBlockGet */; if (fwdBlock == null) { /* begin chunkFromOop: */ /* begin extraHeaderBytes: */ type = (longAt(oop)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; compEnd = oop - extra; bytesFreed = bytesFreed1; goto l2; } newOop = oop - bytesFreed1; /* begin initForwardBlock:mapping:to: */ originalHeader = longAt(oop); if (checkAssertions) { if (fwdBlock == null) { error("ran out of forwarding blocks in become"); } if ((originalHeader & 2147483648U) != 0) { error("object already has a forwarding table entry"); } } originalHeaderType = originalHeader & 3; longAtput(fwdBlock, newOop); longAtput(fwdBlock + 4, originalHeader); longAtput(oop, fwdBlock | (2147483648U | originalHeaderType)); } /* begin objectAfterWhileForwarding: */ header2 = longAt(oop); if ((header2 & 2147483648U) == 0) { /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz1 = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header11 = longAt(oop); if ((header11 & 3) == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; goto l4; } else { sz1 = header11 & 252; goto l4; } l4: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type12 = (longAt(oop + sz1)) & 3; if (type12 > 1) { extra112 = 0; } else { if (type12 == 1) { extra112 = 4; } else { extra112 = 8; } } extra22 = extra112; oop = (oop + sz1) + extra22; goto l5; } fwdBlock2 = header2 & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock2 > endOfMemory) && ((fwdBlock2 <= fwdTableNext) && ((fwdBlock2 & 3) == 0)))) { error("invalid fwd table entry"); } } realHeader = longAt(fwdBlock2 + 4); if ((realHeader & 3) == 0) { sz2 = (longAt(oop - 8)) & 268435452; } else { sz2 = realHeader & 252; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type3 = (longAt(oop + sz2)) & 3; if (type3 > 1) { extra13 = 0; } else { if (type3 == 1) { extra13 = 4; } else { extra13 = 8; } } extra4 = extra13; oop = (oop + sz2) + extra4; l5: /* end objectAfterWhileForwarding: */; } compEnd = endOfMemory; bytesFreed = bytesFreed1; l2: /* end incCompMakeFwd */; mapPointersInObjectsFromto(youngStart, endOfMemory); /* begin incCompMove: */ newOop1 = null; /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type11 = (longAt(compStart)) & 3; if (type11 > 1) { extra111 = 0; } else { if (type11 == 1) { extra111 = 4; } else { extra111 = 8; } } extra21 = extra111; oop1 = compStart + extra21; while (oop1 < compEnd) { /* begin objectAfterWhileForwarding: */ header3 = longAt(oop1); if ((header3 & 2147483648U) == 0) { /* begin objectAfter: */ if (checkAssertions) { if (oop1 >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop1)) & 3) == 2) { sz11 = (longAt(oop1)) & 536870908; } else { /* begin sizeBitsOf: */ header12 = longAt(oop1); if ((header12 & 3) == 0) { sz11 = (longAt(oop1 - 8)) & 4294967292U; goto l6; } else { sz11 = header12 & 252; goto l6; } l6: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type13 = (longAt(oop1 + sz11)) & 3; if (type13 > 1) { extra113 = 0; } else { if (type13 == 1) { extra113 = 4; } else { extra113 = 8; } } extra23 = extra113; next = (oop1 + sz11) + extra23; goto l7; } fwdBlock3 = header3 & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock3 > endOfMemory) && ((fwdBlock3 <= fwdTableNext) && ((fwdBlock3 & 3) == 0)))) { error("invalid fwd table entry"); } } realHeader1 = longAt(fwdBlock3 + 4); if ((realHeader1 & 3) == 0) { sz3 = (longAt(oop1 - 8)) & 268435452; } else { sz3 = realHeader1 & 252; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type4 = (longAt(oop1 + sz3)) & 3; if (type4 > 1) { extra14 = 0; } else { if (type4 == 1) { extra14 = 4; } else { extra14 = 8; } } extra5 = extra14; next = (oop1 + sz3) + extra5; l7: /* end objectAfterWhileForwarding: */; if (!(((longAt(oop1)) & 3) == 2)) { fwdBlock1 = (longAt(oop1)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock1 > endOfMemory) && ((fwdBlock1 <= fwdTableNext) && ((fwdBlock1 & 3) == 0)))) { error("invalid fwd table entry"); } } newOop1 = longAt(fwdBlock1); header = longAt(fwdBlock1 + 4); longAtput(oop1, header); bytesToMove = oop1 - newOop1; /* begin sizeBitsOf: */ header1 = longAt(oop1); if ((header1 & 3) == 0) { sz = (longAt(oop1 - 8)) & 4294967292U; goto l3; } else { sz = header1 & 252; goto l3; } l3: /* end sizeBitsOf: */; firstWord = oop1 - (extraHeaderBytes(oop1)); lastWord = (oop1 + sz) - 4; for (w = firstWord; w <= lastWord; w += 4) { longAtput(w - bytesToMove, longAt(w)); } } oop1 = next; } if (newOop1 == null) { /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type2 = (longAt(compStart)) & 3; if (type2 > 1) { extra12 = 0; } else { if (type2 == 1) { extra12 = 4; } else { extra12 = 8; } } extra3 = extra12; oop1 = compStart + extra3; if ((((longAt(oop1)) & 3) == 2) && ((objectAfter(oop1)) == (oopFromChunk(compEnd)))) { newFreeChunk = oop1; } else { newFreeChunk = freeBlock; } } else { newFreeChunk = newOop1 + (sizeBitsOf(newOop1)); /* begin setSizeOfFree:to: */ longAtput(newFreeChunk, (bytesFreed & 536870908) | 2); } if (checkAssertions) { if (!((objectAfter(newFreeChunk)) == (oopFromChunk(compEnd)))) { error("problem creating free chunk after compaction"); } } if ((objectAfter(newFreeChunk)) == endOfMemory) { initializeMemoryFirstFree(newFreeChunk); } else { initializeMemoryFirstFree(freeBlock); } return newFreeChunk; } int incCompMakeFwd(void) { int fwdBlock; int oop; int bytesFreed; int newOop; int extra; int type; int extra1; int originalHeader; int originalHeaderType; int extra2; int type1; int extra11; int sz; int fwdBlock1; int realHeader; int header; int extra3; int type2; int extra12; int sz1; int header1; int extra21; int type11; int extra111; bytesFreed = 0; /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(compStart)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = compStart + extra2; while (oop < endOfMemory) { if (((longAt(oop)) & 3) == 2) { bytesFreed += (longAt(oop)) & 536870908; } else { /* begin fwdBlockGet */ fwdTableNext += 8; if (fwdTableNext <= fwdTableLast) { fwdBlock = fwdTableNext; goto l1; } else { fwdBlock = null; goto l1; } l1: /* end fwdBlockGet */; if (fwdBlock == null) { /* begin chunkFromOop: */ /* begin extraHeaderBytes: */ type = (longAt(oop)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; compEnd = oop - extra; return bytesFreed; } newOop = oop - bytesFreed; /* begin initForwardBlock:mapping:to: */ originalHeader = longAt(oop); if (checkAssertions) { if (fwdBlock == null) { error("ran out of forwarding blocks in become"); } if ((originalHeader & 2147483648U) != 0) { error("object already has a forwarding table entry"); } } originalHeaderType = originalHeader & 3; longAtput(fwdBlock, newOop); longAtput(fwdBlock + 4, originalHeader); longAtput(oop, fwdBlock | (2147483648U | originalHeaderType)); } /* begin objectAfterWhileForwarding: */ header = longAt(oop); if ((header & 2147483648U) == 0) { /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz1 = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header1 = longAt(oop); if ((header1 & 3) == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; goto l2; } else { sz1 = header1 & 252; goto l2; } l2: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type11 = (longAt(oop + sz1)) & 3; if (type11 > 1) { extra111 = 0; } else { if (type11 == 1) { extra111 = 4; } else { extra111 = 8; } } extra21 = extra111; oop = (oop + sz1) + extra21; goto l3; } fwdBlock1 = header & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock1 > endOfMemory) && ((fwdBlock1 <= fwdTableNext) && ((fwdBlock1 & 3) == 0)))) { error("invalid fwd table entry"); } } realHeader = longAt(fwdBlock1 + 4); if ((realHeader & 3) == 0) { sz = (longAt(oop - 8)) & 268435452; } else { sz = realHeader & 252; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type2 = (longAt(oop + sz)) & 3; if (type2 > 1) { extra12 = 0; } else { if (type2 == 1) { extra12 = 4; } else { extra12 = 8; } } extra3 = extra12; oop = (oop + sz) + extra3; l3: /* end objectAfterWhileForwarding: */; } compEnd = endOfMemory; return bytesFreed; } int incCompMove(int bytesFreed) { int sz; int header; int newOop; int newFreeChunk; int next; int bytesToMove; int w; int fwdBlock; int oop; int firstWord; int lastWord; int header1; int extra; int type; int extra1; int extra2; int type1; int extra11; int sz2; int fwdBlock1; int realHeader; int header2; int extra3; int type2; int extra12; int sz1; int header11; int extra21; int type11; int extra111; newOop = null; /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(compStart)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = compStart + extra2; while (oop < compEnd) { /* begin objectAfterWhileForwarding: */ header2 = longAt(oop); if ((header2 & 2147483648U) == 0) { /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz1 = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header11 = longAt(oop); if ((header11 & 3) == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; goto l2; } else { sz1 = header11 & 252; goto l2; } l2: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type11 = (longAt(oop + sz1)) & 3; if (type11 > 1) { extra111 = 0; } else { if (type11 == 1) { extra111 = 4; } else { extra111 = 8; } } extra21 = extra111; next = (oop + sz1) + extra21; goto l3; } fwdBlock1 = header2 & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock1 > endOfMemory) && ((fwdBlock1 <= fwdTableNext) && ((fwdBlock1 & 3) == 0)))) { error("invalid fwd table entry"); } } realHeader = longAt(fwdBlock1 + 4); if ((realHeader & 3) == 0) { sz2 = (longAt(oop - 8)) & 268435452; } else { sz2 = realHeader & 252; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type2 = (longAt(oop + sz2)) & 3; if (type2 > 1) { extra12 = 0; } else { if (type2 == 1) { extra12 = 4; } else { extra12 = 8; } } extra3 = extra12; next = (oop + sz2) + extra3; l3: /* end objectAfterWhileForwarding: */; if (!(((longAt(oop)) & 3) == 2)) { fwdBlock = (longAt(oop)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } newOop = longAt(fwdBlock); header = longAt(fwdBlock + 4); longAtput(oop, header); bytesToMove = oop - newOop; /* begin sizeBitsOf: */ header1 = longAt(oop); if ((header1 & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz = header1 & 252; goto l1; } l1: /* end sizeBitsOf: */; firstWord = oop - (extraHeaderBytes(oop)); lastWord = (oop + sz) - 4; for (w = firstWord; w <= lastWord; w += 4) { longAtput(w - bytesToMove, longAt(w)); } } oop = next; } if (newOop == null) { /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type = (longAt(compStart)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; oop = compStart + extra; if ((((longAt(oop)) & 3) == 2) && ((objectAfter(oop)) == (oopFromChunk(compEnd)))) { newFreeChunk = oop; } else { newFreeChunk = freeBlock; } } else { newFreeChunk = newOop + (sizeBitsOf(newOop)); /* begin setSizeOfFree:to: */ longAtput(newFreeChunk, (bytesFreed & 536870908) | 2); } if (checkAssertions) { if (!((objectAfter(newFreeChunk)) == (oopFromChunk(compEnd)))) { error("problem creating free chunk after compaction"); } } if ((objectAfter(newFreeChunk)) == endOfMemory) { initializeMemoryFirstFree(newFreeChunk); } else { initializeMemoryFirstFree(freeBlock); } return newFreeChunk; } int incrementalCompaction(void) { if (compStart == freeBlock) { initializeMemoryFirstFree(freeBlock); } else { incCompBody(); } } int incrementalGC(void) { int startTime; int survivorCount; int oop; int i; if (rootTableCount >= 1000) { statRootTableOverflows += 1; return fullGC(); } /* begin preGCAction: */ startTime = ioMicroMSecs(); markPhase(); survivorCount = sweepPhase(); /* begin incrementalCompaction */ if (compStart == freeBlock) { initializeMemoryFirstFree(freeBlock); } else { incCompBody(); } allocationCount = 0; statIncrGCs += 1; statIncrGCMSecs += (ioMicroMSecs()) - startTime; if (survivorCount > tenuringThreshold) { statTenures += 1; /* begin clearRootsTable */ for (i = 1; i <= rootTableCount; i += 1) { oop = rootTable[i]; longAtput(oop, (longAt(oop)) & 3221225471U); rootTable[i] = 0; } rootTableCount = 0; youngStart = freeBlock; } /* begin postGCAction */ if (activeContext < youngStart) { beRootIfOld(activeContext); } if (theHomeContext < youngStart) { beRootIfOld(theHomeContext); } } int initBBOpTable(void) { opTable[0+1] = (int)clearWordwith; opTable[1+1] = (int)bitAndwith; opTable[2+1] = (int)bitAndInvertwith; opTable[3+1] = (int)sourceWordwith; opTable[4+1] = (int)bitInvertAndwith; opTable[5+1] = (int)destinationWordwith; opTable[6+1] = (int)bitXorwith; opTable[7+1] = (int)bitOrwith; opTable[8+1] = (int)bitInvertAndInvertwith; opTable[9+1] = (int)bitInvertXorwith; opTable[10+1] = (int)bitInvertDestinationwith; opTable[11+1] = (int)bitOrInvertwith; opTable[12+1] = (int)bitInvertSourcewith; opTable[13+1] = (int)bitInvertOrwith; opTable[14+1] = (int)bitInvertOrInvertwith; opTable[15+1] = (int)destinationWordwith; opTable[16+1] = (int)destinationWordwith; opTable[17+1] = (int)destinationWordwith; opTable[18+1] = (int)addWordwith; opTable[19+1] = (int)subWordwith; opTable[20+1] = (int)rgbAddwith; opTable[21+1] = (int)rgbSubwith; opTable[22+1] = (int)OLDrgbDiffwith; opTable[23+1] = (int)OLDtallyIntoMapwith; opTable[24+1] = (int)alphaBlendwith; opTable[25+1] = (int)pixPaintwith; opTable[26+1] = (int)pixMaskwith; opTable[27+1] = (int)rgbMaxwith; opTable[28+1] = (int)rgbMinwith; opTable[29+1] = (int)rgbMinInvertwith; opTable[30+1] = (int)alphaBlendConstwith; opTable[31+1] = (int)alphaPaintConstwith; opTable[32+1] = (int)rgbDiffwith; opTable[33+1] = (int)tallyIntoMapwith; } int initForwardBlockmappingto(int fwdBlock, int oop, int newOop) { int originalHeader; int originalHeaderType; originalHeader = longAt(oop); if (checkAssertions) { if (fwdBlock == null) { error("ran out of forwarding blocks in become"); } if ((originalHeader & 2147483648U) != 0) { error("object already has a forwarding table entry"); } } originalHeaderType = originalHeader & 3; longAtput(fwdBlock, newOop); longAtput(fwdBlock + 4, originalHeader); longAtput(oop, fwdBlock | (2147483648U | originalHeaderType)); } int initialInstanceOf(int classPointer) { int thisClass; int thisObj; int ccIndex; int obj; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; /* begin firstAccessibleObject */ /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; obj = chunk + extra; while (obj < endOfMemory) { if (!(((longAt(obj)) & 3) == 2)) { thisObj = obj; goto l3; } /* begin objectAfter: */ if (checkAssertions) { if (obj >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(obj)) & 3) == 2) { sz = (longAt(obj)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(obj); if ((header & 3) == 0) { sz = (longAt(obj - 8)) & 4294967292U; goto l2; } else { sz = header & 252; goto l2; } l2: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(obj + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; obj = (obj + sz) + extra2; } error("heap is empty"); l3: /* end firstAccessibleObject */; while (!(thisObj == null)) { /* begin fetchClassOf: */ if ((thisObj & 1)) { thisClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(thisObj))) >> 12) & 31) - 1; if (ccIndex < 0) { thisClass = (longAt(thisObj - 4)) & 4294967292U; goto l1; } else { thisClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; if (thisClass == classPointer) { return thisObj; } thisObj = accessibleObjectAfter(thisObj); } return nilObj; } int initializeInterpreter(int bytesToShift) { int i; int sched; int proc; int activeCntx; int tmp; initializeObjectMemory(bytesToShift); initBBOpTable(); activeContext = nilObj; theHomeContext = nilObj; method = nilObj; receiver = nilObj; messageSelector = nilObj; newMethod = nilObj; /* begin flushMethodCache */ for (i = 1; i <= 2048; i += 1) { methodCache[i] = 0; } mcProbe = 0; /* begin loadInitialContext */ sched = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); proc = longAt(((((char *) sched)) + 4) + (1 << 2)); activeContext = longAt(((((char *) proc)) + 4) + (1 << 2)); if (activeContext < youngStart) { beRootIfOld(activeContext); } /* begin fetchContextRegisters: */ activeCntx = activeContext; tmp = longAt(((((char *) activeCntx)) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) activeCntx)) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = activeCntx; } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) activeCntx)) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) activeCntx)) + 4) + (2 << 2))) >> 1); stackPointer = (activeCntx + 4) + (((6 + tmp) - 1) * 4); reclaimableContextCount = 0; interruptCheckCounter = 0; nextPollTick = 0; nextWakeupTick = 0; lastTick = 0; interruptKeycode = 2094; interruptPending = false; semaphoresToSignalCount = 0; deferDisplayUpdates = false; } int initializeMemoryFirstFree(int firstFree) { int fwdBlockBytes; fwdBlockBytes = 16000; if (!((memoryLimit - fwdBlockBytes) >= (firstFree + 4))) { fwdBlockBytes = memoryLimit - (firstFree + 4); } endOfMemory = memoryLimit - fwdBlockBytes; freeBlock = firstFree; /* begin setSizeOfFree:to: */ longAtput(freeBlock, ((endOfMemory - firstFree) & 536870908) | 2); /* begin setSizeOfFree:to: */ longAtput(endOfMemory, (4 & 536870908) | 2); if (checkAssertions) { if (!((freeBlock < endOfMemory) && (endOfMemory < memoryLimit))) { error("error in free space computation"); } if (!((oopFromChunk(endOfMemory)) == endOfMemory)) { error("header format must have changed"); } if (!((objectAfter(freeBlock)) == endOfMemory)) { error("free block not properly initialized"); } } } int initializeObjectMemory(int bytesToShift) { int oop; int last; int newClassOop; int fieldAddr; int fieldOop; int classHeader; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; checkAssertions = false; youngStart = endOfMemory; initializeMemoryFirstFree(endOfMemory); /* begin adjustAllOopsBy: */ if (bytesToShift == 0) { goto l2; } /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; oop = chunk + extra; while (oop < endOfMemory) { if (!(((longAt(oop)) & 3) == 2)) { /* begin adjustFieldsAndClassOf:by: */ fieldAddr = oop + (lastPointerOf(oop)); while (fieldAddr > oop) { fieldOop = longAt(fieldAddr); if (!((fieldOop & 1))) { longAtput(fieldAddr, fieldOop + bytesToShift); } fieldAddr -= 4; } if (((longAt(oop)) & 3) != 3) { classHeader = longAt(oop - 4); newClassOop = (classHeader & 4294967292U) + bytesToShift; longAtput(oop - 4, newClassOop | (classHeader & 3)); } } last = oop; /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(oop + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = (oop + sz) + extra2; } l2: /* end adjustAllOopsBy: */; specialObjectsOop += bytesToShift; nilObj = longAt(((((char *) specialObjectsOop)) + 4) + (0 << 2)); falseObj = longAt(((((char *) specialObjectsOop)) + 4) + (1 << 2)); trueObj = longAt(((((char *) specialObjectsOop)) + 4) + (2 << 2)); rootTableCount = 0; child = 0; field = 0; parentField = 0; freeLargeContexts = 1; freeSmallContexts = 1; allocationCount = 0; lowSpaceThreshold = 0; signalLowSpace = false; compStart = 0; compEnd = 0; fwdTableNext = 0; fwdTableLast = 0; remapBufferCount = 0; allocationsBetweenGCs = 4000; tenuringThreshold = 2000; statFullGCs = 0; statFullGCMSecs = 0; statIncrGCs = 0; statIncrGCMSecs = 0; statTenures = 0; statRootTableOverflows = 0; displayBits = 0; } int instanceAfter(int objectPointer) { int thisClass; int classPointer; int thisObj; int ccIndex; int ccIndex1; /* begin fetchClassOf: */ if ((objectPointer & 1)) { classPointer = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l2; } ccIndex1 = ((((unsigned) (longAt(objectPointer))) >> 12) & 31) - 1; if (ccIndex1 < 0) { classPointer = (longAt(objectPointer - 4)) & 4294967292U; goto l2; } else { classPointer = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex1 << 2)); goto l2; } l2: /* end fetchClassOf: */; thisObj = accessibleObjectAfter(objectPointer); while (!(thisObj == null)) { /* begin fetchClassOf: */ if ((thisObj & 1)) { thisClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(thisObj))) >> 12) & 31) - 1; if (ccIndex < 0) { thisClass = (longAt(thisObj - 4)) & 4294967292U; goto l1; } else { thisClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; if (thisClass == classPointer) { return thisObj; } thisObj = accessibleObjectAfter(thisObj); } return nilObj; } int instantiateClassindexableSize(int classPointer, int size) { int sizeHiBits; int newObj; int binc; int hash; int header1; int header2; int header3; int hdrSize; int byteSize; int format; int inc; int cClass; int fillWord; int i; int newObj1; int remappedClassOop; int end; int oop; int newFreeSize; int enoughSpace; int newChunk; int minFree; if (checkAssertions) { if (size < 0) { error("cannot have a negative indexable field count"); } } /* begin newObjectHash */ lastHash = (13849 + (27181 * lastHash)) & 65535; hash = lastHash; header1 = (longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1; sizeHiBits = ((unsigned) (header1 & 393216)) >> 9; header1 = (header1 & 131071) | ((hash << 17) & 536739840); header2 = classPointer; header3 = 0; cClass = header1 & 126976; byteSize = (header1 & 252) + sizeHiBits; format = (((unsigned) header1) >> 8) & 15; if (format < 8) { inc = size * 4; } else { inc = (size + 3) & 536870908; binc = 3 - ((size + 3) & 3); header1 = header1 | (binc << 8); } if ((byteSize + inc) > 255) { header3 = byteSize + inc; header1 -= byteSize & 255; } else { header1 += inc; } byteSize += inc; if (header3 > 0) { hdrSize = 3; } else { if (cClass == 0) { hdrSize = 2; } else { hdrSize = 1; } } if (format < 4) { fillWord = nilObj; } else { fillWord = 0; } /* begin allocate:headerSize:h1:h2:h3:fill: */ if (hdrSize > 1) { /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = header2; } /* begin allocateChunk: */ if (allocationCount >= allocationsBetweenGCs) { incrementalGC(); } /* begin sufficientSpaceToAllocate: */ minFree = (lowSpaceThreshold + (byteSize + ((hdrSize - 1) * 4))) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { enoughSpace = true; goto l1; } else { enoughSpace = sufficientSpaceAfterGC(minFree); goto l1; } l1: /* end sufficientSpaceToAllocate: */; if (!(enoughSpace)) { signalLowSpace = true; lowSpaceThreshold = 0; interruptCheckCounter = 0; } if (((longAt(freeBlock)) & 536870908) < ((byteSize + ((hdrSize - 1) * 4)) + 4)) { error("out of memory"); } newFreeSize = ((longAt(freeBlock)) & 536870908) - (byteSize + ((hdrSize - 1) * 4)); newChunk = freeBlock; freeBlock += byteSize + ((hdrSize - 1) * 4); /* begin setSizeOfFree:to: */ longAtput(freeBlock, (newFreeSize & 536870908) | 2); allocationCount += 1; newObj1 = newChunk; if (hdrSize > 1) { /* begin popRemappableOop */ oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; remappedClassOop = oop; } if (hdrSize == 3) { longAtput(newObj1, header3 | 0); longAtput(newObj1 + 4, remappedClassOop | 0); longAtput(newObj1 + 8, header1 | 0); newObj1 += 8; } if (hdrSize == 2) { longAtput(newObj1, remappedClassOop | 1); longAtput(newObj1 + 4, header1 | 1); newObj1 += 4; } if (hdrSize == 1) { longAtput(newObj1, header1 | 3); } end = newObj1 + byteSize; i = newObj1 + 4; while (i < end) { longAtput(i, fillWord); i += 4; } if (checkAssertions) { okayOop(newObj1); oopHasOkayClass(newObj1); if (!((objectAfter(newObj1)) == freeBlock)) { error("allocate bug: did not set header of new oop correctly"); } if (!((objectAfter(freeBlock)) == endOfMemory)) { error("allocate bug: did not set header of freeBlock correctly"); } } newObj = newObj1; return newObj; } int instantiateSmallClasssizeInBytesfill(int classPointer, int sizeInBytes, int fillValue) { int header1; int header2; int hdrSize; int hash; int i; int newObj; int remappedClassOop; int end; int oop; int newFreeSize; int enoughSpace; int newChunk; int minFree; /* begin newObjectHash */ lastHash = (13849 + (27181 * lastHash)) & 65535; hash = lastHash; header1 = ((hash << 17) & 536739840) | ((longAt(((((char *) classPointer)) + 4) + (2 << 2))) - 1); header1 += sizeInBytes - (header1 & 252); header2 = classPointer; if ((header1 & 126976) == 0) { hdrSize = 2; } else { hdrSize = 1; } /* begin allocate:headerSize:h1:h2:h3:fill: */ if (hdrSize > 1) { /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = header2; } /* begin allocateChunk: */ if (allocationCount >= allocationsBetweenGCs) { incrementalGC(); } /* begin sufficientSpaceToAllocate: */ minFree = (lowSpaceThreshold + (sizeInBytes + ((hdrSize - 1) * 4))) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { enoughSpace = true; goto l1; } else { enoughSpace = sufficientSpaceAfterGC(minFree); goto l1; } l1: /* end sufficientSpaceToAllocate: */; if (!(enoughSpace)) { signalLowSpace = true; lowSpaceThreshold = 0; interruptCheckCounter = 0; } if (((longAt(freeBlock)) & 536870908) < ((sizeInBytes + ((hdrSize - 1) * 4)) + 4)) { error("out of memory"); } newFreeSize = ((longAt(freeBlock)) & 536870908) - (sizeInBytes + ((hdrSize - 1) * 4)); newChunk = freeBlock; freeBlock += sizeInBytes + ((hdrSize - 1) * 4); /* begin setSizeOfFree:to: */ longAtput(freeBlock, (newFreeSize & 536870908) | 2); allocationCount += 1; newObj = newChunk; if (hdrSize > 1) { /* begin popRemappableOop */ oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; remappedClassOop = oop; } if (hdrSize == 3) { longAtput(newObj, 0 | 0); longAtput(newObj + 4, remappedClassOop | 0); longAtput(newObj + 8, header1 | 0); newObj += 8; } if (hdrSize == 2) { longAtput(newObj, remappedClassOop | 1); longAtput(newObj + 4, header1 | 1); newObj += 4; } if (hdrSize == 1) { longAtput(newObj, header1 | 3); } end = newObj + sizeInBytes; i = newObj + 4; while (i < end) { longAtput(i, fillValue); i += 4; } if (checkAssertions) { okayOop(newObj); oopHasOkayClass(newObj); if (!((objectAfter(newObj)) == freeBlock)) { error("allocate bug: did not set header of new oop correctly"); } if (!((objectAfter(freeBlock)) == endOfMemory)) { error("allocate bug: did not set header of freeBlock correctly"); } } return newObj; } int intToNetAddress(int addr) { int netAddressOop; netAddressOop = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)), 8, 0); byteAtput(((((char *) netAddressOop)) + 4) + 0, (((unsigned) addr) >> 24) & 255); byteAtput(((((char *) netAddressOop)) + 4) + 1, (((unsigned) addr) >> 16) & 255); byteAtput(((((char *) netAddressOop)) + 4) + 2, (((unsigned) addr) >> 8) & 255); byteAtput(((((char *) netAddressOop)) + 4) + 3, addr & 255); return netAddressOop; } int integerObjectOf(int value) { if (value < 0) { return ((2147483648U + value) << 1) + 1; } else { return (value << 1) + 1; } } int integerValueOf(int objectPointer) { if ((objectPointer & 2147483648U) != 0) { return ((((unsigned) (objectPointer & 2147483647U)) >> 1) - 1073741823) - 1; } else { return ((unsigned) objectPointer) >> 1; } } int interpret(void) { int localTP; int localCP; char * localSP; char * localIP; int currentBytecode; int t1; int t2; int t3; int t4; int t5; int t6; int t7; int t8; int t9; int t10; int t11; int t12; int t13; int t14; int t15; int t16; int t17; int t18; int t19; int t20; int t21; /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); while (true) { currentBytecode = byteAt(++localIP); switch (currentBytecode) { case 0: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((0 & 15) << 2))); break; case 1: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((1 & 15) << 2))); break; case 2: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((2 & 15) << 2))); break; case 3: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((3 & 15) << 2))); break; case 4: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((4 & 15) << 2))); break; case 5: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((5 & 15) << 2))); break; case 6: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((6 & 15) << 2))); break; case 7: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((7 & 15) << 2))); break; case 8: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((8 & 15) << 2))); break; case 9: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((9 & 15) << 2))); break; case 10: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((10 & 15) << 2))); break; case 11: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((11 & 15) << 2))); break; case 12: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((12 & 15) << 2))); break; case 13: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((13 & 15) << 2))); break; case 14: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((14 & 15) << 2))); break; case 15: /* pushReceiverVariableBytecode */ /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + ((15 & 15) << 2))); break; case 16: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((16 & 15) + 6) << 2))); break; case 17: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((17 & 15) + 6) << 2))); break; case 18: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((18 & 15) + 6) << 2))); break; case 19: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((19 & 15) + 6) << 2))); break; case 20: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((20 & 15) + 6) << 2))); break; case 21: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((21 & 15) + 6) << 2))); break; case 22: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((22 & 15) + 6) << 2))); break; case 23: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((23 & 15) + 6) << 2))); break; case 24: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((24 & 15) + 6) << 2))); break; case 25: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((25 & 15) + 6) << 2))); break; case 26: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((26 & 15) + 6) << 2))); break; case 27: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((27 & 15) + 6) << 2))); break; case 28: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((28 & 15) + 6) << 2))); break; case 29: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((29 & 15) + 6) << 2))); break; case 30: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((30 & 15) + 6) << 2))); break; case 31: /* pushTemporaryVariableBytecode */ /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + (((31 & 15) + 6) << 2))); break; case 32: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((32 & 31) + 1) << 2))); break; case 33: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((33 & 31) + 1) << 2))); break; case 34: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((34 & 31) + 1) << 2))); break; case 35: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((35 & 31) + 1) << 2))); break; case 36: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((36 & 31) + 1) << 2))); break; case 37: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((37 & 31) + 1) << 2))); break; case 38: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((38 & 31) + 1) << 2))); break; case 39: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((39 & 31) + 1) << 2))); break; case 40: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((40 & 31) + 1) << 2))); break; case 41: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((41 & 31) + 1) << 2))); break; case 42: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((42 & 31) + 1) << 2))); break; case 43: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((43 & 31) + 1) << 2))); break; case 44: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((44 & 31) + 1) << 2))); break; case 45: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((45 & 31) + 1) << 2))); break; case 46: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((46 & 31) + 1) << 2))); break; case 47: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((47 & 31) + 1) << 2))); break; case 48: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((48 & 31) + 1) << 2))); break; case 49: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((49 & 31) + 1) << 2))); break; case 50: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((50 & 31) + 1) << 2))); break; case 51: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((51 & 31) + 1) << 2))); break; case 52: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((52 & 31) + 1) << 2))); break; case 53: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((53 & 31) + 1) << 2))); break; case 54: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((54 & 31) + 1) << 2))); break; case 55: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((55 & 31) + 1) << 2))); break; case 56: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((56 & 31) + 1) << 2))); break; case 57: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((57 & 31) + 1) << 2))); break; case 58: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((58 & 31) + 1) << 2))); break; case 59: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((59 & 31) + 1) << 2))); break; case 60: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((60 & 31) + 1) << 2))); break; case 61: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((61 & 31) + 1) << 2))); break; case 62: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((62 & 31) + 1) << 2))); break; case 63: /* pushLiteralConstantBytecode */ /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + (((63 & 31) + 1) << 2))); break; case 64: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((64 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 65: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((65 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 66: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((66 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 67: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((67 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 68: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((68 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 69: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((69 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 70: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((70 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 71: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((71 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 72: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((72 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 73: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((73 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 74: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((74 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 75: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((75 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 76: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((76 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 77: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((77 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 78: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((78 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 79: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((79 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 80: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((80 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 81: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((81 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 82: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((82 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 83: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((83 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 84: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((84 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 85: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((85 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 86: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((86 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 87: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((87 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 88: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((88 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 89: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((89 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 90: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((90 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 91: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((91 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 92: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((92 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 93: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((93 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 94: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((94 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 95: /* pushLiteralVariableBytecode */ /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + (((95 & 31) + 1) << 2))))) + 4) + (1 << 2))); break; case 96: /* storeAndPopReceiverVariableBytecode */ t2 = receiver; t1 = longAt(localSP); if (t2 < youngStart) { possibleRootStoreIntovalue(t2, t1); } longAtput(((((char *) t2)) + 4) + ((96 & 7) << 2), t1); /* begin internalPop: */ localSP -= 1 * 4; break; case 97: /* storeAndPopReceiverVariableBytecode */ t2 = receiver; t1 = longAt(localSP); if (t2 < youngStart) { possibleRootStoreIntovalue(t2, t1); } longAtput(((((char *) t2)) + 4) + ((97 & 7) << 2), t1); /* begin internalPop: */ localSP -= 1 * 4; break; case 98: /* storeAndPopReceiverVariableBytecode */ t2 = receiver; t1 = longAt(localSP); if (t2 < youngStart) { possibleRootStoreIntovalue(t2, t1); } longAtput(((((char *) t2)) + 4) + ((98 & 7) << 2), t1); /* begin internalPop: */ localSP -= 1 * 4; break; case 99: /* storeAndPopReceiverVariableBytecode */ t2 = receiver; t1 = longAt(localSP); if (t2 < youngStart) { possibleRootStoreIntovalue(t2, t1); } longAtput(((((char *) t2)) + 4) + ((99 & 7) << 2), t1); /* begin internalPop: */ localSP -= 1 * 4; break; case 100: /* storeAndPopReceiverVariableBytecode */ t2 = receiver; t1 = longAt(localSP); if (t2 < youngStart) { possibleRootStoreIntovalue(t2, t1); } longAtput(((((char *) t2)) + 4) + ((100 & 7) << 2), t1); /* begin internalPop: */ localSP -= 1 * 4; break; case 101: /* storeAndPopReceiverVariableBytecode */ t2 = receiver; t1 = longAt(localSP); if (t2 < youngStart) { possibleRootStoreIntovalue(t2, t1); } longAtput(((((char *) t2)) + 4) + ((101 & 7) << 2), t1); /* begin internalPop: */ localSP -= 1 * 4; break; case 102: /* storeAndPopReceiverVariableBytecode */ t2 = receiver; t1 = longAt(localSP); if (t2 < youngStart) { possibleRootStoreIntovalue(t2, t1); } longAtput(((((char *) t2)) + 4) + ((102 & 7) << 2), t1); /* begin internalPop: */ localSP -= 1 * 4; break; case 103: /* storeAndPopReceiverVariableBytecode */ t2 = receiver; t1 = longAt(localSP); if (t2 < youngStart) { possibleRootStoreIntovalue(t2, t1); } longAtput(((((char *) t2)) + 4) + ((103 & 7) << 2), t1); /* begin internalPop: */ localSP -= 1 * 4; break; case 104: /* storeAndPopTemporaryVariableBytecode */ longAtput(((((char *) theHomeContext)) + 4) + (((104 & 7) + 6) << 2), longAt(localSP)); /* begin internalPop: */ localSP -= 1 * 4; break; case 105: /* storeAndPopTemporaryVariableBytecode */ longAtput(((((char *) theHomeContext)) + 4) + (((105 & 7) + 6) << 2), longAt(localSP)); /* begin internalPop: */ localSP -= 1 * 4; break; case 106: /* storeAndPopTemporaryVariableBytecode */ longAtput(((((char *) theHomeContext)) + 4) + (((106 & 7) + 6) << 2), longAt(localSP)); /* begin internalPop: */ localSP -= 1 * 4; break; case 107: /* storeAndPopTemporaryVariableBytecode */ longAtput(((((char *) theHomeContext)) + 4) + (((107 & 7) + 6) << 2), longAt(localSP)); /* begin internalPop: */ localSP -= 1 * 4; break; case 108: /* storeAndPopTemporaryVariableBytecode */ longAtput(((((char *) theHomeContext)) + 4) + (((108 & 7) + 6) << 2), longAt(localSP)); /* begin internalPop: */ localSP -= 1 * 4; break; case 109: /* storeAndPopTemporaryVariableBytecode */ longAtput(((((char *) theHomeContext)) + 4) + (((109 & 7) + 6) << 2), longAt(localSP)); /* begin internalPop: */ localSP -= 1 * 4; break; case 110: /* storeAndPopTemporaryVariableBytecode */ longAtput(((((char *) theHomeContext)) + 4) + (((110 & 7) + 6) << 2), longAt(localSP)); /* begin internalPop: */ localSP -= 1 * 4; break; case 111: /* storeAndPopTemporaryVariableBytecode */ longAtput(((((char *) theHomeContext)) + 4) + (((111 & 7) + 6) << 2), longAt(localSP)); /* begin internalPop: */ localSP -= 1 * 4; break; case 112: /* pushReceiverBytecode */ /* begin internalPush: */ longAtput(localSP += 4, receiver); break; case 113: /* pushConstantTrueBytecode */ /* begin internalPush: */ longAtput(localSP += 4, trueObj); break; case 114: /* pushConstantFalseBytecode */ /* begin internalPush: */ longAtput(localSP += 4, falseObj); break; case 115: /* pushConstantNilBytecode */ /* begin internalPush: */ longAtput(localSP += 4, nilObj); break; case 116: /* pushConstantMinusOneBytecode */ /* begin internalPush: */ longAtput(localSP += 4, 4294967295U); break; case 117: /* pushConstantZeroBytecode */ /* begin internalPush: */ longAtput(localSP += 4, 1); break; case 118: /* pushConstantOneBytecode */ /* begin internalPush: */ longAtput(localSP += 4, 3); break; case 119: /* pushConstantTwoBytecode */ /* begin internalPush: */ longAtput(localSP += 4, 5); break; case 120: /* returnReceiver */ t2 = longAt(((((char *) theHomeContext)) + 4) + (0 << 2)); t1 = receiver; /* begin returnValue:to: */ commonReturn: /* */; t4 = nilObj; t5 = activeContext; t3 = longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)); if ((t2 == t4) || ((longAt(((((char *) t2)) + 4) + (1 << 2))) == t4)) { /* begin internalPush: */ longAtput(localSP += 4, activeContext); /* begin internalPush: */ longAtput(localSP += 4, t1); messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (21 << 2)); argumentCount = 1; /* begin normalSend */ goto commonSend; l3: /* end fetchClassOf: */; l1: /* end lookupInMethodCacheSel:class: */; } while (!(t5 == t2)) { t6 = longAt(((((char *) t5)) + 4) + (0 << 2)); longAtput(((((char *) t5)) + 4) + (0 << 2), t4); longAtput(((((char *) t5)) + 4) + (1 << 2), t4); if (reclaimableContextCount > 0) { reclaimableContextCount -= 1; /* begin recycleContextIfPossible:methodContextClass: */ if (t5 >= youngStart) { t7 = longAt(t5); t8 = t7 & 126976; if (t8 == 0) { t9 = ((longAt(t5 - 4)) & 4294967292U) == t3; } else { t9 = t8 == (((longAt(((((char *) t3)) + 4) + (2 << 2))) - 1) & 126976); } if (t9) { if ((t7 & 252) == 76) { longAtput(((((char *) t5)) + 4) + (0 << 2), freeSmallContexts); freeSmallContexts = t5; } else { longAtput(((((char *) t5)) + 4) + (0 << 2), freeLargeContexts); freeLargeContexts = t5; } } } } t5 = t6; } activeContext = t5; if (t5 < youngStart) { beRootIfOld(t5); } /* begin internalFetchContextRegisters: */ t10 = longAt(((((char *) t5)) + 4) + (3 << 2)); if ((t10 & 1)) { t10 = longAt(((((char *) t5)) + 4) + (5 << 2)); if (t10 < youngStart) { beRootIfOld(t10); } } else { t10 = t5; } theHomeContext = t10; receiver = longAt(((((char *) t10)) + 4) + (5 << 2)); method = longAt(((((char *) t10)) + 4) + (3 << 2)); t10 = ((longAt(((((char *) t5)) + 4) + (1 << 2))) >> 1); localIP = ((char *) (((method + t10) + 4) - 2)); t10 = ((longAt(((((char *) t5)) + 4) + (2 << 2))) >> 1); localSP = ((char *) ((t5 + 4) + (((6 + t10) - 1) * 4))); /* begin internalPush: */ longAtput(localSP += 4, t1); /* begin internalQuickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); checkForInterrupts(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); } l4: /* end returnValue:to: */; break; case 121: /* returnTrue */ t2 = longAt(((((char *) theHomeContext)) + 4) + (0 << 2)); t1 = trueObj; /* begin returnValue:to: */ goto commonReturn; l8: /* end returnValue:to: */; break; case 122: /* returnFalse */ t2 = longAt(((((char *) theHomeContext)) + 4) + (0 << 2)); t1 = falseObj; /* begin returnValue:to: */ goto commonReturn; l12: /* end returnValue:to: */; break; case 123: /* returnNil */ t2 = longAt(((((char *) theHomeContext)) + 4) + (0 << 2)); t1 = nilObj; /* begin returnValue:to: */ goto commonReturn; l16: /* end returnValue:to: */; break; case 124: /* returnTopFromMethod */ t2 = longAt(((((char *) theHomeContext)) + 4) + (0 << 2)); t1 = longAt(localSP); /* begin returnValue:to: */ goto commonReturn; l20: /* end returnValue:to: */; break; case 125: /* returnTopFromBlock */ t2 = longAt(((((char *) activeContext)) + 4) + (0 << 2)); t1 = longAt(localSP); /* begin returnValue:to: */ goto commonReturn; l24: /* end returnValue:to: */; break; case 126: case 127: /* unknownBytecode */ error("Unknown bytecode"); break; case 128: /* extendedPushBytecode */ t1 = byteAt(++localIP); t2 = (((unsigned) t1) >> 6) & 3; t3 = t1 & 63; if (t2 == 0) { /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + (t3 << 2))); goto l25; } if (t2 == 1) { /* begin pushTemporaryVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) theHomeContext)) + 4) + ((t3 + 6) << 2))); goto l25; } if (t2 == 2) { /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + ((t3 + 1) << 2))); goto l25; } if (t2 == 3) { /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + ((t3 + 1) << 2))))) + 4) + (1 << 2))); goto l25; } l25: /* end case */; break; case 129: /* extendedStoreBytecode */ t1 = byteAt(++localIP); t2 = (((unsigned) t1) >> 6) & 3; t3 = t1 & 63; if (t2 == 0) { /* begin storePointer:ofObject:withValue: */ t5 = receiver; t6 = longAt(localSP); if (t5 < youngStart) { possibleRootStoreIntovalue(t5, t6); } longAtput(((((char *) t5)) + 4) + (t3 << 2), t6); goto l26; } if (t2 == 1) { longAtput(((((char *) theHomeContext)) + 4) + ((t3 + 6) << 2), longAt(localSP)); goto l26; } if (t2 == 2) { error("illegal store"); } if (t2 == 3) { t4 = longAt(((((char *) method)) + 4) + ((t3 + 1) << 2)); /* begin storePointer:ofObject:withValue: */ t7 = longAt(localSP); if (t4 < youngStart) { possibleRootStoreIntovalue(t4, t7); } longAtput(((((char *) t4)) + 4) + (1 << 2), t7); goto l26; } l26: /* end case */; break; case 130: /* extendedStoreAndPopBytecode */ /* begin extendedStoreBytecode */ t1 = byteAt(++localIP); t2 = (((unsigned) t1) >> 6) & 3; t3 = t1 & 63; if (t2 == 0) { /* begin storePointer:ofObject:withValue: */ t5 = receiver; t6 = longAt(localSP); if (t5 < youngStart) { possibleRootStoreIntovalue(t5, t6); } longAtput(((((char *) t5)) + 4) + (t3 << 2), t6); goto l27; } if (t2 == 1) { longAtput(((((char *) theHomeContext)) + 4) + ((t3 + 6) << 2), longAt(localSP)); goto l27; } if (t2 == 2) { error("illegal store"); } if (t2 == 3) { t4 = longAt(((((char *) method)) + 4) + ((t3 + 1) << 2)); /* begin storePointer:ofObject:withValue: */ t7 = longAt(localSP); if (t4 < youngStart) { possibleRootStoreIntovalue(t4, t7); } longAtput(((((char *) t4)) + 4) + (1 << 2), t7); goto l27; } l27: /* end extendedStoreBytecode */; /* begin popStackBytecode */ /* begin internalPop: */ localSP -= 1 * 4; break; case 131: /* singleExtendedSendBytecode */ t1 = byteAt(++localIP); messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 31) + 1) << 2)); argumentCount = ((unsigned) t1) >> 5; /* begin normalSend */ commonSend: /* */; /* begin fetchClassOf: */ if (((longAt(localSP - (argumentCount * 4))) & 1)) { t2 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l30; } t8 = ((((unsigned) (longAt(longAt(localSP - (argumentCount * 4))))) >> 12) & 31) - 1; if (t8 < 0) { t2 = (longAt((longAt(localSP - (argumentCount * 4))) - 4)) & 4294967292U; goto l30; } else { t2 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (t8 << 2)); goto l30; } l30: /* end fetchClassOf: */; /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); /* begin sendSelectorToClass: */ /* begin findNewMethodInClass: */ /* begin lookupInMethodCacheSel:class: */ t6 = ((unsigned) (messageSelector ^ t2)) >> 2; t4 = (t6 & 511) + 1; for (t5 = 1; t5 <= 3; t5 += 1) { if (((methodCache[t4]) == messageSelector) && ((methodCache[t4 + 512]) == t2)) { newMethod = methodCache[t4 + (512 * 2)]; primitiveIndex = methodCache[t4 + (512 * 3)]; t3 = true; goto l28; } t4 = ((((unsigned) t6) >> t5) & 511) + 1; } t3 = false; l28: /* end lookupInMethodCacheSel:class: */; if (!(t3)) { lookupMethodInClass(t2); /* begin primitiveIndexOf: */ t7 = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; if (t7 > 511) { primitiveIndex = (t7 & 511) + (((unsigned) t7) >> 19); goto l29; } else { primitiveIndex = t7; goto l29; } l29: /* end primitiveIndexOf: */; addToMethodCacheSelclassmethodprimIndex(messageSelector, t2, newMethod, primitiveIndex); } /* begin executeNewMethod */ if ((primitiveIndex == 0) || (!(primitiveResponse()))) { activateNewMethod(); /* begin quickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { checkForInterrupts(); } } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 132: /* doubleExtendedDoAnythingBytecode */ t1 = byteAt(++localIP); t2 = byteAt(++localIP); t4 = ((unsigned) t1) >> 5; if (t4 == 0) { messageSelector = longAt(((((char *) method)) + 4) + ((t2 + 1) << 2)); argumentCount = t1 & 31; /* begin normalSend */ goto commonSend; l34: /* end fetchClassOf: */; l32: /* end lookupInMethodCacheSel:class: */; } if (t4 == 1) { messageSelector = longAt(((((char *) method)) + 4) + ((t2 + 1) << 2)); argumentCount = t1 & 31; /* begin superclassSend */ goto commonSupersend; l35: /* end lookupInMethodCacheSel:class: */; } if (t4 == 2) { /* begin pushReceiverVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) receiver)) + 4) + (t2 << 2))); goto l31; } if (t4 == 3) { /* begin pushLiteralConstant: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) method)) + 4) + ((t2 + 1) << 2))); goto l31; } if (t4 == 4) { /* begin pushLiteralVariable: */ /* begin internalPush: */ longAtput(localSP += 4, longAt(((((char *) (longAt(((((char *) method)) + 4) + ((t2 + 1) << 2))))) + 4) + (1 << 2))); goto l31; } if (t4 == 5) { t3 = longAt(localSP); /* begin storePointer:ofObject:withValue: */ t5 = receiver; if (t5 < youngStart) { possibleRootStoreIntovalue(t5, t3); } longAtput(((((char *) t5)) + 4) + (t2 << 2), t3); goto l31; } if (t4 == 6) { t3 = longAt(localSP); /* begin internalPop: */ localSP -= 1 * 4; /* begin storePointer:ofObject:withValue: */ t6 = receiver; if (t6 < youngStart) { possibleRootStoreIntovalue(t6, t3); } longAtput(((((char *) t6)) + 4) + (t2 << 2), t3); goto l31; } if (t4 == 7) { t3 = longAt(localSP); /* begin storePointer:ofObject:withValue: */ t7 = longAt(((((char *) method)) + 4) + ((t2 + 1) << 2)); if (t7 < youngStart) { possibleRootStoreIntovalue(t7, t3); } longAtput(((((char *) t7)) + 4) + (1 << 2), t3); goto l31; } l31: /* end case */; break; case 133: /* singleExtendedSuperBytecode */ t1 = byteAt(++localIP); messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 31) + 1) << 2)); argumentCount = ((unsigned) t1) >> 5; /* begin superclassSend */ commonSupersend: /* */; /* begin superclassOf: */ t3 = longAt(((((char *) (longAt(((((char *) method)) + 4) + (((((((unsigned) (longAt(((((char *) method)) + 4) + (0 << 2)))) >> 10) & 255) - 1) + 1) << 2))))) + 4) + (1 << 2)); t2 = longAt(((((char *) t3)) + 4) + (0 << 2)); /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); /* begin sendSelectorToClass: */ /* begin findNewMethodInClass: */ /* begin lookupInMethodCacheSel:class: */ t7 = ((unsigned) (messageSelector ^ t2)) >> 2; t5 = (t7 & 511) + 1; for (t6 = 1; t6 <= 3; t6 += 1) { if (((methodCache[t5]) == messageSelector) && ((methodCache[t5 + 512]) == t2)) { newMethod = methodCache[t5 + (512 * 2)]; primitiveIndex = methodCache[t5 + (512 * 3)]; t4 = true; goto l37; } t5 = ((((unsigned) t7) >> t6) & 511) + 1; } t4 = false; l37: /* end lookupInMethodCacheSel:class: */; if (!(t4)) { lookupMethodInClass(t2); /* begin primitiveIndexOf: */ t8 = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; if (t8 > 511) { primitiveIndex = (t8 & 511) + (((unsigned) t8) >> 19); goto l38; } else { primitiveIndex = t8; goto l38; } l38: /* end primitiveIndexOf: */; addToMethodCacheSelclassmethodprimIndex(messageSelector, t2, newMethod, primitiveIndex); } /* begin executeNewMethod */ if ((primitiveIndex == 0) || (!(primitiveResponse()))) { activateNewMethod(); /* begin quickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { checkForInterrupts(); } } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 134: /* secondExtendedSendBytecode */ t1 = byteAt(++localIP); messageSelector = longAt(((((char *) method)) + 4) + (((t1 & 63) + 1) << 2)); argumentCount = ((unsigned) t1) >> 6; /* begin normalSend */ goto commonSend; l41: /* end fetchClassOf: */; l39: /* end lookupInMethodCacheSel:class: */; break; case 135: /* popStackBytecode */ /* begin internalPop: */ localSP -= 1 * 4; break; case 136: /* duplicateTopBytecode */ /* begin internalPush: */ t1 = longAt(localSP); longAtput(localSP += 4, t1); break; case 137: /* pushActiveContextBytecode */ reclaimableContextCount = 0; /* begin internalPush: */ longAtput(localSP += 4, activeContext); break; case 138: case 139: case 140: case 141: case 142: case 143: /* experimentalBytecode */ t2 = longAt(((((char *) theHomeContext)) + 4) + (((currentBytecode - 138) + 6) << 2)); t4 = byteAt(localIP + 1); t5 = byteAt(localIP + 2); t6 = byteAt(localIP + 3); if ((t2 & 1)) { t1 = (t2 >> 1); } else { /* begin internalPush: */ longAtput(localSP += 4, t2); goto l42; } if (t4 < 32) { t3 = longAt(((((char *) theHomeContext)) + 4) + (((t4 & 15) + 6) << 2)); if ((t3 & 1)) { t3 = (t3 >> 1); } else { /* begin internalPush: */ longAtput(localSP += 4, t2); goto l42; } } else { if (t4 > 64) { t3 = 1; } else { t3 = longAt(((((char *) method)) + 4) + (((t4 & 31) + 1) << 2)); if ((t3 & 1)) { t3 = (t3 >> 1); } else { /* begin internalPush: */ longAtput(localSP += 4, t2); goto l42; } } } if (t5 < 178) { t8 = t1 + t3; if ((t8 ^ (t8 << 1)) >= 0) { if ((t6 > 103) && (t6 < 112)) { localIP += 3; longAtput(((((char *) theHomeContext)) + 4) + (((t6 & 7) + 6) << 2), ((t8 << 1) | 1)); } else { localIP += 2; /* begin internalPush: */ longAtput(localSP += 4, ((t8 << 1) | 1)); } } else { /* begin internalPush: */ longAtput(localSP += 4, t2); goto l42; } } else { t7 = byteAt(localIP + 4); if (t1 <= t3) { localIP = (localIP + 3) + 1; } else { localIP = ((localIP + 3) + 1) + t7; } } l42: /* end case */; break; case 144: /* shortUnconditionalJump */ /* begin jump: */ localIP += (144 & 7) + 1; break; case 145: /* shortUnconditionalJump */ /* begin jump: */ localIP += (145 & 7) + 1; break; case 146: /* shortUnconditionalJump */ /* begin jump: */ localIP += (146 & 7) + 1; break; case 147: /* shortUnconditionalJump */ /* begin jump: */ localIP += (147 & 7) + 1; break; case 148: /* shortUnconditionalJump */ /* begin jump: */ localIP += (148 & 7) + 1; break; case 149: /* shortUnconditionalJump */ /* begin jump: */ localIP += (149 & 7) + 1; break; case 150: /* shortUnconditionalJump */ /* begin jump: */ localIP += (150 & 7) + 1; break; case 151: /* shortUnconditionalJump */ /* begin jump: */ localIP += (151 & 7) + 1; break; case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: /* shortConditionalJump */ /* begin jumplfFalseBy: */ t1 = (currentBytecode & 7) + 1; t2 = longAt(localSP); if (t2 == falseObj) { /* begin jump: */ localIP += t1; } else { if (!(t2 == trueObj)) { messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); argumentCount = 0; /* begin normalSend */ goto commonSend; l46: /* end fetchClassOf: */; l44: /* end lookupInMethodCacheSel:class: */; } } /* begin internalPop: */ localSP -= 1 * 4; l43: /* end jumplfFalseBy: */; break; case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: /* longUnconditionalJump */ t1 = (((currentBytecode & 7) - 4) * 256) + (byteAt(++localIP)); localIP += t1; if (t1 < 0) { /* begin internalQuickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); checkForInterrupts(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); } } break; case 168: case 169: case 170: case 171: /* longJumpIfTrue */ /* begin jumplfTrueBy: */ t1 = ((currentBytecode & 3) * 256) + (byteAt(++localIP)); t2 = longAt(localSP); if (t2 == trueObj) { /* begin jump: */ localIP += t1; } else { if (!(t2 == falseObj)) { messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); argumentCount = 0; /* begin normalSend */ goto commonSend; l50: /* end fetchClassOf: */; l48: /* end lookupInMethodCacheSel:class: */; } } /* begin internalPop: */ localSP -= 1 * 4; l47: /* end jumplfTrueBy: */; break; case 172: case 173: case 174: case 175: /* longJumpIfFalse */ /* begin jumplfFalseBy: */ t1 = ((currentBytecode & 3) * 256) + (byteAt(++localIP)); t2 = longAt(localSP); if (t2 == falseObj) { /* begin jump: */ localIP += t1; } else { if (!(t2 == trueObj)) { messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (25 << 2)); argumentCount = 0; /* begin normalSend */ goto commonSend; l54: /* end fetchClassOf: */; l52: /* end lookupInMethodCacheSel:class: */; } } /* begin internalPop: */ localSP -= 1 * 4; l51: /* end jumplfFalseBy: */; break; case 176: /* bytecodePrimAdd */ t3 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t3 & t1) & 1) != 0) { t2 = ((t3 >> 1)) + ((t1 >> 1)); if ((t2 ^ (t2 << 1)) >= 0) { longAtput(localSP -= 4, ((t2 << 1) | 1)); goto l55; } } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatAdd(); if (!(successFlag)) { successFlag = true; primitiveAdd(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l55: /* end case */; break; case 177: /* bytecodePrimSubtract */ t3 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t3 & t1) & 1) != 0) { t2 = ((t3 >> 1)) - ((t1 >> 1)); if ((t2 ^ (t2 << 1)) >= 0) { longAtput(localSP -= 4, ((t2 << 1) | 1)); goto l56; } } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatSubtract(); if (!(successFlag)) { successFlag = true; primitiveSubtract(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l56: /* end case */; break; case 178: /* bytecodePrimLessThan */ t2 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t2 & t1) & 1) != 0) { /* begin booleanCheat: */ t3 = byteAt(++localIP); /* begin internalPop: */ localSP -= 2 * 4; if ((t3 < 160) && (t3 > 151)) { if (t2 < t1) { goto l57; } else { /* begin jump: */ localIP += t3 - 151; goto l57; } } if (t3 == 172) { t4 = byteAt(++localIP); if (t2 < t1) { goto l57; } else { /* begin jump: */ localIP += t4; goto l57; } } localIP -= 1; if (t2 < t1) { /* begin internalPush: */ longAtput(localSP += 4, trueObj); } else { /* begin internalPush: */ longAtput(localSP += 4, falseObj); } goto l57; } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatLessThan(); if (!(successFlag)) { successFlag = true; primitiveLessThan(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l57: /* end case */; break; case 179: /* bytecodePrimGreaterThan */ t2 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t2 & t1) & 1) != 0) { /* begin booleanCheat: */ t3 = byteAt(++localIP); /* begin internalPop: */ localSP -= 2 * 4; if ((t3 < 160) && (t3 > 151)) { if (t2 > t1) { goto l58; } else { /* begin jump: */ localIP += t3 - 151; goto l58; } } if (t3 == 172) { t4 = byteAt(++localIP); if (t2 > t1) { goto l58; } else { /* begin jump: */ localIP += t4; goto l58; } } localIP -= 1; if (t2 > t1) { /* begin internalPush: */ longAtput(localSP += 4, trueObj); } else { /* begin internalPush: */ longAtput(localSP += 4, falseObj); } goto l58; } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatGreaterThan(); if (!(successFlag)) { successFlag = true; primitiveGreaterThan(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l58: /* end case */; break; case 180: /* bytecodePrimLessOrEqual */ t2 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t2 & t1) & 1) != 0) { /* begin booleanCheat: */ t3 = byteAt(++localIP); /* begin internalPop: */ localSP -= 2 * 4; if ((t3 < 160) && (t3 > 151)) { if (t2 <= t1) { goto l59; } else { /* begin jump: */ localIP += t3 - 151; goto l59; } } if (t3 == 172) { t4 = byteAt(++localIP); if (t2 <= t1) { goto l59; } else { /* begin jump: */ localIP += t4; goto l59; } } localIP -= 1; if (t2 <= t1) { /* begin internalPush: */ longAtput(localSP += 4, trueObj); } else { /* begin internalPush: */ longAtput(localSP += 4, falseObj); } goto l59; } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatLessOrEqual(); if (!(successFlag)) { successFlag = true; primitiveLessOrEqual(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l59: /* end case */; break; case 181: /* bytecodePrimGreaterOrEqual */ t2 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t2 & t1) & 1) != 0) { /* begin booleanCheat: */ t3 = byteAt(++localIP); /* begin internalPop: */ localSP -= 2 * 4; if ((t3 < 160) && (t3 > 151)) { if (t2 >= t1) { goto l60; } else { /* begin jump: */ localIP += t3 - 151; goto l60; } } if (t3 == 172) { t4 = byteAt(++localIP); if (t2 >= t1) { goto l60; } else { /* begin jump: */ localIP += t4; goto l60; } } localIP -= 1; if (t2 >= t1) { /* begin internalPush: */ longAtput(localSP += 4, trueObj); } else { /* begin internalPush: */ longAtput(localSP += 4, falseObj); } goto l60; } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatGreaterOrEqual(); if (!(successFlag)) { successFlag = true; primitiveGreaterOrEqual(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l60: /* end case */; break; case 182: /* bytecodePrimEqual */ t2 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t2 & t1) & 1) != 0) { /* begin booleanCheat: */ t3 = byteAt(++localIP); /* begin internalPop: */ localSP -= 2 * 4; if ((t3 < 160) && (t3 > 151)) { if (t2 == t1) { goto l61; } else { /* begin jump: */ localIP += t3 - 151; goto l61; } } if (t3 == 172) { t4 = byteAt(++localIP); if (t2 == t1) { goto l61; } else { /* begin jump: */ localIP += t4; goto l61; } } localIP -= 1; if (t2 == t1) { /* begin internalPush: */ longAtput(localSP += 4, trueObj); } else { /* begin internalPush: */ longAtput(localSP += 4, falseObj); } goto l61; } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatEqual(); if (!(successFlag)) { successFlag = true; primitiveEqual(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l61: /* end case */; break; case 183: /* bytecodePrimNotEqual */ t2 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t2 & t1) & 1) != 0) { /* begin booleanCheat: */ t3 = byteAt(++localIP); /* begin internalPop: */ localSP -= 2 * 4; if ((t3 < 160) && (t3 > 151)) { if (t2 != t1) { goto l62; } else { /* begin jump: */ localIP += t3 - 151; goto l62; } } if (t3 == 172) { t4 = byteAt(++localIP); if (t2 != t1) { goto l62; } else { /* begin jump: */ localIP += t4; goto l62; } } localIP -= 1; if (t2 != t1) { /* begin internalPush: */ longAtput(localSP += 4, trueObj); } else { /* begin internalPush: */ longAtput(localSP += 4, falseObj); } goto l62; } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatNotEqual(); if (!(successFlag)) { successFlag = true; primitiveNotEqual(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l62: /* end case */; break; case 184: /* bytecodePrimMultiply */ t3 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t3 & t1) & 1) != 0) { t3 = (t3 >> 1); t1 = (t1 >> 1); t2 = t3 * t1; if (((t1 == 0) || ((t2 / t1) == t3)) && ((t2 ^ (t2 << 1)) >= 0)) { longAtput(localSP -= 4, ((t2 << 1) | 1)); goto l63; } } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatMultiply(); if (!(successFlag)) { successFlag = true; primitiveMultiply(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l63: /* end case */; break; case 185: /* bytecodePrimDivide */ t3 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); if (((t3 & t1) & 1) != 0) { t3 = (t3 >> 1); t1 = (t1 >> 1); if ((t1 != 0) && ((t3 % t1) == 0)) { t2 = t3 / t1; if ((t2 ^ (t2 << 1)) >= 0) { longAtput(localSP -= 4, ((t2 << 1) | 1)); goto l64; } } } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; primitiveFloatDivide(); if (!(successFlag)) { successFlag = true; primitiveDivide(); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); l64: /* end case */; break; case 186: /* bytecodePrimMod */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveMod(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 187: /* bytecodePrimMakePoint */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveMakePoint(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 188: /* bytecodePrimBitShift */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveBitShift(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 189: /* bytecodePrimDiv */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveDiv(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 190: /* bytecodePrimBitAnd */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveBitAnd(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 191: /* bytecodePrimBitOr */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveBitOr(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 192: /* bytecodePrimAt */ t2 = longAt(localSP); t4 = longAt(localSP - (1 * 4)); successFlag = (t2 & 1); if (successFlag) { /* begin fetchClassOf: */ if ((t4 & 1)) { t5 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l65; } t6 = ((((unsigned) (longAt(t4))) >> 12) & 31) - 1; if (t6 < 0) { t5 = (longAt(t4 - 4)) & 4294967292U; goto l65; } else { t5 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (t6 << 2)); goto l65; } l65: /* end fetchClassOf: */; t1 = t5 == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2))); if (!(t1 || ((t5 == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) || ((t5 == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)))) || (t5 == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))))))) { successFlag = false; } } if (successFlag) { t2 = (t2 >> 1); /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); t3 = stObjectat(t4, t2); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); if (t1 && (successFlag)) { t3 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (((t3 >> 1)) << 2)); } } if (successFlag) { /* begin internalPop:thenPush: */ longAtput(localSP -= (2 - 1) * 4, t3); } else { messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((16 * 2) << 2)); argumentCount = 1; /* begin normalSend */ goto commonSend; l68: /* end fetchClassOf: */; l66: /* end lookupInMethodCacheSel:class: */; } break; case 193: /* bytecodePrimAtPut */ t2 = t3 = longAt(localSP); t4 = longAt(localSP - (1 * 4)); t5 = longAt(localSP - (2 * 4)); successFlag = (t4 & 1); if (successFlag) { /* begin fetchClassOf: */ if ((t5 & 1)) { t6 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l69; } t7 = ((((unsigned) (longAt(t5))) >> 12) & 31) - 1; if (t7 < 0) { t6 = (longAt(t5 - 4)) & 4294967292U; goto l69; } else { t6 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (t7 << 2)); goto l69; } l69: /* end fetchClassOf: */; t1 = t6 == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2))); if (!(t1 || ((t6 == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) || ((t6 == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)))) || (t6 == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))))))) { successFlag = false; } } if (successFlag) { t4 = (t4 >> 1); if (t1) { t3 = asciiOfCharacter(t2); } stObjectatput(t5, t4, t3); } if (successFlag) { /* begin internalPop:thenPush: */ longAtput(localSP -= (3 - 1) * 4, t2); } else { messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((17 * 2) << 2)); argumentCount = 2; /* begin normalSend */ goto commonSend; l72: /* end fetchClassOf: */; l70: /* end lookupInMethodCacheSel:class: */; } break; case 194: /* bytecodePrimSize */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); successFlag = true; /* begin fetchClassOf: */ if (((longAt(stackPointer - (0 * 4))) & 1)) { t1 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l73; } t2 = ((((unsigned) (longAt(longAt(stackPointer - (0 * 4))))) >> 12) & 31) - 1; if (t2 < 0) { t1 = (longAt((longAt(stackPointer - (0 * 4))) - 4)) & 4294967292U; goto l73; } else { t1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (t2 << 2)); goto l73; } l73: /* end fetchClassOf: */; if ((t1 == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) || ((t1 == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) || ((t1 == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))) || (t1 == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2))))))) { primitiveSize(); } else { failSpecialPrim(0); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 195: /* bytecodePrimNext */ messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((19 * 2) << 2)); argumentCount = 0; /* begin normalSend */ goto commonSend; l76: /* end fetchClassOf: */; l74: /* end lookupInMethodCacheSel:class: */; break; case 196: /* bytecodePrimNextPut */ messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((20 * 2) << 2)); argumentCount = 1; /* begin normalSend */ goto commonSend; l79: /* end fetchClassOf: */; l77: /* end lookupInMethodCacheSel:class: */; break; case 197: /* bytecodePrimAtEnd */ messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((21 * 2) << 2)); argumentCount = 0; /* begin normalSend */ goto commonSend; l82: /* end fetchClassOf: */; l80: /* end lookupInMethodCacheSel:class: */; break; case 198: /* bytecodePrimEquivalent */ t2 = longAt(localSP - (1 * 4)); t1 = longAt(localSP - (0 * 4)); /* begin booleanCheat: */ t3 = byteAt(++localIP); /* begin internalPop: */ localSP -= 2 * 4; if ((t3 < 160) && (t3 > 151)) { if (t2 == t1) { goto l83; } else { /* begin jump: */ localIP += t3 - 151; goto l83; } } if (t3 == 172) { t4 = byteAt(++localIP); if (t2 == t1) { goto l83; } else { /* begin jump: */ localIP += t4; goto l83; } } localIP -= 1; if (t2 == t1) { /* begin internalPush: */ longAtput(localSP += 4, trueObj); } else { /* begin internalPush: */ longAtput(localSP += 4, falseObj); } l83: /* end booleanCheat: */; break; case 199: /* bytecodePrimClass */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveClass(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 200: /* bytecodePrimBlockCopy */ /* begin fetchClassOf: */ if (((longAt(localSP - (1 * 4))) & 1)) { t1 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l85; } t2 = ((((unsigned) (longAt(longAt(localSP - (1 * 4))))) >> 12) & 31) - 1; if (t2 < 0) { t1 = (longAt((longAt(localSP - (1 * 4))) - 4)) & 4294967292U; goto l85; } else { t1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (t2 << 2)); goto l85; } l85: /* end fetchClassOf: */; successFlag = true; /* begin success: */ t3 = (t1 == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)))) || (t1 == (longAt(((((char *) specialObjectsOop)) + 4) + (10 << 2)))); successFlag = t3 && successFlag; if (successFlag) { /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); /* begin primitiveBlockCopy */ t7 = longAt(stackPointer - (1 * 4)); if (((longAt(((((char *) t7)) + 4) + (3 << 2))) & 1)) { t4 = longAt(((((char *) t7)) + 4) + (5 << 2)); } else { t4 = t7; } /* begin sizeBitsOf: */ t9 = longAt(t4); if ((t9 & 3) == 0) { t8 = (longAt(t4 - 8)) & 4294967292U; goto l86; } else { t8 = t9 & 252; goto l86; } l86: /* end sizeBitsOf: */; t7 = null; /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = t4; t5 = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)), t8, nilObj); /* begin popRemappableOop */ t10 = remapBuffer[remapBufferCount]; remapBufferCount -= 1; t4 = t10; t6 = (((instructionPointer - method) << 1) | 1); longAtput(((((char *) t5)) + 4) + (4 << 2), t6); longAtput(((((char *) t5)) + 4) + (1 << 2), t6); /* begin storeStackPointerValue:inContext: */ longAtput(((((char *) t5)) + 4) + (2 << 2), ((0 << 1) | 1)); longAtput(((((char *) t5)) + 4) + (3 << 2), longAt(stackPointer - (0 * 4))); longAtput(((((char *) t5)) + 4) + (5 << 2), t4); /* begin pop: */ stackPointer -= 2 * 4; /* begin push: */ longAtput(t11 = stackPointer + 4, t5); stackPointer = t11; /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); } if (!(successFlag)) { messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((24 * 2) << 2)); argumentCount = 1; /* begin normalSend */ goto commonSend; l89: /* end fetchClassOf: */; l87: /* end lookupInMethodCacheSel:class: */; } l84: /* end case */; break; case 201: /* bytecodePrimValue */ t1 = longAt(localSP); successFlag = true; argumentCount = 0; /* begin assertClassOf:is: */ if ((t1 & 1)) { successFlag = false; goto l91; } t2 = (((unsigned) (longAt(t1))) >> 12) & 31; if (t2 == 0) { t3 = (longAt(t1 - 4)) & 4294967292U; } else { t3 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t2 - 1) << 2)); } /* begin success: */ successFlag = (t3 == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)))) && successFlag; l91: /* end assertClassOf:is: */; if (successFlag) { /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveValue(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); } if (!(successFlag)) { messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((25 * 2) << 2)); argumentCount = 0; /* begin normalSend */ goto commonSend; l94: /* end fetchClassOf: */; l92: /* end lookupInMethodCacheSel:class: */; } l90: /* end case */; break; case 202: /* bytecodePrimValueWithArg */ t1 = longAt(localSP - (1 * 4)); successFlag = true; argumentCount = 1; /* begin assertClassOf:is: */ if ((t1 & 1)) { successFlag = false; goto l96; } t2 = (((unsigned) (longAt(t1))) >> 12) & 31; if (t2 == 0) { t3 = (longAt(t1 - 4)) & 4294967292U; } else { t3 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t2 - 1) << 2)); } /* begin success: */ successFlag = (t3 == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)))) && successFlag; l96: /* end assertClassOf:is: */; if (successFlag) { /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); primitiveValue(); /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); } if (!(successFlag)) { messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((26 * 2) << 2)); argumentCount = 1; /* begin normalSend */ goto commonSend; l99: /* end fetchClassOf: */; l97: /* end lookupInMethodCacheSel:class: */; } l95: /* end case */; break; case 203: /* bytecodePrimDo */ messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((27 * 2) << 2)); argumentCount = 1; /* begin normalSend */ goto commonSend; l102: /* end fetchClassOf: */; l100: /* end lookupInMethodCacheSel:class: */; break; case 204: /* bytecodePrimNew */ messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((28 * 2) << 2)); argumentCount = 0; /* begin normalSend */ goto commonSend; l105: /* end fetchClassOf: */; l103: /* end lookupInMethodCacheSel:class: */; break; case 205: /* bytecodePrimNewWithArg */ messageSelector = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((29 * 2) << 2)); argumentCount = 1; /* begin normalSend */ goto commonSend; l108: /* end fetchClassOf: */; l106: /* end lookupInMethodCacheSel:class: */; break; case 206: /* bytecodePrimPointX */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); /* begin primitivePointX */ successFlag = true; /* begin popStack */ t3 = longAt(stackPointer); stackPointer -= 4; t1 = t3; /* begin assertClassOf:is: */ if ((t1 & 1)) { successFlag = false; goto l109; } t4 = (((unsigned) (longAt(t1))) >> 12) & 31; if (t4 == 0) { t5 = (longAt(t1 - 4)) & 4294967292U; } else { t5 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t4 - 1) << 2)); } /* begin success: */ successFlag = (t5 == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)))) && successFlag; l109: /* end assertClassOf:is: */; if (successFlag) { /* begin push: */ longAtput(t2 = stackPointer + 4, longAt(((((char *) t1)) + 4) + (0 << 2))); stackPointer = t2; } else { /* begin unPop: */ stackPointer += 1 * 4; failSpecialPrim(0); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 207: /* bytecodePrimPointY */ /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); /* begin primitivePointY */ successFlag = true; /* begin popStack */ t3 = longAt(stackPointer); stackPointer -= 4; t1 = t3; /* begin assertClassOf:is: */ if ((t1 & 1)) { successFlag = false; goto l110; } t4 = (((unsigned) (longAt(t1))) >> 12) & 31; if (t4 == 0) { t5 = (longAt(t1 - 4)) & 4294967292U; } else { t5 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((t4 - 1) << 2)); } /* begin success: */ successFlag = (t5 == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)))) && successFlag; l110: /* end assertClassOf:is: */; if (successFlag) { /* begin push: */ longAtput(t2 = stackPointer + 4, longAt(((((char *) t1)) + 4) + (1 << 2))); stackPointer = t2; } else { /* begin unPop: */ stackPointer += 1 * 4; failSpecialPrim(0); } /* begin internalizeIPandSP */ localIP = ((char *) instructionPointer); localSP = ((char *) stackPointer); break; case 208: case 209: case 210: case 211: case 212: case 213: case 214: case 215: case 216: case 217: case 218: case 219: case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: case 239: case 240: case 241: case 242: case 243: case 244: case 245: case 246: case 247: case 248: case 249: case 250: case 251: case 252: case 253: case 254: case 255: /* sendLiteralSelectorBytecode */ /* begin literal: */ t1 = currentBytecode & 15; messageSelector = longAt(((((char *) method)) + 4) + ((t1 + 1) << 2)); argumentCount = ((((unsigned) currentBytecode) >> 4) & 3) - 1; /* begin normalSend */ goto commonSend; l113: /* end fetchClassOf: */; l111: /* end lookupInMethodCacheSel:class: */; break; } } /* begin externalizeIPandSP */ instructionPointer = ((int) localIP); stackPointer = ((int) localSP); } int isBytes(int oop) { return ((((unsigned) (longAt(oop))) >> 8) & 15) >= 8; } int isEmptyList(int aLinkedList) { return (longAt(((((char *) aLinkedList)) + 4) + (0 << 2))) == nilObj; } int isFreeObject(int oop) { return ((longAt(oop)) & 3) == 2; } int isIntegerObject(int objectPointer) { return (objectPointer & 1) > 0; } int isIntegerValue(int intValue) { return (intValue ^ (intValue << 1)) >= 0; } int isObjectForwarded(int oop) { return ((oop & 1) == 0) && (((longAt(oop)) & 2147483648U) != 0); } int isPointers(int oop) { return ((((unsigned) (longAt(oop))) >> 8) & 15) <= 4; } int isWords(int oop) { return ((((unsigned) (longAt(oop))) >> 8) & 15) == 6; } int isWordsOrBytes(int oop) { int fmt; fmt = (((unsigned) (longAt(oop))) >> 8) & 15; return (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); } int lastPointerOf(int objectPointer) { int methodHeader; int sz; int fmt; int header; int type; fmt = (((unsigned) (longAt(objectPointer))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header = longAt(objectPointer); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l1; } else { if ((header & 126976) == 0) { type = 1; goto l1; } else { type = 3; goto l1; } } l1: /* end rightType: */; if (type == 0) { sz = (longAt(objectPointer - 8)) & 4294967292U; goto l2; } else { sz = header & 252; goto l2; } l2: /* end sizeBitsOfSafe: */; return sz - 4; } if (fmt < 12) { return 0; } methodHeader = longAt(objectPointer + 4); return (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; } int lastPointerWhileForwarding(int oop) { int methodHeader; int size; int fwdBlock; int fmt; int header; header = longAt(oop); if ((header & 2147483648U) != 0) { fwdBlock = header & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } header = longAt(fwdBlock + 4); } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 4) { if ((header & 3) == 0) { size = (longAt(oop - 8)) & 268435452; } else { size = header & 252; } return size - 4; } if (fmt < 12) { return 0; } methodHeader = longAt(oop + 4); return (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; } int lengthOf(int oop) { int sz; int header; int fmt; header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { return ((unsigned) (sz - 4)) >> 2; } else { return (sz - 4) - (fmt & 3); } } int lengthOfbaseHeaderformat(int oop, int hdr, int fmt) { int sz; if ((hdr & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; } else { sz = hdr & 252; } if (fmt < 8) { return ((unsigned) (sz - 4)) >> 2; } else { return (sz - 4) - (fmt & 3); } } int literal(int offset) { return longAt(((((char *) method)) + 4) + ((offset + 1) << 2)); } int literalofMethod(int offset, int methodPointer) { return longAt(((((char *) methodPointer)) + 4) + ((offset + 1) << 2)); } int literalCountOf(int methodPointer) { return (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 10) & 255; } int literalCountOfHeader(int headerPointer) { return (((unsigned) headerPointer) >> 10) & 255; } int loadBitBltFrom(int bbObj) { int destBitsSize; int destWidth; int destHeight; int sourceBitsSize; int sourcePixPerWord; int halftoneBits; int cmSize; int sz; int header; int fmt; int sz1; int header1; int fmt1; bitBltOop = bbObj; combinationRule = fetchIntegerofObject(3, bitBltOop); if ((!successFlag) || ((combinationRule < 0) || (combinationRule > 33))) { return false; } if ((combinationRule >= 16) && (combinationRule <= 17)) { return false; } sourceForm = longAt(((((char *) bitBltOop)) + 4) + (1 << 2)); /* begin ignoreSourceOrHalftone: */ if (sourceForm == nilObj) { noSource = true; goto l3; } if (combinationRule == 0) { noSource = true; goto l3; } if (combinationRule == 5) { noSource = true; goto l3; } if (combinationRule == 10) { noSource = true; goto l3; } if (combinationRule == 15) { noSource = true; goto l3; } noSource = false; l3: /* end ignoreSourceOrHalftone: */; halftoneForm = longAt(((((char *) bitBltOop)) + 4) + (2 << 2)); /* begin ignoreSourceOrHalftone: */ if (halftoneForm == nilObj) { noHalftone = true; goto l4; } if (combinationRule == 0) { noHalftone = true; goto l4; } if (combinationRule == 5) { noHalftone = true; goto l4; } if (combinationRule == 10) { noHalftone = true; goto l4; } if (combinationRule == 15) { noHalftone = true; goto l4; } noHalftone = false; l4: /* end ignoreSourceOrHalftone: */; destForm = longAt(((((char *) bitBltOop)) + 4) + (0 << 2)); if (!((((((unsigned) (longAt(destForm))) >> 8) & 15) <= 4) && ((lengthOf(destForm)) >= 4))) { return false; } destBits = longAt(((((char *) destForm)) + 4) + (0 << 2)); destBitsSize = byteLengthOf(destBits); destWidth = fetchIntegerofObject(1, destForm); destHeight = fetchIntegerofObject(2, destForm); if (!((destWidth >= 0) && (destHeight >= 0))) { return false; } destPixSize = fetchIntegerofObject(3, destForm); pixPerWord = 32 / destPixSize; destRaster = (destWidth + (pixPerWord - 1)) / pixPerWord; if (!((isWordsOrBytes(destBits)) && (destBitsSize == ((destRaster * destHeight) * 4)))) { return false; } destX = fetchIntegerOrTruncFloatofObject(4, bitBltOop); destY = fetchIntegerOrTruncFloatofObject(5, bitBltOop); width = fetchIntegerOrTruncFloatofObject(6, bitBltOop); height = fetchIntegerOrTruncFloatofObject(7, bitBltOop); if (!successFlag) { return false; } if (noSource) { sourceX = sourceY = 0; } else { if (!((((((unsigned) (longAt(sourceForm))) >> 8) & 15) <= 4) && ((lengthOf(sourceForm)) >= 4))) { return false; } sourceBits = longAt(((((char *) sourceForm)) + 4) + (0 << 2)); sourceBitsSize = byteLengthOf(sourceBits); srcWidth = fetchIntegerOrTruncFloatofObject(1, sourceForm); srcHeight = fetchIntegerOrTruncFloatofObject(2, sourceForm); if (!((srcWidth >= 0) && (srcHeight >= 0))) { return false; } sourcePixSize = fetchIntegerofObject(3, sourceForm); sourcePixPerWord = 32 / sourcePixSize; sourceRaster = (srcWidth + (sourcePixPerWord - 1)) / sourcePixPerWord; if (!((isWordsOrBytes(sourceBits)) && (sourceBitsSize == ((sourceRaster * srcHeight) * 4)))) { return false; } colorMap = longAt(((((char *) bitBltOop)) + 4) + (14 << 2)); if (!(colorMap == nilObj)) { if (((((unsigned) (longAt(colorMap))) >> 8) & 15) == 6) { /* begin lengthOf: */ header = longAt(colorMap); if ((header & 3) == 0) { sz = (longAt(colorMap - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { cmSize = ((unsigned) (sz - 4)) >> 2; goto l1; } else { cmSize = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; cmBitsPerColor = 0; if (cmSize == 512) { cmBitsPerColor = 3; } if (cmSize == 4096) { cmBitsPerColor = 4; } if (cmSize == 32768) { cmBitsPerColor = 5; } if (primitiveIndex != 147) { if (sourcePixSize <= 8) { if (!(cmSize == (1 << sourcePixSize))) { return false; } } else { if (cmBitsPerColor == 0) { return false; } } } } else { return false; } } sourceX = fetchIntegerOrTruncFloatofObject(8, bitBltOop); sourceY = fetchIntegerOrTruncFloatofObject(9, bitBltOop); } if (!(noHalftone)) { if ((((((unsigned) (longAt(halftoneForm))) >> 8) & 15) <= 4) && ((lengthOf(halftoneForm)) >= 4)) { halftoneBits = longAt(((((char *) halftoneForm)) + 4) + (0 << 2)); halftoneHeight = fetchIntegerofObject(2, halftoneForm); if (!(((((unsigned) (longAt(halftoneBits))) >> 8) & 15) == 6)) { noHalftone = true; } } else { if (!((!(((((unsigned) (longAt(halftoneForm))) >> 8) & 15) <= 4)) && (((((unsigned) (longAt(halftoneForm))) >> 8) & 15) == 6))) { return false; } halftoneBits = halftoneForm; /* begin lengthOf: */ header1 = longAt(halftoneBits); if ((header1 & 3) == 0) { sz1 = (longAt(halftoneBits - 8)) & 4294967292U; } else { sz1 = header1 & 252; } fmt1 = (((unsigned) header1) >> 8) & 15; if (fmt1 < 8) { halftoneHeight = ((unsigned) (sz1 - 4)) >> 2; goto l2; } else { halftoneHeight = (sz1 - 4) - (fmt1 & 3); goto l2; } l2: /* end lengthOf: */; } halftoneBase = halftoneBits + 4; } clipX = fetchIntegerOrTruncFloatofObject(10, bitBltOop); clipY = fetchIntegerOrTruncFloatofObject(11, bitBltOop); clipWidth = fetchIntegerOrTruncFloatofObject(12, bitBltOop); clipHeight = fetchIntegerOrTruncFloatofObject(13, bitBltOop); if (!successFlag) { return false; } if (clipX < 0) { clipWidth += clipX; clipX = 0; } if (clipY < 0) { clipHeight += clipY; clipY = 0; } if ((clipX + clipWidth) > destWidth) { clipWidth = destWidth - clipX; } if ((clipY + clipHeight) > destHeight) { clipHeight = destHeight - clipY; } return true; } int loadInitialContext(void) { int sched; int proc; int activeCntx; int tmp; sched = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); proc = longAt(((((char *) sched)) + 4) + (1 << 2)); activeContext = longAt(((((char *) proc)) + 4) + (1 << 2)); if (activeContext < youngStart) { beRootIfOld(activeContext); } /* begin fetchContextRegisters: */ activeCntx = activeContext; tmp = longAt(((((char *) activeCntx)) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) activeCntx)) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = activeCntx; } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) activeCntx)) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) activeCntx)) + 4) + (2 << 2))) >> 1); stackPointer = (activeCntx + 4) + (((6 + tmp) - 1) * 4); reclaimableContextCount = 0; } int loadScannerFromstartstopstringrightXstopArraydisplayFlag(int bbObj, int start, int stop, int string, int rightX, int stopArray, int displayFlag) { int successValue; int successValue1; int successValue2; scanStart = start; scanStop = stop; scanString = string; scanRightX = rightX; scanStopArray = stopArray; scanDisplayFlag = displayFlag; /* begin success: */ successValue1 = (((((unsigned) (longAt(scanStopArray))) >> 8) & 15) <= 4) && ((lengthOf(scanStopArray)) >= 1); successFlag = successValue1 && successFlag; scanXTable = longAt(((((char *) bbObj)) + 4) + (16 << 2)); /* begin success: */ successValue2 = (((((unsigned) (longAt(scanXTable))) >> 8) & 15) <= 4) && ((lengthOf(scanXTable)) >= 1); successFlag = successValue2 && successFlag; /* begin storeInteger:ofObject:withValue: */ if ((0 ^ (0 << 1)) >= 0) { longAtput(((((char *) bbObj)) + 4) + (6 << 2), ((0 << 1) | 1)); } else { primitiveFail(); } /* begin storeInteger:ofObject:withValue: */ if ((0 ^ (0 << 1)) >= 0) { longAtput(((((char *) bbObj)) + 4) + (8 << 2), ((0 << 1) | 1)); } else { primitiveFail(); } if (scanDisplayFlag) { /* begin success: */ successValue = loadBitBltFrom(bbObj); successFlag = successValue && successFlag; } else { bitBltOop = bbObj; destX = fetchIntegerOrTruncFloatofObject(4, bbObj); } return !(!successFlag); } int lookupInMethodCacheSelclass(int selector, int class) { int probe; int p; int hash; hash = ((unsigned) (selector ^ class)) >> 2; probe = (hash & 511) + 1; for (p = 1; p <= 3; p += 1) { if (((methodCache[probe]) == selector) && ((methodCache[probe + 512]) == class)) { newMethod = methodCache[probe + (512 * 2)]; primitiveIndex = methodCache[probe + (512 * 3)]; return true; } probe = ((((unsigned) hash) >> p) & 511) + 1; } return false; } int lookupMethodInClass(int class) { int dictionary; int currentClass; int found; int rclass; int oop; int argumentArray; int message; int oop1; int valuePointer; int toIndex; int fromIndex; int lastFrom; int sp; int methodArray; int mask; int wrapAround; int nextSelector; int index; int length; int sz; int primBits; int header; currentClass = class; while (currentClass != nilObj) { dictionary = longAt(((((char *) currentClass)) + 4) + (1 << 2)); /* begin lookupMethodInDictionary: */ /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(dictionary); if ((header & 3) == 0) { sz = (longAt(dictionary - 8)) & 4294967292U; goto l2; } else { sz = header & 252; goto l2; } l2: /* end sizeBitsOf: */; length = ((unsigned) (sz - 4)) >> 2; mask = (length - 2) - 1; if ((messageSelector & 1)) { index = (mask & ((messageSelector >> 1))) + 2; } else { index = (mask & ((((unsigned) (longAt(messageSelector))) >> 17) & 4095)) + 2; } wrapAround = false; while (true) { nextSelector = longAt(((((char *) dictionary)) + 4) + (index << 2)); if (nextSelector == nilObj) { found = false; goto l3; } if (nextSelector == messageSelector) { methodArray = longAt(((((char *) dictionary)) + 4) + (1 << 2)); newMethod = longAt(((((char *) methodArray)) + 4) + ((index - 2) << 2)); /* begin primitiveIndexOf: */ primBits = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; if (primBits > 511) { primitiveIndex = (primBits & 511) + (((unsigned) primBits) >> 19); goto l1; } else { primitiveIndex = primBits; goto l1; } l1: /* end primitiveIndexOf: */; found = true; goto l3; } index += 1; if (index == length) { if (wrapAround) { found = false; goto l3; } wrapAround = true; index = 2; } } l3: /* end lookupMethodInDictionary: */; if (found) { return currentClass; } currentClass = longAt(((((char *) currentClass)) + 4) + (0 << 2)); } if (messageSelector == (longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)))) { error("Recursive not understood error encountered"); } /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = class; /* begin createActualMessage */ argumentArray = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)), argumentCount); /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = argumentArray; message = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (15 << 2)), 0); /* begin popRemappableOop */ oop1 = remapBuffer[remapBufferCount]; remapBufferCount -= 1; argumentArray = oop1; if (argumentArray < youngStart) { beRootIfOld(argumentArray); } /* begin storePointer:ofObject:withValue: */ valuePointer = messageSelector; if (message < youngStart) { possibleRootStoreIntovalue(message, valuePointer); } longAtput(((((char *) message)) + 4) + (0 << 2), valuePointer); /* begin storePointer:ofObject:withValue: */ if (message < youngStart) { possibleRootStoreIntovalue(message, argumentArray); } longAtput(((((char *) message)) + 4) + (1 << 2), argumentArray); /* begin transfer:fromIndex:ofObject:toIndex:ofObject: */ fromIndex = activeContext + (((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - (argumentCount - 1)) * 4); toIndex = argumentArray + (0 * 4); lastFrom = fromIndex + (argumentCount * 4); while (fromIndex < lastFrom) { fromIndex += 4; toIndex += 4; longAtput(toIndex, longAt(fromIndex)); } /* begin pop: */ stackPointer -= argumentCount * 4; /* begin push: */ longAtput(sp = stackPointer + 4, message); stackPointer = sp; argumentCount = 1; /* begin popRemappableOop */ oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; rclass = oop; messageSelector = longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)); return lookupMethodInClass(rclass); } int lookupMethodInDictionary(int dictionary) { int methodArray; int mask; int wrapAround; int nextSelector; int index; int length; int sz; int primBits; int header; /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(dictionary); if ((header & 3) == 0) { sz = (longAt(dictionary - 8)) & 4294967292U; goto l2; } else { sz = header & 252; goto l2; } l2: /* end sizeBitsOf: */; length = ((unsigned) (sz - 4)) >> 2; mask = (length - 2) - 1; if ((messageSelector & 1)) { index = (mask & ((messageSelector >> 1))) + 2; } else { index = (mask & ((((unsigned) (longAt(messageSelector))) >> 17) & 4095)) + 2; } wrapAround = false; while (true) { nextSelector = longAt(((((char *) dictionary)) + 4) + (index << 2)); if (nextSelector == nilObj) { return false; } if (nextSelector == messageSelector) { methodArray = longAt(((((char *) dictionary)) + 4) + (1 << 2)); newMethod = longAt(((((char *) methodArray)) + 4) + ((index - 2) << 2)); /* begin primitiveIndexOf: */ primBits = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; if (primBits > 511) { primitiveIndex = (primBits & 511) + (((unsigned) primBits) >> 19); goto l1; } else { primitiveIndex = primBits; goto l1; } l1: /* end primitiveIndexOf: */; return true; } index += 1; if (index == length) { if (wrapAround) { return false; } wrapAround = true; index = 2; } } } int lowestFreeAfter(int chunk) { int oopHeader; int oop; int oopHeaderType; int oopSize; int extra; int extra1; int type; int extra2; int type1; int extra3; /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(chunk)) & 3; if (type1 > 1) { extra3 = 0; } else { if (type1 == 1) { extra3 = 4; } else { extra3 = 8; } } extra1 = extra3; oop = chunk + extra1; while (oop < endOfMemory) { oopHeader = longAt(oop); oopHeaderType = oopHeader & 3; if (oopHeaderType == 2) { return oop; } else { if (oopHeaderType == 0) { oopSize = (longAt(oop - 8)) & 4294967292U; } else { oopSize = oopHeader & 252; } } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type = (longAt(oop + oopSize)) & 3; if (type > 1) { extra2 = 0; } else { if (type == 1) { extra2 = 4; } else { extra2 = 8; } } extra = extra2; oop = (oop + oopSize) + extra; } error("expected to find at least one free object"); } int makeDirEntryNamesizecreateDatemodDateisDirfileSize(char *entryName, int entryNameSize, int createDate, int modifiedDate, int dirFlag, int fileSize) { int modDateOop; int i; int nameString; int createDateOop; int results; int valuePointer; int valuePointer1; int oop; int oop1; int oop2; int oop3; int oop4; int oop5; int oop6; int oop7; /* begin pushRemappableOop: */ oop = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)), 5); remapBuffer[remapBufferCount += 1] = oop; /* begin pushRemappableOop: */ oop1 = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), entryNameSize); remapBuffer[remapBufferCount += 1] = oop1; /* begin pushRemappableOop: */ oop2 = positive32BitIntegerFor(createDate); remapBuffer[remapBufferCount += 1] = oop2; /* begin pushRemappableOop: */ oop3 = positive32BitIntegerFor(modifiedDate); remapBuffer[remapBufferCount += 1] = oop3; /* begin popRemappableOop */ oop4 = remapBuffer[remapBufferCount]; remapBufferCount -= 1; modDateOop = oop4; /* begin popRemappableOop */ oop5 = remapBuffer[remapBufferCount]; remapBufferCount -= 1; createDateOop = oop5; /* begin popRemappableOop */ oop6 = remapBuffer[remapBufferCount]; remapBufferCount -= 1; nameString = oop6; /* begin popRemappableOop */ oop7 = remapBuffer[remapBufferCount]; remapBufferCount -= 1; results = oop7; for (i = 0; i <= (entryNameSize - 1); i += 1) { byteAtput(((((char *) nameString)) + 4) + i, entryName[i]); } /* begin storePointer:ofObject:withValue: */ if (results < youngStart) { possibleRootStoreIntovalue(results, nameString); } longAtput(((((char *) results)) + 4) + (0 << 2), nameString); /* begin storePointer:ofObject:withValue: */ if (results < youngStart) { possibleRootStoreIntovalue(results, createDateOop); } longAtput(((((char *) results)) + 4) + (1 << 2), createDateOop); /* begin storePointer:ofObject:withValue: */ if (results < youngStart) { possibleRootStoreIntovalue(results, modDateOop); } longAtput(((((char *) results)) + 4) + (2 << 2), modDateOop); if (dirFlag) { /* begin storePointer:ofObject:withValue: */ valuePointer = trueObj; if (results < youngStart) { possibleRootStoreIntovalue(results, valuePointer); } longAtput(((((char *) results)) + 4) + (3 << 2), valuePointer); } else { /* begin storePointer:ofObject:withValue: */ valuePointer1 = falseObj; if (results < youngStart) { possibleRootStoreIntovalue(results, valuePointer1); } longAtput(((((char *) results)) + 4) + (3 << 2), valuePointer1); } /* begin storePointer:ofObject:withValue: */ if (results < youngStart) { possibleRootStoreIntovalue(results, ((fileSize << 1) | 1)); } longAtput(((((char *) results)) + 4) + (4 << 2), ((fileSize << 1) | 1)); return results; } int makePointwithxValueyValue(int xValue, int yValue) { int pointResult; pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); /* begin storePointer:ofObject:withValue: */ if (pointResult < youngStart) { possibleRootStoreIntovalue(pointResult, ((xValue << 1) | 1)); } longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((xValue << 1) | 1)); /* begin storePointer:ofObject:withValue: */ if (pointResult < youngStart) { possibleRootStoreIntovalue(pointResult, ((yValue << 1) | 1)); } longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((yValue << 1) | 1)); return pointResult; } int mapInterpreterOops(void) { int i; int oop; int i1; nilObj = remap(nilObj); falseObj = remap(falseObj); trueObj = remap(trueObj); specialObjectsOop = remap(specialObjectsOop); stackPointer -= activeContext; activeContext = remap(activeContext); stackPointer += activeContext; theHomeContext = remap(theHomeContext); instructionPointer -= method; method = remap(method); instructionPointer += method; receiver = remap(receiver); messageSelector = remap(messageSelector); newMethod = remap(newMethod); for (i = 1; i <= remapBufferCount; i += 1) { oop = remapBuffer[i]; if (!((oop & 1))) { remapBuffer[i] = (remap(oop)); } } /* begin flushMethodCache */ for (i1 = 1; i1 <= 2048; i1 += 1) { methodCache[i1] = 0; } mcProbe = 0; } int mapPointersInObjectsFromto(int memStart, int memEnd) { int oop; int i; int fwdBlock; int fieldOffset; int fieldOop; int newOop; int fwdBlock1; int fieldOffset1; int fieldOop1; int newOop1; int i2; int oop1; int i1; int extra; int type; int extra1; int methodHeader; int size; int fwdBlock2; int fmt; int header; int newClassOop; int fwdBlock3; int classHeader; int classOop; int newClassHeader; int methodHeader1; int size1; int fwdBlock4; int fmt1; int header1; int newClassOop1; int fwdBlock5; int classHeader1; int classOop1; int newClassHeader1; int sz; int fwdBlock6; int realHeader; int header2; int extra3; int type2; int extra12; int sz1; int header11; int extra2; int type1; int extra11; /* begin mapInterpreterOops */ nilObj = remap(nilObj); falseObj = remap(falseObj); trueObj = remap(trueObj); specialObjectsOop = remap(specialObjectsOop); stackPointer -= activeContext; activeContext = remap(activeContext); stackPointer += activeContext; theHomeContext = remap(theHomeContext); instructionPointer -= method; method = remap(method); instructionPointer += method; receiver = remap(receiver); messageSelector = remap(messageSelector); newMethod = remap(newMethod); for (i2 = 1; i2 <= remapBufferCount; i2 += 1) { oop1 = remapBuffer[i2]; if (!((oop1 & 1))) { remapBuffer[i2] = (remap(oop1)); } } /* begin flushMethodCache */ for (i1 = 1; i1 <= 2048; i1 += 1) { methodCache[i1] = 0; } mcProbe = 0; for (i = 1; i <= rootTableCount; i += 1) { oop = rootTable[i]; if ((oop < memStart) || (oop >= memEnd)) { /* begin remapFieldsAndClassOf: */ /* begin lastPointerWhileForwarding: */ header = longAt(oop); if ((header & 2147483648U) != 0) { fwdBlock2 = header & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock2 > endOfMemory) && ((fwdBlock2 <= fwdTableNext) && ((fwdBlock2 & 3) == 0)))) { error("invalid fwd table entry"); } } header = longAt(fwdBlock2 + 4); } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 4) { if ((header & 3) == 0) { size = (longAt(oop - 8)) & 268435452; } else { size = header & 252; } fieldOffset = size - 4; goto l1; } if (fmt < 12) { fieldOffset = 0; goto l1; } methodHeader = longAt(oop + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerWhileForwarding: */; while (fieldOffset >= 4) { fieldOop = longAt(oop + fieldOffset); if (((fieldOop & 1) == 0) && (((longAt(fieldOop)) & 2147483648U) != 0)) { fwdBlock = (longAt(fieldOop)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } newOop = longAt(fwdBlock); longAtput(oop + fieldOffset, newOop); if ((oop < youngStart) && (newOop >= youngStart)) { beRootWhileForwarding(oop); } } fieldOffset -= 4; } /* begin remapClassOf: */ if (((longAt(oop)) & 3) == 3) { goto l2; } classHeader = longAt(oop - 4); classOop = classHeader & 4294967292U; if (((classOop & 1) == 0) && (((longAt(classOop)) & 2147483648U) != 0)) { fwdBlock3 = (longAt(classOop)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock3 > endOfMemory) && ((fwdBlock3 <= fwdTableNext) && ((fwdBlock3 & 3) == 0)))) { error("invalid fwd table entry"); } } newClassOop = longAt(fwdBlock3); newClassHeader = newClassOop | (classHeader & 3); longAtput(oop - 4, newClassHeader); if ((oop < youngStart) && (newClassOop >= youngStart)) { beRootWhileForwarding(oop); } } l2: /* end remapClassOf: */; } } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type = (longAt(memStart)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; oop = memStart + extra; while (oop < memEnd) { if (!(((longAt(oop)) & 3) == 2)) { /* begin remapFieldsAndClassOf: */ /* begin lastPointerWhileForwarding: */ header1 = longAt(oop); if ((header1 & 2147483648U) != 0) { fwdBlock4 = header1 & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock4 > endOfMemory) && ((fwdBlock4 <= fwdTableNext) && ((fwdBlock4 & 3) == 0)))) { error("invalid fwd table entry"); } } header1 = longAt(fwdBlock4 + 4); } fmt1 = (((unsigned) header1) >> 8) & 15; if (fmt1 < 4) { if ((header1 & 3) == 0) { size1 = (longAt(oop - 8)) & 268435452; } else { size1 = header1 & 252; } fieldOffset1 = size1 - 4; goto l3; } if (fmt1 < 12) { fieldOffset1 = 0; goto l3; } methodHeader1 = longAt(oop + 4); fieldOffset1 = (((((unsigned) methodHeader1) >> 10) & 255) * 4) + 4; l3: /* end lastPointerWhileForwarding: */; while (fieldOffset1 >= 4) { fieldOop1 = longAt(oop + fieldOffset1); if (((fieldOop1 & 1) == 0) && (((longAt(fieldOop1)) & 2147483648U) != 0)) { fwdBlock1 = (longAt(fieldOop1)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock1 > endOfMemory) && ((fwdBlock1 <= fwdTableNext) && ((fwdBlock1 & 3) == 0)))) { error("invalid fwd table entry"); } } newOop1 = longAt(fwdBlock1); longAtput(oop + fieldOffset1, newOop1); if ((oop < youngStart) && (newOop1 >= youngStart)) { beRootWhileForwarding(oop); } } fieldOffset1 -= 4; } /* begin remapClassOf: */ if (((longAt(oop)) & 3) == 3) { goto l4; } classHeader1 = longAt(oop - 4); classOop1 = classHeader1 & 4294967292U; if (((classOop1 & 1) == 0) && (((longAt(classOop1)) & 2147483648U) != 0)) { fwdBlock5 = (longAt(classOop1)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock5 > endOfMemory) && ((fwdBlock5 <= fwdTableNext) && ((fwdBlock5 & 3) == 0)))) { error("invalid fwd table entry"); } } newClassOop1 = longAt(fwdBlock5); newClassHeader1 = newClassOop1 | (classHeader1 & 3); longAtput(oop - 4, newClassHeader1); if ((oop < youngStart) && (newClassOop1 >= youngStart)) { beRootWhileForwarding(oop); } } l4: /* end remapClassOf: */; } /* begin objectAfterWhileForwarding: */ header2 = longAt(oop); if ((header2 & 2147483648U) == 0) { /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz1 = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header11 = longAt(oop); if ((header11 & 3) == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; goto l5; } else { sz1 = header11 & 252; goto l5; } l5: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(oop + sz1)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = (oop + sz1) + extra2; goto l6; } fwdBlock6 = header2 & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock6 > endOfMemory) && ((fwdBlock6 <= fwdTableNext) && ((fwdBlock6 & 3) == 0)))) { error("invalid fwd table entry"); } } realHeader = longAt(fwdBlock6 + 4); if ((realHeader & 3) == 0) { sz = (longAt(oop - 8)) & 268435452; } else { sz = realHeader & 252; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type2 = (longAt(oop + sz)) & 3; if (type2 > 1) { extra12 = 0; } else { if (type2 == 1) { extra12 = 4; } else { extra12 = 8; } } extra3 = extra12; oop = (oop + sz) + extra3; l6: /* end objectAfterWhileForwarding: */; } } int markAndTrace(int oop) { int action; int lastFieldOffset; int header; int header1; int type; int oop1; int lastFieldOffset1; int header2; int typeBits; int childType; int methodHeader; int sz; int fmt; int methodHeader1; int sz1; int fmt1; int header3; int type1; int header4; int type2; header = longAt(oop); header = (header & 4294967292U) | 2; if (oop >= youngStart) { header = header | 2147483648U; } longAtput(oop, header); parentField = 3; child = oop; /* begin lastPointerOf: */ fmt1 = (((unsigned) (longAt(oop))) >> 8) & 15; if (fmt1 < 4) { /* begin sizeBitsOfSafe: */ header3 = longAt(oop); /* begin rightType: */ if ((header3 & 252) == 0) { type1 = 0; goto l9; } else { if ((header3 & 126976) == 0) { type1 = 1; goto l9; } else { type1 = 3; goto l9; } } l9: /* end rightType: */; if (type1 == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; goto l10; } else { sz1 = header3 & 252; goto l10; } l10: /* end sizeBitsOfSafe: */; lastFieldOffset = sz1 - 4; goto l8; } if (fmt1 < 12) { lastFieldOffset = 0; goto l8; } methodHeader1 = longAt(oop + 4); lastFieldOffset = (((((unsigned) methodHeader1) >> 10) & 255) * 4) + 4; l8: /* end lastPointerOf: */; field = oop + lastFieldOffset; action = 1; while (!(action == 4)) { if (action == 1) { /* begin startField */ child = longAt(field); typeBits = child & 3; if ((typeBits & 1) == 1) { field -= 4; action = 1; goto l6; } if (typeBits == 0) { longAtput(field, parentField); parentField = field; action = 2; goto l6; } if (typeBits == 2) { if ((child & 126976) != 0) { child = child & 4294967292U; /* begin rightType: */ if ((child & 252) == 0) { childType = 0; goto l5; } else { if ((child & 126976) == 0) { childType = 1; goto l5; } else { childType = 3; goto l5; } } l5: /* end rightType: */; longAtput(field, child | childType); action = 3; goto l6; } else { child = longAt(field - 4); child = child & 4294967292U; longAtput(field - 4, parentField); parentField = (field - 4) | 1; action = 2; goto l6; } } l6: /* end startField */; } if (action == 2) { /* begin startObj */ oop1 = child; if (oop1 < youngStart) { field = oop1; action = 3; goto l2; } header2 = longAt(oop1); if ((header2 & 2147483648U) == 0) { header2 = header2 & 4294967292U; header2 = (header2 | 2147483648U) | 2; longAtput(oop1, header2); /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(oop1))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header4 = longAt(oop1); /* begin rightType: */ if ((header4 & 252) == 0) { type2 = 0; goto l11; } else { if ((header4 & 126976) == 0) { type2 = 1; goto l11; } else { type2 = 3; goto l11; } } l11: /* end rightType: */; if (type2 == 0) { sz = (longAt(oop1 - 8)) & 4294967292U; goto l12; } else { sz = header4 & 252; goto l12; } l12: /* end sizeBitsOfSafe: */; lastFieldOffset1 = sz - 4; goto l7; } if (fmt < 12) { lastFieldOffset1 = 0; goto l7; } methodHeader = longAt(oop1 + 4); lastFieldOffset1 = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l7: /* end lastPointerOf: */; field = oop1 + lastFieldOffset1; action = 1; goto l2; } else { field = oop1; action = 3; goto l2; } l2: /* end startObj */; } if (action == 3) { /* begin upward */ if ((parentField & 1) == 1) { if (parentField == 3) { header1 = (longAt(field)) & 4294967292U; /* begin rightType: */ if ((header1 & 252) == 0) { type = 0; goto l3; } else { if ((header1 & 126976) == 0) { type = 1; goto l3; } else { type = 3; goto l3; } } l3: /* end rightType: */; longAtput(field, header1 + type); action = 4; goto l1; } else { child = field; field = parentField - 1; parentField = longAt(field); header1 = longAt(field + 4); /* begin rightType: */ if ((header1 & 252) == 0) { type = 0; goto l4; } else { if ((header1 & 126976) == 0) { type = 1; goto l4; } else { type = 3; goto l4; } } l4: /* end rightType: */; longAtput(field, child + type); field += 4; header1 = header1 & 4294967292U; longAtput(field, header1 + type); action = 3; goto l1; } } else { child = field; field = parentField; parentField = longAt(field); longAtput(field, child); field -= 4; action = 1; goto l1; } l1: /* end upward */; } } } int markAndTraceInterpreterOops(void) { int i; int oop; markAndTrace(specialObjectsOop); markAndTrace(activeContext); markAndTrace(messageSelector); markAndTrace(newMethod); for (i = 1; i <= remapBufferCount; i += 1) { oop = remapBuffer[i]; if (!((oop & 1))) { markAndTrace(oop); } } } int markPhase(void) { int oop; int i; int i1; int oop1; freeSmallContexts = 1; freeLargeContexts = 1; /* begin markAndTraceInterpreterOops */ markAndTrace(specialObjectsOop); markAndTrace(activeContext); markAndTrace(messageSelector); markAndTrace(newMethod); for (i1 = 1; i1 <= remapBufferCount; i1 += 1) { oop1 = remapBuffer[i1]; if (!((oop1 & 1))) { markAndTrace(oop1); } } for (i = 1; i <= rootTableCount; i += 1) { oop = rootTable[i]; if (!((oop & 1))) { markAndTrace(oop); } } } int mergewith(int sourceWord, int destinationWord) { int (*mergeFnwith)(int, int); mergeFnwith = ((int (*)(int, int)) (opTable[combinationRule + 1])); mergeFnwith; return mergeFnwith(sourceWord, destinationWord); } int methodClassOf(int methodPointer) { return longAt(((((char *) (longAt(((((char *) methodPointer)) + 4) + (((((((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 10) & 255) - 1) + 1) << 2))))) + 4) + (1 << 2)); } int netAddressToInt(int oop) { int sz; int sz1; int header; int fmt; int ccIndex; int cl; /* begin assertClassOf:is: */ if ((oop & 1)) { successFlag = false; goto l2; } ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(oop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))) && successFlag; l2: /* end assertClassOf:is: */; if (successFlag) { /* begin lengthOf: */ header = longAt(oop); if ((header & 3) == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; } else { sz1 = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { sz = ((unsigned) (sz1 - 4)) >> 2; goto l1; } else { sz = (sz1 - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; if (!(sz == 4)) { return primitiveFail(); } } if (successFlag) { return (((byteAt(((((char *) oop)) + 4) + 3)) + ((byteAt(((((char *) oop)) + 4) + 2)) << 8)) + ((byteAt(((((char *) oop)) + 4) + 1)) << 16)) + ((byteAt(((((char *) oop)) + 4) + 0)) << 24); } } int newActiveContext(int aContext) { int tmp; /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); if (aContext < youngStart) { beRootIfOld(aContext); } activeContext = aContext; /* begin fetchContextRegisters: */ tmp = longAt(((((char *) aContext)) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) aContext)) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = aContext; } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) aContext)) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) aContext)) + 4) + (2 << 2))) >> 1); stackPointer = (aContext + 4) + (((6 + tmp) - 1) * 4); } int newObjectHash(void) { lastHash = (13849 + (27181 * lastHash)) & 65535; return lastHash; } int nilObject(void) { return nilObj; } int objectAfter(int oop) { int sz; int header; int extra; int type; int extra1; if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type = (longAt(oop + sz)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; return (oop + sz) + extra; } int objectAfterWhileForwarding(int oop) { int sz; int fwdBlock; int realHeader; int header; int extra; int type; int extra1; int sz1; int header1; int extra2; int type1; int extra11; header = longAt(oop); if ((header & 2147483648U) == 0) { /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz1 = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header1 = longAt(oop); if ((header1 & 3) == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz1 = header1 & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(oop + sz1)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; return (oop + sz1) + extra2; } fwdBlock = header & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } realHeader = longAt(fwdBlock + 4); if ((realHeader & 3) == 0) { sz = (longAt(oop - 8)) & 268435452; } else { sz = realHeader & 252; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type = (longAt(oop + sz)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; return (oop + sz) + extra; } int okArrayClass(int cl) { return (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) || ((cl == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)))) || (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2))))); } int okStreamArrayClass(int cl) { return (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) || ((cl == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) || ((cl == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))) || (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)))))); } int okayActiveProcessStack(void) { int cntxt; cntxt = activeContext; while (!(cntxt == nilObj)) { okayFields(cntxt); cntxt = longAt(((((char *) cntxt)) + 4) + (0 << 2)); } } int okayFields(int oop) { int i; int fieldOop; if ((oop == null) || (oop == 0)) { return true; } if ((oop & 1)) { return true; } okayOop(oop); oopHasOkayClass(oop); if (!(((((unsigned) (longAt(oop))) >> 8) & 15) <= 4)) { return true; } i = (lengthOf(oop)) - 1; while (i >= 0) { fieldOop = longAt(((((char *) oop)) + 4) + (i << 2)); if (!((fieldOop & 1))) { okayOop(fieldOop); oopHasOkayClass(fieldOop); } i -= 1; } } int okayInterpreterObjects(void) { int i; int oop; int oopOrZero; int cntxt; okayFields(nilObj); okayFields(falseObj); okayFields(trueObj); okayFields(specialObjectsOop); okayFields(activeContext); okayFields(method); okayFields(receiver); okayFields(theHomeContext); okayFields(messageSelector); okayFields(newMethod); for (i = 1; i <= 512; i += 1) { oopOrZero = methodCache[i]; if (!(oopOrZero == 0)) { okayFields(methodCache[i]); okayFields(methodCache[i + 512]); okayFields(methodCache[i + (2 * 512)]); } } for (i = 1; i <= remapBufferCount; i += 1) { oop = remapBuffer[i]; if (!((oop & 1))) { okayFields(oop); } } /* begin okayActiveProcessStack */ cntxt = activeContext; while (!(cntxt == nilObj)) { okayFields(cntxt); cntxt = longAt(((((char *) cntxt)) + 4) + (0 << 2)); } } int okayOop(int oop) { int sz; int type; int fmt; int header; if ((oop & 1)) { return true; } if (!((0 < oop) && (oop < endOfMemory))) { error("oop is not a valid address"); } if (!((oop % 4) == 0)) { error("oop is not a word-aligned address"); } /* begin sizeBitsOf: */ header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; if (!((oop + sz) < endOfMemory)) { error("oop size would make it extend beyond the end of memory"); } type = (longAt(oop)) & 3; if (type == 2) { error("oop is a free chunk, not an object"); } if (type == 3) { if (((((unsigned) (longAt(oop))) >> 12) & 31) == 0) { error("cannot have zero compact class field in a short header"); } } if (type == 1) { if (!((oop >= 4) && (((longAt(oop - 4)) & 3) == type))) { error("class header word has wrong type"); } } if (type == 0) { if (!((oop >= 8) && ((((longAt(oop - 8)) & 3) == type) && (((longAt(oop - 4)) & 3) == type)))) { error("class header word has wrong type"); } } fmt = (((unsigned) (longAt(oop))) >> 8) & 15; if (((fmt == 4) || (fmt == 5)) || (fmt == 7)) { error("oop has an unknown format type"); } if (!(((longAt(oop)) & 536870912) == 0)) { error("unused header bit 30 is set; should be zero"); } if ((((longAt(oop)) & 1073741824) == 1) && (oop >= youngStart)) { error("root bit is set in a young object"); } return true; } int oopFromChunk(int chunk) { int extra; int type; int extra1; /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; return chunk + extra; } int oopHasOkayClass(int oop) { int behaviorFormatBits; int oopClass; int formatMask; int oopFormatBits; int ccIndex; okayOop(oop); /* begin fetchClassOf: */ if ((oop & 1)) { oopClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(oop))) >> 12) & 31) - 1; if (ccIndex < 0) { oopClass = (longAt(oop - 4)) & 4294967292U; goto l1; } else { oopClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; if ((oopClass & 1)) { error("a SmallInteger is not a valid class or behavior"); } okayOop(oopClass); if (!((((((unsigned) (longAt(oopClass))) >> 8) & 15) <= 4) && ((lengthOf(oopClass)) >= 3))) { error("a class (behavior) must be a pointers object of size >= 3"); } if (((((unsigned) (longAt(oop))) >> 8) & 15) >= 8) { formatMask = 3072; } else { formatMask = 3840; } behaviorFormatBits = ((longAt(((((char *) oopClass)) + 4) + (2 << 2))) - 1) & formatMask; oopFormatBits = (longAt(oop)) & formatMask; if (!(behaviorFormatBits == oopFormatBits)) { error("object and its class (behavior) formats differ"); } return true; } int partitionedANDtonBitsnPartitions(int word1, int word2, int nBits, int nParts) { int mask; int i; int result; mask = (1 << nBits) - 1; result = 0; for (i = 1; i <= nParts; i += 1) { if ((word1 & mask) == mask) { result = result | (word2 & mask); } mask = mask << nBits; } return result; } int partitionedAddtonBitsnPartitions(int word1, int word2, int nBits, int nParts) { int mask; int sum; int i; int result; mask = (1 << nBits) - 1; result = 0; for (i = 1; i <= nParts; i += 1) { sum = (word1 & mask) + (word2 & mask); if (sum <= mask) { result = result | sum; } else { result = result | mask; } mask = mask << nBits; } return result; } int partitionedMaxwithnBitsnPartitions(int word1, int word2, int nBits, int nParts) { int mask; int i; int result; mask = (1 << nBits) - 1; result = 0; for (i = 1; i <= nParts; i += 1) { result = result | ((((word2 & mask) < (word1 & mask)) ? (word1 & mask) : (word2 & mask))); mask = mask << nBits; } return result; } int partitionedMinwithnBitsnPartitions(int word1, int word2, int nBits, int nParts) { int mask; int i; int result; mask = (1 << nBits) - 1; result = 0; for (i = 1; i <= nParts; i += 1) { result = result | ((((word2 & mask) < (word1 & mask)) ? (word2 & mask) : (word1 & mask))); mask = mask << nBits; } return result; } int partitionedSubfromnBitsnPartitions(int word1, int word2, int nBits, int nParts) { int mask; int i; int p1; int p2; int result; mask = (1 << nBits) - 1; result = 0; for (i = 1; i <= nParts; i += 1) { p1 = word1 & mask; p2 = word2 & mask; if (p1 < p2) { result = result | (p2 - p1); } else { result = result | (p1 - p2); } mask = mask << nBits; } return result; } int pickSourcePixelsnullMapsrcMaskdestMask(int nPix, int nullMap, int sourcePixMask, int destPixMask) { if (sourcePixSize >= 16) { return pickSourcePixelsRGBnullMapsrcMaskdestMask(nPix, nullMap, sourcePixMask, destPixMask); } if (nullMap) { return pickSourcePixelsNullMapsrcMaskdestMask(nPix, sourcePixMask, destPixMask); } return pickSourcePixelssrcMaskdestMask(nPix, sourcePixMask, destPixMask); } int pickSourcePixelssrcMaskdestMask(int nPix, int sourcePixMask, int destPixMask) { int sourceWord; int destWord; int sourcePix; int destPix; int i; sourceWord = longAt(sourceIndex); destWord = 0; for (i = 1; i <= nPix; i += 1) { sourcePix = (((unsigned) sourceWord) >> ((32 - sourcePixSize) - srcBitIndex)) & sourcePixMask; destPix = (longAt(((((char *) colorMap)) + 4) + (sourcePix << 2))) & destPixMask; destWord = (destWord << destPixSize) | destPix; if ((srcBitIndex += sourcePixSize) > 31) { srcBitIndex -= 32; sourceIndex += 4; sourceWord = longAt(sourceIndex); } } return destWord; } int pickSourcePixelsNullMapsrcMaskdestMask(int nPix, int sourcePixMask, int destPixMask) { int sourceWord; int destWord; int sourcePix; int i; sourceWord = longAt(sourceIndex); destWord = 0; for (i = 1; i <= nPix; i += 1) { sourcePix = (((unsigned) sourceWord) >> ((32 - sourcePixSize) - srcBitIndex)) & sourcePixMask; destWord = (destWord << destPixSize) | (sourcePix & destPixMask); if ((srcBitIndex += sourcePixSize) > 31) { srcBitIndex -= 32; sourceIndex += 4; sourceWord = longAt(sourceIndex); } } return destWord; } int pickSourcePixelsRGBnullMapsrcMaskdestMask(int nPix, int nullMap, int sourcePixMask, int destPixMask) { int sourceWord; int destWord; int sourcePix; int destPix; int i; int mask; int srcPix; int destPix1; int d; int mask3; int srcPix1; int destPix2; int d1; int mask4; int srcPix2; int destPix3; int d2; int mask5; int srcPix3; int destPix4; int d3; sourceWord = longAt(sourceIndex); destWord = 0; for (i = 1; i <= nPix; i += 1) { sourcePix = (((unsigned) sourceWord) >> ((32 - sourcePixSize) - srcBitIndex)) & sourcePixMask; if (nullMap) { if (sourcePixSize == 16) { /* begin rgbMap:from:to: */ if ((d = 8 - 5) > 0) { mask = (1 << 5) - 1; srcPix = sourcePix << d; mask = mask << d; destPix1 = srcPix & mask; mask = mask << 8; srcPix = srcPix << d; destPix = (destPix1 + (srcPix & mask)) + ((srcPix << d) & (mask << 8)); goto l1; } else { if (d == 0) { destPix = sourcePix; goto l1; } if (sourcePix == 0) { destPix = sourcePix; goto l1; } d = 5 - 8; mask = (1 << 8) - 1; srcPix = ((unsigned) sourcePix) >> d; destPix1 = srcPix & mask; mask = mask << 8; srcPix = ((unsigned) srcPix) >> d; destPix1 = (destPix1 + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << 8)); if (destPix1 == 0) { destPix = 1; goto l1; } destPix = destPix1; goto l1; } l1: /* end rgbMap:from:to: */; } else { /* begin rgbMap:from:to: */ if ((d1 = 5 - 8) > 0) { mask3 = (1 << 8) - 1; srcPix1 = sourcePix << d1; mask3 = mask3 << d1; destPix2 = srcPix1 & mask3; mask3 = mask3 << 5; srcPix1 = srcPix1 << d1; destPix = (destPix2 + (srcPix1 & mask3)) + ((srcPix1 << d1) & (mask3 << 5)); goto l2; } else { if (d1 == 0) { destPix = sourcePix; goto l2; } if (sourcePix == 0) { destPix = sourcePix; goto l2; } d1 = 8 - 5; mask3 = (1 << 5) - 1; srcPix1 = ((unsigned) sourcePix) >> d1; destPix2 = srcPix1 & mask3; mask3 = mask3 << 5; srcPix1 = ((unsigned) srcPix1) >> d1; destPix2 = (destPix2 + (srcPix1 & mask3)) + ((((unsigned) srcPix1) >> d1) & (mask3 << 5)); if (destPix2 == 0) { destPix = 1; goto l2; } destPix = destPix2; goto l2; } l2: /* end rgbMap:from:to: */; } } else { if (sourcePixSize == 16) { /* begin rgbMap:from:to: */ if ((d2 = cmBitsPerColor - 5) > 0) { mask4 = (1 << 5) - 1; srcPix2 = sourcePix << d2; mask4 = mask4 << d2; destPix3 = srcPix2 & mask4; mask4 = mask4 << cmBitsPerColor; srcPix2 = srcPix2 << d2; sourcePix = (destPix3 + (srcPix2 & mask4)) + ((srcPix2 << d2) & (mask4 << cmBitsPerColor)); goto l3; } else { if (d2 == 0) { sourcePix = sourcePix; goto l3; } if (sourcePix == 0) { sourcePix = sourcePix; goto l3; } d2 = 5 - cmBitsPerColor; mask4 = (1 << cmBitsPerColor) - 1; srcPix2 = ((unsigned) sourcePix) >> d2; destPix3 = srcPix2 & mask4; mask4 = mask4 << cmBitsPerColor; srcPix2 = ((unsigned) srcPix2) >> d2; destPix3 = (destPix3 + (srcPix2 & mask4)) + ((((unsigned) srcPix2) >> d2) & (mask4 << cmBitsPerColor)); if (destPix3 == 0) { sourcePix = 1; goto l3; } sourcePix = destPix3; goto l3; } l3: /* end rgbMap:from:to: */; } else { /* begin rgbMap:from:to: */ if ((d3 = cmBitsPerColor - 8) > 0) { mask5 = (1 << 8) - 1; srcPix3 = sourcePix << d3; mask5 = mask5 << d3; destPix4 = srcPix3 & mask5; mask5 = mask5 << cmBitsPerColor; srcPix3 = srcPix3 << d3; sourcePix = (destPix4 + (srcPix3 & mask5)) + ((srcPix3 << d3) & (mask5 << cmBitsPerColor)); goto l4; } else { if (d3 == 0) { sourcePix = sourcePix; goto l4; } if (sourcePix == 0) { sourcePix = sourcePix; goto l4; } d3 = 8 - cmBitsPerColor; mask5 = (1 << cmBitsPerColor) - 1; srcPix3 = ((unsigned) sourcePix) >> d3; destPix4 = srcPix3 & mask5; mask5 = mask5 << cmBitsPerColor; srcPix3 = ((unsigned) srcPix3) >> d3; destPix4 = (destPix4 + (srcPix3 & mask5)) + ((((unsigned) srcPix3) >> d3) & (mask5 << cmBitsPerColor)); if (destPix4 == 0) { sourcePix = 1; goto l4; } sourcePix = destPix4; goto l4; } l4: /* end rgbMap:from:to: */; } destPix = (longAt(((((char *) colorMap)) + 4) + (sourcePix << 2))) & destPixMask; } destWord = (destWord << destPixSize) | destPix; if ((srcBitIndex += sourcePixSize) > 31) { srcBitIndex -= 32; sourceIndex += 4; sourceWord = longAt(sourceIndex); } } return destWord; } int pixMaskwith(int sourceWord, int destinationWord) { int mask; int i; int result; /* begin partitionedAND:to:nBits:nPartitions: */ mask = (1 << destPixSize) - 1; result = 0; for (i = 1; i <= pixPerWord; i += 1) { if (((~sourceWord) & mask) == mask) { result = result | (destinationWord & mask); } mask = mask << destPixSize; } return result; } int pixPaintwith(int sourceWord, int destinationWord) { if (sourceWord == 0) { return destinationWord; } return sourceWord | (partitionedANDtonBitsnPartitions(~sourceWord, destinationWord, destPixSize, pixPerWord)); } int pop(int nItems) { stackPointer -= nItems * 4; } int popthenPush(int nItems, int oop) { int sp; longAtput(sp = stackPointer - ((nItems - 1) * 4), oop); stackPointer = sp; } double popFloat(void) { int top; double result; int top1; int ccIndex; int cl; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; top = top1; /* begin assertClassOf:is: */ if ((top & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(top))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(top - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { fetchFloatAtinto(top + 4, result); } return result; } int popInteger(void) { int integerPointer; int top; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { return (integerPointer >> 1); } else { successFlag = false; return 1; } } int popPos32BitInteger(void) { int top; int top1; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; top = top1; return positive32BitValueOf(top); } int popRemappableOop(void) { int oop; oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; return oop; } int popStack(void) { int top; top = longAt(stackPointer); stackPointer -= 4; return top; } int positive32BitIntegerFor(int integerValue) { int newLargeInteger; if ((integerValue >= 0) && ((integerValue ^ (integerValue << 1)) >= 0)) { return ((integerValue << 1) | 1); } newLargeInteger = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)), 8, 0); byteAtput(((((char *) newLargeInteger)) + 4) + 3, (((unsigned) integerValue) >> 24) & 255); byteAtput(((((char *) newLargeInteger)) + 4) + 2, (((unsigned) integerValue) >> 16) & 255); byteAtput(((((char *) newLargeInteger)) + 4) + 1, (((unsigned) integerValue) >> 8) & 255); byteAtput(((((char *) newLargeInteger)) + 4) + 0, integerValue & 255); return newLargeInteger; } int positive32BitValueOf(int oop) { int sz; int value; int sz1; int header; int fmt; int ccIndex; int cl; if ((oop & 1)) { value = (oop >> 1); if (value < 0) { return primitiveFail(); } return value; } /* begin assertClassOf:is: */ if ((oop & 1)) { successFlag = false; goto l2; } ccIndex = (((unsigned) (longAt(oop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(oop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (13 << 2)))) && successFlag; l2: /* end assertClassOf:is: */; if (successFlag) { /* begin lengthOf: */ header = longAt(oop); if ((header & 3) == 0) { sz1 = (longAt(oop - 8)) & 4294967292U; } else { sz1 = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { sz = ((unsigned) (sz1 - 4)) >> 2; goto l1; } else { sz = (sz1 - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; if (!(sz == 4)) { return primitiveFail(); } } if (successFlag) { return (((byteAt(((((char *) oop)) + 4) + 0)) + ((byteAt(((((char *) oop)) + 4) + 1)) << 8)) + ((byteAt(((((char *) oop)) + 4) + 2)) << 16)) + ((byteAt(((((char *) oop)) + 4) + 3)) << 24); } } int possibleRootStoreIntovalue(int oop, int valueObj) { int header; if ((valueObj >= youngStart) && (!((valueObj & 1)))) { header = longAt(oop); if ((header & 1073741824) == 0) { if (rootTableCount < 1000) { rootTableCount += 1; rootTable[rootTableCount] = oop; longAtput(oop, header | 1073741824); } } } } int postGCAction(void) { if (activeContext < youngStart) { beRootIfOld(activeContext); } if (theHomeContext < youngStart) { beRootIfOld(theHomeContext); } } int preGCAction(int fullGCFlag) { } int prepareForwardingTableForBecomingwith(int array1, int array2) { int entriesAvailable; int fwdBlock; int fieldOffset; int oop1; int oop2; int entriesNeeded; int originalHeader; int originalHeaderType; int originalHeader1; int originalHeaderType1; int methodHeader; int sz; int fmt; int header; int type; entriesNeeded = 2 * (((int) (lastPointerOf(array1)) >> 2)); entriesAvailable = fwdTableInit(); if (entriesAvailable < entriesNeeded) { initializeMemoryFirstFree(freeBlock); return false; } /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(array1))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header = longAt(array1); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l4; } else { if ((header & 126976) == 0) { type = 1; goto l4; } else { type = 3; goto l4; } } l4: /* end rightType: */; if (type == 0) { sz = (longAt(array1 - 8)) & 4294967292U; goto l5; } else { sz = header & 252; goto l5; } l5: /* end sizeBitsOfSafe: */; fieldOffset = sz - 4; goto l3; } if (fmt < 12) { fieldOffset = 0; goto l3; } methodHeader = longAt(array1 + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l3: /* end lastPointerOf: */; while (fieldOffset >= 4) { oop1 = longAt(array1 + fieldOffset); oop2 = longAt(array2 + fieldOffset); /* begin fwdBlockGet */ fwdTableNext += 8; if (fwdTableNext <= fwdTableLast) { fwdBlock = fwdTableNext; goto l1; } else { fwdBlock = null; goto l1; } l1: /* end fwdBlockGet */; /* begin initForwardBlock:mapping:to: */ originalHeader = longAt(oop1); if (checkAssertions) { if (fwdBlock == null) { error("ran out of forwarding blocks in become"); } if ((originalHeader & 2147483648U) != 0) { error("object already has a forwarding table entry"); } } originalHeaderType = originalHeader & 3; longAtput(fwdBlock, oop2); longAtput(fwdBlock + 4, originalHeader); longAtput(oop1, fwdBlock | (2147483648U | originalHeaderType)); /* begin fwdBlockGet */ fwdTableNext += 8; if (fwdTableNext <= fwdTableLast) { fwdBlock = fwdTableNext; goto l2; } else { fwdBlock = null; goto l2; } l2: /* end fwdBlockGet */; /* begin initForwardBlock:mapping:to: */ originalHeader1 = longAt(oop2); if (checkAssertions) { if (fwdBlock == null) { error("ran out of forwarding blocks in become"); } if ((originalHeader1 & 2147483648U) != 0) { error("object already has a forwarding table entry"); } } originalHeaderType1 = originalHeader1 & 3; longAtput(fwdBlock, oop1); longAtput(fwdBlock + 4, originalHeader1); longAtput(oop2, fwdBlock | (2147483648U | originalHeaderType1)); fieldOffset -= 4; } return true; } int primIndex(void) { return primitiveIndex; } int primitiveAdd(void) { int arg; int result; int rcvr; int sp; rcvr = longAt(stackPointer - (1 * 4)); arg = longAt(stackPointer - (0 * 4)); /* begin pop: */ stackPointer -= 2 * 4; /* begin success: */ successFlag = (((rcvr & arg) & 1) != 0) && successFlag; if (successFlag) { result = ((rcvr >> 1)) + ((arg >> 1)); } /* begin checkIntegerResult:from: */ if (successFlag && ((result ^ (result << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((result << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(1); } } int primitiveArctan(void) { double rcvr; rcvr = popFloat(); if (successFlag) { pushFloat(atan(rcvr)); } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveArrayBecome(void) { int arg; int rcvr; int top; int successValue; int i; int fieldOffset; int oop1; int oop2; int hdr1; int hdr2; int fwdBlock; int fwdHeader; int fwdBlock1; int fwdHeader1; int methodHeader; int sz; int fmt; int header; int type; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; arg = top; rcvr = longAt(stackPointer); /* begin success: */ /* begin become:with: */ if (!((fetchClassOf(rcvr)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2))))) { successValue = false; goto l4; } if (!((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2))))) { successValue = false; goto l4; } if (!((lastPointerOf(rcvr)) == (lastPointerOf(arg)))) { successValue = false; goto l4; } if (!(containOnlyOopsand(rcvr, arg))) { successValue = false; goto l4; } if (!(prepareForwardingTableForBecomingwith(rcvr, arg))) { successValue = false; goto l4; } if (allYoungand(rcvr, arg)) { mapPointersInObjectsFromto(youngStart, endOfMemory); } else { mapPointersInObjectsFromto(startOfMemory(), endOfMemory); } /* begin restoreHeadersAfterBecoming:with: */ /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(rcvr))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header = longAt(rcvr); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l2; } else { if ((header & 126976) == 0) { type = 1; goto l2; } else { type = 3; goto l2; } } l2: /* end rightType: */; if (type == 0) { sz = (longAt(rcvr - 8)) & 4294967292U; goto l3; } else { sz = header & 252; goto l3; } l3: /* end sizeBitsOfSafe: */; fieldOffset = sz - 4; goto l1; } if (fmt < 12) { fieldOffset = 0; goto l1; } methodHeader = longAt(rcvr + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerOf: */; while (fieldOffset >= 4) { oop1 = longAt(rcvr + fieldOffset); oop2 = longAt(arg + fieldOffset); /* begin restoreHeaderOf: */ fwdHeader = longAt(oop1); fwdBlock = fwdHeader & 2147483644; if (checkAssertions) { if ((fwdHeader & 2147483648U) == 0) { error("attempting to restore the header of an object that has no forwarding block"); } /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } longAtput(oop1, longAt(fwdBlock + 4)); /* begin restoreHeaderOf: */ fwdHeader1 = longAt(oop2); fwdBlock1 = fwdHeader1 & 2147483644; if (checkAssertions) { if ((fwdHeader1 & 2147483648U) == 0) { error("attempting to restore the header of an object that has no forwarding block"); } /* begin fwdBlockValidate: */ if (!((fwdBlock1 > endOfMemory) && ((fwdBlock1 <= fwdTableNext) && ((fwdBlock1 & 3) == 0)))) { error("invalid fwd table entry"); } } longAtput(oop2, longAt(fwdBlock1 + 4)); /* begin exchangeHashBits:with: */ hdr1 = longAt(oop1); hdr2 = longAt(oop2); longAtput(oop1, (hdr1 & 3758227455U) | (hdr2 & 536739840)); longAtput(oop2, (hdr2 & 3758227455U) | (hdr1 & 536739840)); fieldOffset -= 4; } initializeMemoryFirstFree(freeBlock); successValue = true; l4: /* end become:with: */; successFlag = successValue && successFlag; /* begin flushMethodCache */ for (i = 1; i <= 2048; i += 1) { methodCache[i] = 0; } mcProbe = 0; if (!(successFlag)) { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveAsFloat(void) { int arg; int integerPointer; int top; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { arg = (integerPointer >> 1); goto l1; } else { successFlag = false; arg = 1; goto l1; } l1: /* end popInteger */; if (successFlag) { pushFloat(((double) arg)); } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveAsOop(void) { int thisReceiver; int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; thisReceiver = top; /* begin success: */ successFlag = (!((thisReceiver & 1))) && successFlag; if (successFlag) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((((((unsigned) (longAt(thisReceiver))) >> 17) & 4095) << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveAsyncFileClose(void) { AsyncFile *f; f = asyncFileValueOf(longAt(stackPointer)); if (successFlag) { asyncFileClose(f); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveAsyncFileOpen(void) { AsyncFile *f; int semaIndex; int writeFlag; int fileName; int fmt; int fileNameSize; int fOop; int sp; int integerPointer; int oop; int successValue; int sz; int header; int fmt1; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { semaIndex = (integerPointer >> 1); goto l1; } else { primitiveFail(); semaIndex = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin booleanValueOf: */ if ((longAt(stackPointer - (1 * 4))) == trueObj) { writeFlag = true; goto l2; } if ((longAt(stackPointer - (1 * 4))) == falseObj) { writeFlag = false; goto l2; } successFlag = false; writeFlag = null; l2: /* end booleanValueOf: */; /* begin stackObjectValue: */ oop = longAt(stackPointer - (2 * 4)); if ((oop & 1)) { primitiveFail(); fileName = null; goto l3; } fileName = oop; l3: /* end stackObjectValue: */; if (!(successFlag)) { return null; } fmt = (((unsigned) (longAt(fileName))) >> 8) & 15; /* begin success: */ successValue = (fmt >= 8) && (fmt <= 11); successFlag = successValue && successFlag; /* begin lengthOf: */ header = longAt(fileName); if ((header & 3) == 0) { sz = (longAt(fileName - 8)) & 4294967292U; } else { sz = header & 252; } fmt1 = (((unsigned) header) >> 8) & 15; if (fmt1 < 8) { fileNameSize = ((unsigned) (sz - 4)) >> 2; goto l4; } else { fileNameSize = (sz - 4) - (fmt1 & 3); goto l4; } l4: /* end lengthOf: */; if (successFlag) { fOop = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)), sizeof(AsyncFile)); f = asyncFileValueOf(fOop); } if (successFlag) { asyncFileOpen(f, fileName + 4, fileNameSize, writeFlag, semaIndex); } if (successFlag) { /* begin pop: */ stackPointer -= 4 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, fOop); stackPointer = sp; } } int primitiveAsyncFileReadResult(void) { AsyncFile *f; int startIndex; int buffer; int bufferPtr; int bufferSize; int count; int fmt; int r; int integerPointer; int integerPointer1; int oop; int successValue; int successValue1; int sp; int sz; int header; int fmt1; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { startIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); startIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin stackObjectValue: */ oop = longAt(stackPointer - (2 * 4)); if ((oop & 1)) { primitiveFail(); buffer = null; goto l3; } buffer = oop; l3: /* end stackObjectValue: */; f = asyncFileValueOf(longAt(stackPointer - (3 * 4))); if (!(successFlag)) { return null; } fmt = (((unsigned) (longAt(buffer))) >> 8) & 15; /* begin success: */ successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); successFlag = successValue && successFlag; /* begin lengthOf: */ header = longAt(buffer); if ((header & 3) == 0) { sz = (longAt(buffer - 8)) & 4294967292U; } else { sz = header & 252; } fmt1 = (((unsigned) header) >> 8) & 15; if (fmt1 < 8) { bufferSize = ((unsigned) (sz - 4)) >> 2; goto l4; } else { bufferSize = (sz - 4) - (fmt1 & 3); goto l4; } l4: /* end lengthOf: */; if (fmt == 6) { count = count * 4; startIndex = ((startIndex - 1) * 4) + 1; bufferSize = bufferSize * 4; } /* begin success: */ successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize); successFlag = successValue1 && successFlag; bufferPtr = ((buffer + 4) + startIndex) - 1; if (successFlag) { r = asyncFileReadResult(f, bufferPtr, count); } if (successFlag) { /* begin pop: */ stackPointer -= 5 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((r << 1) | 1)); stackPointer = sp; } } int primitiveAsyncFileReadStart(void) { AsyncFile *f; int fPosition; int count; int integerPointer; int integerPointer1; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { fPosition = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); fPosition = 0; goto l2; } l2: /* end stackIntegerValue: */; f = asyncFileValueOf(longAt(stackPointer - (2 * 4))); if (successFlag) { asyncFileReadStart(f, fPosition, count); } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; } } int primitiveAsyncFileWriteResult(void) { AsyncFile *f; int r; int sp; f = asyncFileValueOf(longAt(stackPointer)); if (successFlag) { r = asyncFileWriteResult(f); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((r << 1) | 1)); stackPointer = sp; } } int primitiveAsyncFileWriteStart(void) { AsyncFile *f; int startIndex; int buffer; int bufferPtr; int bufferSize; int count; int fPosition; int fmt; int integerPointer; int integerPointer1; int oop; int integerPointer2; int successValue; int sz; int header; int fmt1; int successValue1; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { startIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); startIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin stackObjectValue: */ oop = longAt(stackPointer - (2 * 4)); if ((oop & 1)) { primitiveFail(); buffer = null; goto l3; } buffer = oop; l3: /* end stackObjectValue: */; /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (3 * 4)); if ((integerPointer2 & 1)) { fPosition = (integerPointer2 >> 1); goto l4; } else { primitiveFail(); fPosition = 0; goto l4; } l4: /* end stackIntegerValue: */; f = asyncFileValueOf(longAt(stackPointer - (4 * 4))); if (!(successFlag)) { return null; } fmt = (((unsigned) (longAt(buffer))) >> 8) & 15; /* begin success: */ successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); successFlag = successValue && successFlag; /* begin lengthOf: */ header = longAt(buffer); if ((header & 3) == 0) { sz = (longAt(buffer - 8)) & 4294967292U; } else { sz = header & 252; } fmt1 = (((unsigned) header) >> 8) & 15; if (fmt1 < 8) { bufferSize = ((unsigned) (sz - 4)) >> 2; goto l5; } else { bufferSize = (sz - 4) - (fmt1 & 3); goto l5; } l5: /* end lengthOf: */; if (fmt == 6) { count = count * 4; startIndex = ((startIndex - 1) * 4) + 1; bufferSize = bufferSize * 4; } /* begin success: */ successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize); successFlag = successValue1 && successFlag; bufferPtr = ((buffer + 4) + startIndex) - 1; if (successFlag) { asyncFileWriteStart(f, fPosition, bufferPtr, count); } if (successFlag) { /* begin pop: */ stackPointer -= 5 * 4; } } int primitiveAt(void) { int index; int result; int rcvr; int sp; /* begin commonAt: */ index = longAt(stackPointer); rcvr = longAt(stackPointer - (1 * 4)); if (((index & 1)) && (!((rcvr & 1)))) { index = (index >> 1); result = stObjectat(rcvr, index); if (false && (successFlag)) { result = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (((result >> 1)) << 2)); } } else { successFlag = false; } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), result); stackPointer = sp; } else { if (false) { failSpecialPrim(63); } else { failSpecialPrim(60); } } } int primitiveAtEnd(void) { int array; int stream; int arrayClass; int size; int index; int limit; int successValue; int sp; int sp1; int top; int ccIndex; int hdr; int totalLength; int fmt; int fixedFields; int sz; int classFormat; int class; int ccIndex1; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; stream = top; successFlag = (((((unsigned) (longAt(stream))) >> 8) & 15) <= 4) && ((lengthOf(stream)) >= (2 + 1)); if (successFlag) { array = longAt(((((char *) stream)) + 4) + (0 << 2)); index = fetchIntegerofObject(1, stream); limit = fetchIntegerofObject(2, stream); /* begin fetchClassOf: */ if ((array & 1)) { arrayClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(array))) >> 12) & 31) - 1; if (ccIndex < 0) { arrayClass = (longAt(array - 4)) & 4294967292U; goto l1; } else { arrayClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; /* begin success: */ successValue = (arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) || ((arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) || ((arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))) || (arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)))))); successFlag = successValue && successFlag; /* begin stSizeOf: */ hdr = longAt(array); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz = (longAt(array - 8)) & 4294967292U; } else { sz = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; goto l4; } else { totalLength = (sz - 4) - (fmt & 3); goto l4; } l4: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l2; } if (fmt < 2) { fixedFields = totalLength; goto l2; } /* begin fetchClassOf: */ if ((array & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l3; } ccIndex1 = ((((unsigned) (longAt(array))) >> 12) & 31) - 1; if (ccIndex1 < 0) { class = (longAt(array - 4)) & 4294967292U; goto l3; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex1 << 2)); goto l3; } l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l2: /* end fixedFieldsOf:format:length: */; size = totalLength - fixedFields; } if (successFlag) { /* begin pushBool: */ if ((index >= limit) || (index >= size)) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveAtPut(void) { int value; int valToStore; int index; int rcvr; int sp; /* begin commonAtPut: */ value = valToStore = longAt(stackPointer); index = longAt(stackPointer - (1 * 4)); rcvr = longAt(stackPointer - (2 * 4)); if (((index & 1)) && (!((rcvr & 1)))) { index = (index >> 1); if (false) { valToStore = asciiOfCharacter(value); } stObjectatput(rcvr, index, valToStore); } else { successFlag = false; } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((3 - 1) * 4), value); stackPointer = sp; } else { if (false) { failSpecialPrim(64); } else { failSpecialPrim(61); } } } int primitiveBeCursor(void) { int maskObj; int maskBitsIndex; int depth; int bitsObj; int extentX; int extentY; int cursorObj; int offsetObj; int offsetX; int offsetY; int cursorBitsIndex; int successValue; int successValue1; int successValue2; int successValue3; int successValue4; int successValue5; int successValue6; int successValue7; int successValue8; if (argumentCount == 0) { cursorObj = longAt(stackPointer); maskBitsIndex = null; } if (argumentCount == 1) { cursorObj = longAt(stackPointer - (1 * 4)); maskObj = longAt(stackPointer); } /* begin success: */ successFlag = (argumentCount < 2) && successFlag; /* begin success: */ successValue7 = (((((unsigned) (longAt(cursorObj))) >> 8) & 15) <= 4) && ((lengthOf(cursorObj)) >= 5); successFlag = successValue7 && successFlag; if (successFlag) { bitsObj = longAt(((((char *) cursorObj)) + 4) + (0 << 2)); extentX = fetchIntegerofObject(1, cursorObj); extentY = fetchIntegerofObject(2, cursorObj); depth = fetchIntegerofObject(3, cursorObj); offsetObj = longAt(((((char *) cursorObj)) + 4) + (4 << 2)); } /* begin success: */ successValue8 = (((((unsigned) (longAt(offsetObj))) >> 8) & 15) <= 4) && ((lengthOf(offsetObj)) >= 2); successFlag = successValue8 && successFlag; if (successFlag) { offsetX = fetchIntegerofObject(0, offsetObj); offsetY = fetchIntegerofObject(1, offsetObj); /* begin success: */ successValue = (extentX == 16) && ((extentY == 16) && (depth == 1)); successFlag = successValue && successFlag; /* begin success: */ successValue1 = (offsetX >= -16) && (offsetX <= 0); successFlag = successValue1 && successFlag; /* begin success: */ successValue2 = (offsetY >= -16) && (offsetY <= 0); successFlag = successValue2 && successFlag; /* begin success: */ successValue3 = (((((unsigned) (longAt(bitsObj))) >> 8) & 15) == 6) && ((lengthOf(bitsObj)) == 16); successFlag = successValue3 && successFlag; cursorBitsIndex = bitsObj + 4; } if (argumentCount == 1) { /* begin success: */ successValue6 = (((((unsigned) (longAt(maskObj))) >> 8) & 15) <= 4) && ((lengthOf(maskObj)) >= 5); successFlag = successValue6 && successFlag; if (successFlag) { bitsObj = longAt(((((char *) maskObj)) + 4) + (0 << 2)); extentX = fetchIntegerofObject(1, maskObj); extentY = fetchIntegerofObject(2, maskObj); depth = fetchIntegerofObject(3, maskObj); } if (successFlag) { /* begin success: */ successValue4 = (extentX == 16) && ((extentY == 16) && (depth == 1)); successFlag = successValue4 && successFlag; /* begin success: */ successValue5 = (((((unsigned) (longAt(bitsObj))) >> 8) & 15) == 6) && ((lengthOf(bitsObj)) == 16); successFlag = successValue5 && successFlag; maskBitsIndex = bitsObj + 4; } } if (successFlag) { if (argumentCount == 0) { ioSetCursor(cursorBitsIndex, offsetX, offsetY); } else { ioSetCursorWithMask(cursorBitsIndex, maskBitsIndex, offsetX, offsetY); } /* begin pop: */ stackPointer -= argumentCount * 4; } } int primitiveBeDisplay(void) { int rcvr; int oop; int successValue; rcvr = longAt(stackPointer); /* begin success: */ successValue = (((((unsigned) (longAt(rcvr))) >> 8) & 15) <= 4) && ((lengthOf(rcvr)) >= 4); successFlag = successValue && successFlag; if (successFlag) { /* begin storePointer:ofObject:withValue: */ oop = specialObjectsOop; if (oop < youngStart) { possibleRootStoreIntovalue(oop, rcvr); } longAtput(((((char *) oop)) + 4) + (14 << 2), rcvr); } } int primitiveBeep(void) { ioBeep(); } int primitiveBitAnd(void) { int integerReceiver; int integerArgument; int object; int sp; int top; int top1; int top2; int top11; successFlag = true; /* begin popPos32BitInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; top = top1; integerArgument = positive32BitValueOf(top); /* begin popPos32BitInteger */ /* begin popStack */ top11 = longAt(stackPointer); stackPointer -= 4; top2 = top11; integerReceiver = positive32BitValueOf(top2); if (successFlag) { /* begin push: */ object = positive32BitIntegerFor(integerReceiver & integerArgument); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(14); } } int primitiveBitOr(void) { int integerReceiver; int integerArgument; int object; int sp; int top; int top1; int top2; int top11; successFlag = true; /* begin popPos32BitInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; top = top1; integerArgument = positive32BitValueOf(top); /* begin popPos32BitInteger */ /* begin popStack */ top11 = longAt(stackPointer); stackPointer -= 4; top2 = top11; integerReceiver = positive32BitValueOf(top2); if (successFlag) { /* begin push: */ object = positive32BitIntegerFor(integerReceiver | integerArgument); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(15); } } int primitiveBitShift(void) { int shifted; int integerReceiver; int integerArgument; int object; int sp; int integerPointer; int top; int top2; int top1; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popPos32BitInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; top2 = top1; integerReceiver = positive32BitValueOf(top2); if (successFlag) { if (integerArgument >= 0) { /* begin success: */ successFlag = (integerArgument <= 31) && successFlag; shifted = integerReceiver << integerArgument; /* begin success: */ successFlag = ((((unsigned) shifted) >> integerArgument) == integerReceiver) && successFlag; } else { /* begin success: */ successFlag = (integerArgument >= -31) && successFlag; shifted = ((integerArgument < 0) ? ((unsigned) integerReceiver >> -integerArgument) : ((unsigned) integerReceiver << integerArgument)); } } if (successFlag) { /* begin push: */ object = positive32BitIntegerFor(shifted); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(17); } } int primitiveBitXor(void) { int integerReceiver; int integerArgument; int object; int sp; int top; int top1; int top2; int top11; /* begin popPos32BitInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; top = top1; integerArgument = positive32BitValueOf(top); /* begin popPos32BitInteger */ /* begin popStack */ top11 = longAt(stackPointer); stackPointer -= 4; top2 = top11; integerReceiver = positive32BitValueOf(top2); if (successFlag) { /* begin push: */ object = positive32BitIntegerFor(integerReceiver ^ integerArgument); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveBlockCopy(void) { int methodContext; int newContext; int initialIP; int context; int contextSize; int header; int oop; int sp; context = longAt(stackPointer - (1 * 4)); if (((longAt(((((char *) context)) + 4) + (3 << 2))) & 1)) { methodContext = longAt(((((char *) context)) + 4) + (5 << 2)); } else { methodContext = context; } /* begin sizeBitsOf: */ header = longAt(methodContext); if ((header & 3) == 0) { contextSize = (longAt(methodContext - 8)) & 4294967292U; goto l1; } else { contextSize = header & 252; goto l1; } l1: /* end sizeBitsOf: */; context = null; /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = methodContext; newContext = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)), contextSize, nilObj); /* begin popRemappableOop */ oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; methodContext = oop; initialIP = (((instructionPointer - method) << 1) | 1); longAtput(((((char *) newContext)) + 4) + (4 << 2), initialIP); longAtput(((((char *) newContext)) + 4) + (1 << 2), initialIP); /* begin storeStackPointerValue:inContext: */ longAtput(((((char *) newContext)) + 4) + (2 << 2), ((0 << 1) | 1)); longAtput(((((char *) newContext)) + 4) + (3 << 2), longAt(stackPointer - (0 * 4))); longAtput(((((char *) newContext)) + 4) + (5 << 2), methodContext); /* begin pop: */ stackPointer -= 2 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, newContext); stackPointer = sp; } int primitiveBytesLeft(void) { int sp; /* begin pop: */ stackPointer -= 1 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((((longAt(freeBlock)) & 536870908) << 1) | 1)); stackPointer = sp; } int primitiveClass(void) { int instance; int top; int object; int sp; int ccIndex; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; instance = top; /* begin push: */ /* begin fetchClassOf: */ if ((instance & 1)) { object = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(instance))) >> 12) & 31) - 1; if (ccIndex < 0) { object = (longAt(instance - 4)) & 4294967292U; goto l1; } else { object = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; longAtput(sp = stackPointer + 4, object); stackPointer = sp; } int primitiveClipboardText(void) { int sz; int s; int sp; int ccIndex; int cl; int hdr; int totalLength; int fmt; int fixedFields; int sz1; int classFormat; int class; int ccIndex1; if (argumentCount == 1) { s = longAt(stackPointer); /* begin assertClassOf:is: */ if ((s & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(s))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(s - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { /* begin stSizeOf: */ hdr = longAt(s); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz1 = (longAt(s - 8)) & 4294967292U; } else { sz1 = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz1 - 4)) >> 2; goto l4; } else { totalLength = (sz1 - 4) - (fmt & 3); goto l4; } l4: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l2; } if (fmt < 2) { fixedFields = totalLength; goto l2; } /* begin fetchClassOf: */ if ((s & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l3; } ccIndex1 = ((((unsigned) (longAt(s))) >> 12) & 31) - 1; if (ccIndex1 < 0) { class = (longAt(s - 4)) & 4294967292U; goto l3; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex1 << 2)); goto l3; } l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l2: /* end fixedFieldsOf:format:length: */; sz = totalLength - fixedFields; clipboardWriteFromAt(sz, s + 4, 0); /* begin pop: */ stackPointer -= 1 * 4; } } else { sz = clipboardSize(); s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); clipboardReadIntoAt(sz, s + 4, 0); /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, s); stackPointer = sp; } } int primitiveClone(void) { int newCopy; int sp; newCopy = clone(longAt(stackPointer)); /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((1 - 1) * 4), newCopy); stackPointer = sp; } int primitiveConstantFill(void) { int i; int end; int rcvrIsBytes; int fillValue; int rcvr; int successValue; int successValue1; int fmt; fillValue = positive32BitValueOf(longAt(stackPointer)); rcvr = longAt(stackPointer - (1 * 4)); /* begin success: */ /* begin isWordsOrBytes: */ fmt = (((unsigned) (longAt(rcvr))) >> 8) & 15; successValue1 = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); successFlag = successValue1 && successFlag; rcvrIsBytes = ((((unsigned) (longAt(rcvr))) >> 8) & 15) >= 8; if (rcvrIsBytes) { /* begin success: */ successValue = (fillValue >= 0) && (fillValue <= 255); successFlag = successValue && successFlag; } if (successFlag) { end = rcvr + (sizeBitsOf(rcvr)); i = rcvr + 4; if (rcvrIsBytes) { while (i < end) { byteAtput(i, fillValue); i += 1; } } else { while (i < end) { longAtput(i, fillValue); i += 4; } } /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveCopyBits(void) { int rcvr; int successValue; rcvr = longAt(stackPointer - (argumentCount * 4)); /* begin success: */ successValue = loadBitBltFrom(rcvr); successFlag = successValue && successFlag; if (successFlag) { copyBits(); showDisplayBits(); } } int primitiveDeferDisplayUpdates(void) { int flag; flag = longAt(stackPointer); if (flag == trueObj) { deferDisplayUpdates = true; } else { if (flag == falseObj) { deferDisplayUpdates = false; } else { primitiveFail(); } } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveDirectoryCreate(void) { int dirName; int dirNameIndex; int dirNameSize; int sz; int header; int fmt; dirName = longAt(stackPointer); /* begin success: */ successFlag = (((((unsigned) (longAt(dirName))) >> 8) & 15) >= 8) && successFlag; if (successFlag) { dirNameIndex = dirName + 4; /* begin lengthOf: */ header = longAt(dirName); if ((header & 3) == 0) { sz = (longAt(dirName - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { dirNameSize = ((unsigned) (sz - 4)) >> 2; goto l1; } else { dirNameSize = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; } if (successFlag) { /* begin success: */ successFlag = (dir_Create((char *) dirNameIndex, dirNameSize)) && successFlag; } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveDirectoryDelimitor(void) { int ascii; int sp; int successValue; ascii = asciiDirectoryDelimiter(); /* begin success: */ successValue = (ascii >= 0) && (ascii <= 255); successFlag = successValue && successFlag; if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (ascii << 2))); stackPointer = sp; } } int primitiveDirectoryLookup(void) { int dirFlag; int pathName; int pathNameIndex; int pathNameSize; int status; int modifiedDate; char entryName[256]; int entryNameSize; int index; int createDate; int fileSize; int sz; int header; int fmt; int sp; int object; int sp1; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { index = (integerPointer >> 1); goto l2; } else { primitiveFail(); index = 0; goto l2; } l2: /* end stackIntegerValue: */; pathName = longAt(stackPointer - (1 * 4)); /* begin success: */ successFlag = (((((unsigned) (longAt(pathName))) >> 8) & 15) >= 8) && successFlag; if (successFlag) { pathNameIndex = pathName + 4; /* begin lengthOf: */ header = longAt(pathName); if ((header & 3) == 0) { sz = (longAt(pathName - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { pathNameSize = ((unsigned) (sz - 4)) >> 2; goto l1; } else { pathNameSize = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; } if (successFlag) { status = dir_Lookup( (char *) pathNameIndex, pathNameSize, index, entryName, &entryNameSize, &createDate, &modifiedDate, &dirFlag, &fileSize); if (status == 1) { /* begin pop: */ stackPointer -= 3 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, nilObj); stackPointer = sp; return null; } if (status == 2) { return primitiveFail(); } } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; /* begin push: */ object = makeDirEntryNamesizecreateDatemodDateisDirfileSize(entryName, entryNameSize, createDate, modifiedDate, dirFlag, fileSize); longAtput(sp1 = stackPointer + 4, object); stackPointer = sp1; } } int primitiveDirectorySetMacTypeAndCreator(void) { int typeStringIndex; int typeString; int fileName; int creatorString; int creatorStringIndex; int fileNameIndex; int fileNameSize; int sz; int header; int fmt; int successValue; int successValue1; creatorString = longAt(stackPointer); typeString = longAt(stackPointer - (1 * 4)); fileName = longAt(stackPointer - (2 * 4)); /* begin success: */ successValue = (((((unsigned) (longAt(creatorString))) >> 8) & 15) >= 8) && ((lengthOf(creatorString)) == 4); successFlag = successValue && successFlag; /* begin success: */ successValue1 = (((((unsigned) (longAt(typeString))) >> 8) & 15) >= 8) && ((lengthOf(typeString)) == 4); successFlag = successValue1 && successFlag; /* begin success: */ successFlag = (((((unsigned) (longAt(fileName))) >> 8) & 15) >= 8) && successFlag; if (successFlag) { creatorStringIndex = creatorString + 4; typeStringIndex = typeString + 4; fileNameIndex = fileName + 4; /* begin lengthOf: */ header = longAt(fileName); if ((header & 3) == 0) { sz = (longAt(fileName - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { fileNameSize = ((unsigned) (sz - 4)) >> 2; goto l1; } else { fileNameSize = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; } if (successFlag) { /* begin success: */ successFlag = (dir_SetMacFileTypeAndCreator( (char *) fileNameIndex, fileNameSize, (char *) typeStringIndex, (char *) creatorStringIndex)) && successFlag; } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; } } int primitiveDiv(void) { int arg; int posArg; int posRcvr; int result; int rcvr; int integerPointer; int top; int integerPointer1; int top1; int sp; int sp1; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { arg = (integerPointer >> 1); goto l1; } else { successFlag = false; arg = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { rcvr = (integerPointer1 >> 1); goto l2; } else { successFlag = false; rcvr = 1; goto l2; } l2: /* end popInteger */; /* begin success: */ successFlag = (arg != 0) && successFlag; if (successFlag) { if (rcvr > 0) { if (arg > 0) { result = rcvr / arg; } else { posArg = 0 - arg; result = 0 - ((rcvr + (posArg - 1)) / posArg); } } else { posRcvr = 0 - rcvr; if (arg > 0) { result = 0 - ((posRcvr + (arg - 1)) / arg); } else { posArg = 0 - arg; result = posRcvr / posArg; } } /* begin checkIntegerResult:from: */ if (successFlag && ((result ^ (result << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((result << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(12); } } else { /* begin checkIntegerResult:from: */ if (successFlag && ((0 ^ (0 << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp1 = stackPointer + 4, ((0 << 1) | 1)); stackPointer = sp1; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(12); } } } int primitiveDivide(void) { int integerReceiver; int integerArgument; int integerPointer; int top; int integerPointer1; int top1; int sp; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { integerReceiver = (integerPointer1 >> 1); goto l2; } else { successFlag = false; integerReceiver = 1; goto l2; } l2: /* end popInteger */; /* begin success: */ successFlag = (integerArgument != 0) && successFlag; if (!(successFlag)) { integerArgument = 1; } /* begin success: */ successFlag = ((integerReceiver % integerArgument) == 0) && successFlag; /* begin checkIntegerResult:from: */ if (successFlag && (((integerReceiver / integerArgument) ^ ((integerReceiver / integerArgument) << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, (((integerReceiver / integerArgument) << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(10); } } int primitiveDoPrimitiveWithArgs(void) { int primIdx; int argumentArray; int arraySize; int index; int cntxSize; int sp; int sp1; int sp2; int sz; int objectPointer; int sz1; int integerPointer; int oop; int header; int header1; int ccIndex; int cl; argumentArray = longAt(stackPointer); /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(argumentArray); if ((header & 3) == 0) { sz = (longAt(argumentArray - 8)) & 4294967292U; goto l2; } else { sz = header & 252; goto l2; } l2: /* end sizeBitsOf: */; arraySize = ((unsigned) (sz - 4)) >> 2; /* begin fetchWordLengthOf: */ objectPointer = activeContext; /* begin sizeBitsOf: */ header1 = longAt(objectPointer); if ((header1 & 3) == 0) { sz1 = (longAt(objectPointer - 8)) & 4294967292U; goto l3; } else { sz1 = header1 & 252; goto l3; } l3: /* end sizeBitsOf: */; cntxSize = ((unsigned) (sz1 - 4)) >> 2; /* begin success: */ successFlag = (((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) + arraySize) < cntxSize) && successFlag; /* begin assertClassOf:is: */ if ((argumentArray & 1)) { successFlag = false; goto l4; } ccIndex = (((unsigned) (longAt(argumentArray))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(argumentArray - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && successFlag; l4: /* end assertClassOf:is: */; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (1 * 4)); if ((integerPointer & 1)) { primIdx = (integerPointer >> 1); goto l1; } else { primitiveFail(); primIdx = 0; goto l1; } l1: /* end stackIntegerValue: */; if (!(successFlag)) { return primitiveFail(); } /* begin pop: */ stackPointer -= 2 * 4; primitiveIndex = primIdx; argumentCount = arraySize; index = 1; while (index <= argumentCount) { /* begin push: */ longAtput(sp = stackPointer + 4, longAt(((((char *) argumentArray)) + 4) + ((index - 1) << 2))); stackPointer = sp; index += 1; } /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = argumentArray; primitiveResponse(); /* begin popRemappableOop */ oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; argumentArray = oop; if (!(successFlag)) { /* begin pop: */ stackPointer -= arraySize * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp1 = stackPointer + 4, ((primIdx << 1) | 1)); stackPointer = sp1; /* begin push: */ longAtput(sp2 = stackPointer + 4, argumentArray); stackPointer = sp2; argumentCount = 2; } } int primitiveDrawLoop(void) { int yDelta; int rcvr; int xDelta; int affL; int dx1; int dy1; int px; int py; int affR; int affT; int affB; int i; int P; int integerPointer; int integerPointer1; int successValue; int objectPointer; int integerValue; int objectPointer1; int integerValue1; rcvr = longAt(stackPointer - (2 * 4)); /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (1 * 4)); if ((integerPointer & 1)) { xDelta = (integerPointer >> 1); goto l1; } else { primitiveFail(); xDelta = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (0 * 4)); if ((integerPointer1 & 1)) { yDelta = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); yDelta = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin success: */ successValue = loadBitBltFrom(rcvr); successFlag = successValue && successFlag; if (successFlag) { /* begin drawLoopX:Y: */ if (xDelta > 0) { dx1 = 1; } else { if (xDelta == 0) { dx1 = 0; } else { dx1 = -1; } } if (yDelta > 0) { dy1 = 1; } else { if (yDelta == 0) { dy1 = 0; } else { dy1 = -1; } } px = abs(yDelta); py = abs(xDelta); affL = affT = 9999; affR = affB = -9999; if (py > px) { P = ((int) py >> 1); for (i = 1; i <= py; i += 1) { destX += dx1; if ((P -= px) < 0) { destY += dy1; P += py; } if (i < py) { copyBits(); if ((affectedL < affectedR) && (affectedT < affectedB)) { affL = ((affL < affectedL) ? affL : affectedL); affR = ((affR < affectedR) ? affectedR : affR); affT = ((affT < affectedT) ? affT : affectedT); affB = ((affB < affectedB) ? affectedB : affB); if (((affR - affL) * (affB - affT)) > 4000) { affectedL = affL; affectedR = affR; affectedT = affT; affectedB = affB; showDisplayBits(); affL = affT = 9999; affR = affB = -9999; } } } } } else { P = ((int) px >> 1); for (i = 1; i <= px; i += 1) { destY += dy1; if ((P -= py) < 0) { destX += dx1; P += px; } if (i < px) { copyBits(); if ((affectedL < affectedR) && (affectedT < affectedB)) { affL = ((affL < affectedL) ? affL : affectedL); affR = ((affR < affectedR) ? affectedR : affR); affT = ((affT < affectedT) ? affT : affectedT); affB = ((affB < affectedB) ? affectedB : affB); if (((affR - affL) * (affB - affT)) > 4000) { affectedL = affL; affectedR = affR; affectedT = affT; affectedB = affB; showDisplayBits(); affL = affT = 9999; affR = affB = -9999; } } } } } affectedL = affL; affectedR = affR; affectedT = affT; affectedB = affB; /* begin storeInteger:ofObject:withValue: */ objectPointer = bitBltOop; integerValue = destX; if ((integerValue ^ (integerValue << 1)) >= 0) { longAtput(((((char *) objectPointer)) + 4) + (4 << 2), ((integerValue << 1) | 1)); } else { primitiveFail(); } /* begin storeInteger:ofObject:withValue: */ objectPointer1 = bitBltOop; integerValue1 = destY; if ((integerValue1 ^ (integerValue1 << 1)) >= 0) { longAtput(((((char *) objectPointer1)) + 4) + (5 << 2), ((integerValue1 << 1) | 1)); } else { primitiveFail(); } showDisplayBits(); /* begin pop: */ stackPointer -= 2 * 4; } } int primitiveEqual(void) { int integerReceiver; int integerArgument; int result; int top; int top1; int sp; int sp1; successFlag = true; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerArgument = top; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerReceiver = top1; /* begin compare31or32Bits:equal: */ if (((integerReceiver & 1)) && ((integerArgument & 1))) { result = integerReceiver == integerArgument; goto l1; } result = (positive32BitValueOf(integerReceiver)) == (positive32BitValueOf(integerArgument)); l1: /* end compare31or32Bits:equal: */; /* begin checkBooleanResult:from: */ if (successFlag) { /* begin pushBool: */ if (result) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(7); } } int primitiveEquivalent(void) { int thisObject; int otherObject; int top; int top1; int sp; int sp1; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; otherObject = top; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; thisObject = top1; /* begin pushBool: */ if (thisObject == otherObject) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } int primitiveExitToDebugger(void) { error("Exit to debugger at user request"); } int primitiveExp(void) { double rcvr; rcvr = popFloat(); if (successFlag) { pushFloat(exp(rcvr)); } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveExponent(void) { int pwr; double frac; double rcvr; int sp; rcvr = popFloat(); if (successFlag) { frac = frexp(rcvr, &pwr); /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, (((pwr - 1) << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveFail(void) { successFlag = false; } int primitiveFileAtEnd(void) { int atEnd; SQFile *file; int sp; int sp1; file = fileValueOf(longAt(stackPointer)); if (successFlag) { atEnd = sqFileAtEnd(file); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (atEnd) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveFileClose(void) { SQFile *file; file = fileValueOf(longAt(stackPointer)); if (successFlag) { sqFileClose(file); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveFileDelete(void) { int nameIndex; int namePointer; int nameSize; int sz; int header; int fmt; namePointer = longAt(stackPointer); /* begin success: */ successFlag = (((((unsigned) (longAt(namePointer))) >> 8) & 15) >= 8) && successFlag; if (successFlag) { nameIndex = namePointer + 4; /* begin lengthOf: */ header = longAt(namePointer); if ((header & 3) == 0) { sz = (longAt(namePointer - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { nameSize = ((unsigned) (sz - 4)) >> 2; goto l1; } else { nameSize = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; } if (successFlag) { sqFileDeleteNameSize(nameIndex, nameSize); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveFileGetPosition(void) { int position; SQFile *file; int sp; file = fileValueOf(longAt(stackPointer)); if (successFlag) { position = sqFileGetPosition(file); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((position << 1) | 1)); stackPointer = sp; } } int primitiveFileOpen(void) { int writeFlag; int nameIndex; int namePointer; int nameSize; int filePointer; SQFile *file; int sz; int header; int fmt; int sp; /* begin booleanValueOf: */ if ((longAt(stackPointer)) == trueObj) { writeFlag = true; goto l2; } if ((longAt(stackPointer)) == falseObj) { writeFlag = false; goto l2; } successFlag = false; writeFlag = null; l2: /* end booleanValueOf: */; namePointer = longAt(stackPointer - (1 * 4)); /* begin success: */ successFlag = (((((unsigned) (longAt(namePointer))) >> 8) & 15) >= 8) && successFlag; if (successFlag) { filePointer = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)), fileRecordSize()); file = fileValueOf(filePointer); nameIndex = namePointer + 4; /* begin lengthOf: */ header = longAt(namePointer); if ((header & 3) == 0) { sz = (longAt(namePointer - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { nameSize = ((unsigned) (sz - 4)) >> 2; goto l1; } else { nameSize = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; } if (successFlag) { sqFileOpen(file, nameIndex, nameSize, writeFlag); } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, filePointer); stackPointer = sp; } } int primitiveFileRead(void) { int array; int startIndex; int arrayIndex; int bytesRead; int byteSize; int count; SQFile *file; int sp; int integerPointer; int integerPointer1; int successValue; int successValue1; int fmt; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { startIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); startIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; array = longAt(stackPointer - (2 * 4)); file = fileValueOf(longAt(stackPointer - (3 * 4))); /* begin success: */ /* begin isWordsOrBytes: */ fmt = (((unsigned) (longAt(array))) >> 8) & 15; successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); successFlag = successValue && successFlag; if (((((unsigned) (longAt(array))) >> 8) & 15) == 6) { byteSize = 4; } else { byteSize = 1; } /* begin success: */ successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= (lengthOf(array))); successFlag = successValue1 && successFlag; if (successFlag) { arrayIndex = array + 4; bytesRead = sqFileReadIntoAt(file, count * byteSize, arrayIndex, (startIndex - 1) * byteSize); } if (successFlag) { /* begin pop: */ stackPointer -= 5 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, (((bytesRead / byteSize) << 1) | 1)); stackPointer = sp; } } int primitiveFileRename(void) { int newNameIndex; int newNamePointer; int newNameSize; int oldNamePointer; int oldNameIndex; int oldNameSize; int sz; int header; int fmt; int sz1; int header1; int fmt1; newNamePointer = longAt(stackPointer); oldNamePointer = longAt(stackPointer - (1 * 4)); /* begin success: */ successFlag = (((((unsigned) (longAt(newNamePointer))) >> 8) & 15) >= 8) && successFlag; /* begin success: */ successFlag = (((((unsigned) (longAt(oldNamePointer))) >> 8) & 15) >= 8) && successFlag; if (successFlag) { newNameIndex = newNamePointer + 4; /* begin lengthOf: */ header = longAt(newNamePointer); if ((header & 3) == 0) { sz = (longAt(newNamePointer - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { newNameSize = ((unsigned) (sz - 4)) >> 2; goto l1; } else { newNameSize = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; oldNameIndex = oldNamePointer + 4; /* begin lengthOf: */ header1 = longAt(oldNamePointer); if ((header1 & 3) == 0) { sz1 = (longAt(oldNamePointer - 8)) & 4294967292U; } else { sz1 = header1 & 252; } fmt1 = (((unsigned) header1) >> 8) & 15; if (fmt1 < 8) { oldNameSize = ((unsigned) (sz1 - 4)) >> 2; goto l2; } else { oldNameSize = (sz1 - 4) - (fmt1 & 3); goto l2; } l2: /* end lengthOf: */; } if (successFlag) { sqFileRenameOldSizeNewSize(oldNameIndex, oldNameSize, newNameIndex, newNameSize); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; } } int primitiveFileSetPosition(void) { int newPosition; SQFile *file; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { newPosition = (integerPointer >> 1); goto l1; } else { primitiveFail(); newPosition = 0; goto l1; } l1: /* end stackIntegerValue: */; file = fileValueOf(longAt(stackPointer - (1 * 4))); if (successFlag) { sqFileSetPosition(file, newPosition); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; } } int primitiveFileSize(void) { int size; SQFile *file; int sp; file = fileValueOf(longAt(stackPointer)); if (successFlag) { size = sqFileSize(file); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((size << 1) | 1)); stackPointer = sp; } } int primitiveFileWrite(void) { int array; int startIndex; int arrayIndex; int bytesWritten; int byteSize; int count; SQFile *file; int sp; int integerPointer; int integerPointer1; int successValue; int successValue1; int fmt; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { startIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); startIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; array = longAt(stackPointer - (2 * 4)); file = fileValueOf(longAt(stackPointer - (3 * 4))); /* begin success: */ /* begin isWordsOrBytes: */ fmt = (((unsigned) (longAt(array))) >> 8) & 15; successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); successFlag = successValue && successFlag; if (((((unsigned) (longAt(array))) >> 8) & 15) == 6) { byteSize = 4; } else { byteSize = 1; } /* begin success: */ successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= (lengthOf(array))); successFlag = successValue1 && successFlag; if (successFlag) { arrayIndex = array + 4; bytesWritten = sqFileWriteFromAt(file, count * byteSize, arrayIndex, (startIndex - 1) * byteSize); } if (successFlag) { /* begin pop: */ stackPointer -= 5 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, (((bytesWritten / byteSize) << 1) | 1)); stackPointer = sp; } } int primitiveFloatAdd(void) { double arg; int argOop; int rcvrOop; double rcvr; double result; int resultOop; int sp; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); result = rcvr + arg; resultOop = clone(rcvrOop); storeFloatAtfrom(resultOop + 4, result); /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), resultOop); stackPointer = sp; } } int primitiveFloatDivide(void) { double arg; int argOop; int rcvrOop; double rcvr; double result; int resultOop; int sp; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); /* begin success: */ successFlag = (arg != 0.0) && successFlag; if (successFlag) { result = rcvr / arg; resultOop = clone(rcvrOop); storeFloatAtfrom(resultOop + 4, result); /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), resultOop); stackPointer = sp; } } } int primitiveFloatEqual(void) { double arg; int argOop; int rcvrOop; double rcvr; int sp; int sp1; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (rcvr == arg) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveFloatGreaterOrEqual(void) { double arg; int argOop; int rcvrOop; double rcvr; int sp; int sp1; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (rcvr >= arg) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveFloatGreaterThan(void) { double arg; int argOop; int rcvrOop; double rcvr; int sp; int sp1; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (rcvr > arg) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveFloatLessOrEqual(void) { double arg; int argOop; int rcvrOop; double rcvr; int sp; int sp1; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (rcvr <= arg) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveFloatLessThan(void) { double arg; int argOop; int rcvrOop; double rcvr; int sp; int sp1; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (rcvr < arg) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveFloatMultiply(void) { double arg; int argOop; int rcvrOop; double rcvr; double result; int resultOop; int sp; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); result = rcvr * arg; resultOop = clone(rcvrOop); storeFloatAtfrom(resultOop + 4, result); /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), resultOop); stackPointer = sp; } } int primitiveFloatNotEqual(void) { double arg; int argOop; int rcvrOop; double rcvr; int sp; int sp1; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (rcvr != arg) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveFloatSubtract(void) { double arg; int argOop; int rcvrOop; double rcvr; double result; int resultOop; int sp; int floatClass; int ccIndex; int cl; int ccIndex1; int cl1; rcvrOop = longAt(stackPointer - (1 * 4)); argOop = longAt(stackPointer); /* begin assertFloat:and: */ if (((rcvrOop | argOop) & 1) != 0) { successFlag = false; } else { floatClass = longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)); /* begin assertClassOf:is: */ if ((rcvrOop & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvrOop))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvrOop - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == floatClass) && successFlag; l1: /* end assertClassOf:is: */; /* begin assertClassOf:is: */ if ((argOop & 1)) { successFlag = false; goto l2; } ccIndex1 = (((unsigned) (longAt(argOop))) >> 12) & 31; if (ccIndex1 == 0) { cl1 = (longAt(argOop - 4)) & 4294967292U; } else { cl1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex1 - 1) << 2)); } /* begin success: */ successFlag = (cl1 == floatClass) && successFlag; l2: /* end assertClassOf:is: */; } if (successFlag) { fetchFloatAtinto(rcvrOop + 4, rcvr); fetchFloatAtinto(argOop + 4, arg); result = rcvr - arg; resultOop = clone(rcvrOop); storeFloatAtfrom(resultOop + 4, result); /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), resultOop); stackPointer = sp; } } int primitiveFlushCache(void) { int i; /* begin flushMethodCache */ for (i = 1; i <= 2048; i += 1) { methodCache[i] = 0; } mcProbe = 0; } int primitiveFlushCacheSelective(void) { int selector; int i; int nCols; int col; selector = longAt(stackPointer); nCols = ((int) 2048 >> 9); for (i = 1; i <= 512; i += 1) { if ((methodCache[i]) == selector) { for (col = 0; col <= (nCols - 1); col += 1) { methodCache[i + (512 * col)] = 0; } } } } int primitiveForceDisplayUpdate(void) { ioForceDisplayUpdate(); } int primitiveFormPrint(void) { double vScale; int depth; int pixelsPerWord; int bitsArray; double hScale; int wordsPerLine; int h; int w; int bitsArraySize; int landscapeFlag; int ok; int rcvr; /* begin booleanValueOf: */ if ((longAt(stackPointer)) == trueObj) { landscapeFlag = true; goto l1; } if ((longAt(stackPointer)) == falseObj) { landscapeFlag = false; goto l1; } successFlag = false; landscapeFlag = null; l1: /* end booleanValueOf: */; vScale = floatValueOf(longAt(stackPointer - (1 * 4))); hScale = floatValueOf(longAt(stackPointer - (2 * 4))); rcvr = longAt(stackPointer - (3 * 4)); if ((rcvr & 1)) { /* begin success: */ successFlag = false && successFlag; } if (successFlag) { if (!((((((unsigned) (longAt(rcvr))) >> 8) & 15) <= 4) && ((lengthOf(rcvr)) >= 4))) { /* begin success: */ successFlag = false && successFlag; } } if (successFlag) { bitsArray = longAt(((((char *) rcvr)) + 4) + (0 << 2)); w = fetchIntegerofObject(1, rcvr); h = fetchIntegerofObject(2, rcvr); depth = fetchIntegerofObject(3, rcvr); if (!((w > 0) && (h > 0))) { /* begin success: */ successFlag = false && successFlag; } pixelsPerWord = 32 / depth; wordsPerLine = (w + (pixelsPerWord - 1)) / pixelsPerWord; if ((!((rcvr & 1))) && (isWordsOrBytes(bitsArray))) { bitsArraySize = byteLengthOf(bitsArray); /* begin success: */ successFlag = (bitsArraySize == ((wordsPerLine * h) * 4)) && successFlag; } else { /* begin success: */ successFlag = false && successFlag; } } if (successFlag) { ok = ioFormPrint(bitsArray + 4, w, h, depth, hScale, vScale, landscapeFlag); /* begin success: */ successFlag = ok && successFlag; } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; } } int primitiveFractionalPart(void) { double trunc; double frac; double rcvr; rcvr = popFloat(); if (successFlag) { frac = modf(rcvr, &trunc); pushFloat(frac); } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveFullGC(void) { int sp; /* begin pop: */ stackPointer -= 1 * 4; incrementalGC(); fullGC(); /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((((longAt(freeBlock)) & 536870908) << 1) | 1)); stackPointer = sp; } int primitiveGetAttribute(void) { int attr; int sz; int s; int sp; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { attr = (integerPointer >> 1); goto l1; } else { primitiveFail(); attr = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { sz = attributeSize(attr); } if (successFlag) { s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); getAttributeIntoLength(attr, s + 4, sz); /* begin pop: */ stackPointer -= 2 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, s); stackPointer = sp; } } int primitiveGreaterOrEqual(void) { int integerReceiver; int integerArgument; int integerPointer; int top; int integerPointer1; int top1; int sp; int sp1; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { integerReceiver = (integerPointer1 >> 1); goto l2; } else { successFlag = false; integerReceiver = 1; goto l2; } l2: /* end popInteger */; /* begin checkBooleanResult:from: */ if (successFlag) { /* begin pushBool: */ if (integerReceiver >= integerArgument) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(6); } } int primitiveGreaterThan(void) { int integerReceiver; int integerArgument; int integerPointer; int top; int integerPointer1; int top1; int sp; int sp1; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { integerReceiver = (integerPointer1 >> 1); goto l2; } else { successFlag = false; integerReceiver = 1; goto l2; } l2: /* end popInteger */; /* begin checkBooleanResult:from: */ if (successFlag) { /* begin pushBool: */ if (integerReceiver > integerArgument) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(4); } } int primitiveImageName(void) { int sz; int s; int sp; int ccIndex; int cl; int hdr; int totalLength; int fmt; int fixedFields; int sz1; int classFormat; int class; int ccIndex1; if (argumentCount == 1) { s = longAt(stackPointer); /* begin assertClassOf:is: */ if ((s & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(s))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(s - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { /* begin stSizeOf: */ hdr = longAt(s); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz1 = (longAt(s - 8)) & 4294967292U; } else { sz1 = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz1 - 4)) >> 2; goto l4; } else { totalLength = (sz1 - 4) - (fmt & 3); goto l4; } l4: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l2; } if (fmt < 2) { fixedFields = totalLength; goto l2; } /* begin fetchClassOf: */ if ((s & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l3; } ccIndex1 = ((((unsigned) (longAt(s))) >> 12) & 31) - 1; if (ccIndex1 < 0) { class = (longAt(s - 4)) & 4294967292U; goto l3; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex1 << 2)); goto l3; } l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l2: /* end fixedFieldsOf:format:length: */; sz = totalLength - fixedFields; imageNamePutLength(s + 4, sz); /* begin pop: */ stackPointer -= 1 * 4; } } else { sz = imageNameSize(); s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); imageNameGetLength(s + 4, sz); /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, s); stackPointer = sp; } } int primitiveIncrementalGC(void) { int sp; /* begin pop: */ stackPointer -= 1 * 4; incrementalGC(); /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((((longAt(freeBlock)) & 536870908) << 1) | 1)); stackPointer = sp; } int primitiveIndexOf(int methodPointer) { int primBits; primBits = (((unsigned) (longAt(((((char *) methodPointer)) + 4) + (0 << 2)))) >> 1) & 805306879; if (primBits > 511) { return (primBits & 511) + (((unsigned) primBits) >> 19); } else { return primBits; } } int primitiveInitializeNetwork(void) { int err; int resolverSemaIndex; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { resolverSemaIndex = (integerPointer >> 1); goto l1; } else { primitiveFail(); resolverSemaIndex = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { err = sqNetworkInit(resolverSemaIndex); /* begin success: */ successFlag = (err == 0) && successFlag; } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveInputSemaphore(void) { int arg; int oop; int oop1; int valuePointer; int top; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; arg = top; if ((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { /* begin storePointer:ofObject:withValue: */ oop = specialObjectsOop; if (oop < youngStart) { possibleRootStoreIntovalue(oop, arg); } longAtput(((((char *) oop)) + 4) + (22 << 2), arg); } else { /* begin storePointer:ofObject:withValue: */ oop1 = specialObjectsOop; valuePointer = nilObj; if (oop1 < youngStart) { possibleRootStoreIntovalue(oop1, valuePointer); } longAtput(((((char *) oop1)) + 4) + (22 << 2), valuePointer); } } int primitiveInputWord(void) { int sp; /* begin pop: */ stackPointer -= 1 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((0 << 1) | 1)); stackPointer = sp; } int primitiveInstVarAt(void) { int value; int hdr; int totalLength; int index; int fmt; int rcvr; int fixedFields; int sz; int sp; int integerPointer; int top; int top1; int classFormat; int class; int ccIndex; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { index = (integerPointer >> 1); goto l3; } else { successFlag = false; index = 1; goto l3; } l3: /* end popInteger */; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; rcvr = top1; if (successFlag) { hdr = longAt(rcvr); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz = (longAt(rcvr - 8)) & 4294967292U; } else { sz = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; goto l1; } else { totalLength = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l4; } if (fmt < 2) { fixedFields = totalLength; goto l4; } /* begin fetchClassOf: */ if ((rcvr & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l5; } ccIndex = ((((unsigned) (longAt(rcvr))) >> 12) & 31) - 1; if (ccIndex < 0) { class = (longAt(rcvr - 4)) & 4294967292U; goto l5; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l5; } l5: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l4: /* end fixedFieldsOf:format:length: */; if (!((index >= 1) && (index <= fixedFields))) { successFlag = false; } } if (successFlag) { /* begin subscript:with:format: */ if (fmt < 4) { value = longAt(((((char *) rcvr)) + 4) + ((index - 1) << 2)); goto l2; } if (fmt < 8) { value = positive32BitIntegerFor(longAt(((((char *) rcvr)) + 4) + ((index - 1) << 2))); goto l2; } else { value = (((byteAt(((((char *) rcvr)) + 4) + (index - 1))) << 1) | 1); goto l2; } l2: /* end subscript:with:format: */; } if (successFlag) { /* begin push: */ longAtput(sp = stackPointer + 4, value); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveInstVarAtPut(void) { int hdr; int newValue; int totalLength; int index; int fmt; int rcvr; int fixedFields; int sp; int top; int top1; int sz; int valueToStore; int integerPointer; int top2; int classFormat; int class; int ccIndex; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; newValue = top; /* begin popInteger */ /* begin popStack */ top2 = longAt(stackPointer); stackPointer -= 4; integerPointer = top2; if ((integerPointer & 1)) { index = (integerPointer >> 1); goto l2; } else { successFlag = false; index = 1; goto l2; } l2: /* end popInteger */; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; rcvr = top1; if (successFlag) { hdr = longAt(rcvr); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz = (longAt(rcvr - 8)) & 4294967292U; } else { sz = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; goto l1; } else { totalLength = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l3; } if (fmt < 2) { fixedFields = totalLength; goto l3; } /* begin fetchClassOf: */ if ((rcvr & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l4; } ccIndex = ((((unsigned) (longAt(rcvr))) >> 12) & 31) - 1; if (ccIndex < 0) { class = (longAt(rcvr - 4)) & 4294967292U; goto l4; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l4; } l4: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l3: /* end fixedFieldsOf:format:length: */; if (!((index >= 1) && (index <= fixedFields))) { successFlag = false; } } if (successFlag) { /* begin subscript:with:storing:format: */ if (fmt < 4) { /* begin storePointer:ofObject:withValue: */ if (rcvr < youngStart) { possibleRootStoreIntovalue(rcvr, newValue); } longAtput(((((char *) rcvr)) + 4) + ((index - 1) << 2), newValue); } else { if (fmt < 8) { valueToStore = positive32BitValueOf(newValue); if (successFlag) { longAtput(((((char *) rcvr)) + 4) + ((index - 1) << 2), valueToStore); } } else { if (!((newValue & 1))) { successFlag = false; } valueToStore = (newValue >> 1); if (!((valueToStore >= 0) && (valueToStore <= 255))) { successFlag = false; } if (successFlag) { byteAtput(((((char *) rcvr)) + 4) + (index - 1), valueToStore); } } } } if (successFlag) { /* begin push: */ longAtput(sp = stackPointer + 4, newValue); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 3 * 4; } } int primitiveInterruptSemaphore(void) { int arg; int oop; int oop1; int valuePointer; int top; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; arg = top; if ((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { /* begin storePointer:ofObject:withValue: */ oop = specialObjectsOop; if (oop < youngStart) { possibleRootStoreIntovalue(oop, arg); } longAtput(((((char *) oop)) + 4) + (30 << 2), arg); } else { /* begin storePointer:ofObject:withValue: */ oop1 = specialObjectsOop; valuePointer = nilObj; if (oop1 < youngStart) { possibleRootStoreIntovalue(oop1, valuePointer); } longAtput(((((char *) oop1)) + 4) + (30 << 2), valuePointer); } } int primitiveKbdNext(void) { int keystrokeWord; int sp; int sp1; /* begin pop: */ stackPointer -= 1 * 4; keystrokeWord = ioGetKeystroke(); if (keystrokeWord >= 0) { /* begin pushInteger: */ /* begin push: */ longAtput(sp1 = stackPointer + 4, ((keystrokeWord << 1) | 1)); stackPointer = sp1; } else { /* begin push: */ longAtput(sp = stackPointer + 4, nilObj); stackPointer = sp; } } int primitiveKbdPeek(void) { int keystrokeWord; int sp; int sp1; /* begin pop: */ stackPointer -= 1 * 4; keystrokeWord = ioPeekKeystroke(); if (keystrokeWord >= 0) { /* begin pushInteger: */ /* begin push: */ longAtput(sp1 = stackPointer + 4, ((keystrokeWord << 1) | 1)); stackPointer = sp1; } else { /* begin push: */ longAtput(sp = stackPointer + 4, nilObj); stackPointer = sp; } } int primitiveLessOrEqual(void) { int integerReceiver; int integerArgument; int integerPointer; int top; int integerPointer1; int top1; int sp; int sp1; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { integerReceiver = (integerPointer1 >> 1); goto l2; } else { successFlag = false; integerReceiver = 1; goto l2; } l2: /* end popInteger */; /* begin checkBooleanResult:from: */ if (successFlag) { /* begin pushBool: */ if (integerReceiver <= integerArgument) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(5); } } int primitiveLessThan(void) { int integerReceiver; int integerArgument; int integerPointer; int top; int integerPointer1; int top1; int sp; int sp1; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { integerReceiver = (integerPointer1 >> 1); goto l2; } else { successFlag = false; integerReceiver = 1; goto l2; } l2: /* end popInteger */; /* begin checkBooleanResult:from: */ if (successFlag) { /* begin pushBool: */ if (integerReceiver < integerArgument) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(3); } } int primitiveLoadInstVar(void) { int thisReceiver; int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; thisReceiver = top; /* begin push: */ longAtput(sp = stackPointer + 4, longAt(((((char *) thisReceiver)) + 4) + ((primitiveIndex - 264) << 2))); stackPointer = sp; } int primitiveLogN(void) { double rcvr; rcvr = popFloat(); if (successFlag) { pushFloat(log(rcvr)); } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveLowSpaceSemaphore(void) { int arg; int oop; int oop1; int valuePointer; int top; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; arg = top; if ((fetchClassOf(arg)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { /* begin storePointer:ofObject:withValue: */ oop = specialObjectsOop; if (oop < youngStart) { possibleRootStoreIntovalue(oop, arg); } longAtput(((((char *) oop)) + 4) + (17 << 2), arg); } else { /* begin storePointer:ofObject:withValue: */ oop1 = specialObjectsOop; valuePointer = nilObj; if (oop1 < youngStart) { possibleRootStoreIntovalue(oop1, valuePointer); } longAtput(((((char *) oop1)) + 4) + (17 << 2), valuePointer); } } int primitiveMIDIClosePort(void) { int portNum; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { portNum = (integerPointer >> 1); goto l1; } else { primitiveFail(); portNum = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { sqMIDIClosePort(portNum); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveMIDIGetClock(void) { int clockValue; int sp; clockValue = (sqMIDIGetClock()) & 536870911; if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((clockValue << 1) | 1)); stackPointer = sp; } } int primitiveMIDIGetPortCount(void) { int n; int sp; n = sqMIDIGetPortCount(); if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((n << 1) | 1)); stackPointer = sp; } } int primitiveMIDIGetPortDirectionality(void) { int dir; int portNum; int integerPointer; int sp; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { portNum = (integerPointer >> 1); goto l1; } else { primitiveFail(); portNum = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { dir = sqMIDIGetPortDirectionality(portNum); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((dir << 1) | 1)); stackPointer = sp; } } int primitiveMIDIGetPortName(void) { char portName[256]; int portNum; int sz; int nameObj; int namePtr; int sp; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { portNum = (integerPointer >> 1); goto l1; } else { primitiveFail(); portNum = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { sz = sqMIDIGetPortName(portNum, (int) &portName, 255); } if (successFlag) { nameObj = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); namePtr = nameObj + 4; memcpy((char *) namePtr, portName, sz); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, nameObj); stackPointer = sp; } } int primitiveMIDIOpenPort(void) { int semaIndex; int portNum; int clockRate; int integerPointer; int integerPointer1; int integerPointer2; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { clockRate = (integerPointer >> 1); goto l1; } else { primitiveFail(); clockRate = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { semaIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); semaIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (2 * 4)); if ((integerPointer2 & 1)) { portNum = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); portNum = 0; goto l3; } l3: /* end stackIntegerValue: */; if (successFlag) { sqMIDIOpenPort(portNum, semaIndex, clockRate); } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; } } int primitiveMIDIParameterGetOrSet(void) { int whichParameter; int newValue; int currentValue; int sp; int integerPointer; int integerPointer1; int integerPointer2; if (argumentCount == 1) { /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { whichParameter = (integerPointer >> 1); goto l1; } else { primitiveFail(); whichParameter = 0; goto l1; } l1: /* end stackIntegerValue: */; if (!(successFlag)) { return null; } currentValue = sqMIDIParameter(whichParameter, false, 0); if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((currentValue << 1) | 1)); stackPointer = sp; } return null; } if (argumentCount == 2) { /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (0 * 4)); if ((integerPointer1 & 1)) { newValue = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); newValue = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (1 * 4)); if ((integerPointer2 & 1)) { whichParameter = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); whichParameter = 0; goto l3; } l3: /* end stackIntegerValue: */; if (!(successFlag)) { return null; } sqMIDIParameter(whichParameter, true, newValue); if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; } return null; } primitiveFail(); } int primitiveMIDIRead(void) { int array; int portNum; int arrayLength; int bytesRead; int fmt; int sz; int header; int fmt1; int sp; int integerPointer; int successValue; array = longAt(stackPointer - (0 * 4)); /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (1 * 4)); if ((integerPointer & 1)) { portNum = (integerPointer >> 1); goto l2; } else { primitiveFail(); portNum = 0; goto l2; } l2: /* end stackIntegerValue: */; fmt = (((unsigned) (longAt(array))) >> 8) & 15; /* begin success: */ successValue = (fmt >= 8) && (fmt <= 11); successFlag = successValue && successFlag; if (successFlag) { /* begin lengthOf: */ header = longAt(array); if ((header & 3) == 0) { sz = (longAt(array - 8)) & 4294967292U; } else { sz = header & 252; } fmt1 = (((unsigned) header) >> 8) & 15; if (fmt1 < 8) { arrayLength = ((unsigned) (sz - 4)) >> 2; goto l1; } else { arrayLength = (sz - 4) - (fmt1 & 3); goto l1; } l1: /* end lengthOf: */; bytesRead = sqMIDIPortReadInto(portNum, arrayLength, array + 4); } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((bytesRead << 1) | 1)); stackPointer = sp; } } int primitiveMIDIWrite(void) { int array; int portNum; int arrayLength; int time; int bytesWritten; int fmt; int sz; int header; int fmt1; int sp; int integerPointer; int integerPointer1; int successValue; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { time = (integerPointer >> 1); goto l2; } else { primitiveFail(); time = 0; goto l2; } l2: /* end stackIntegerValue: */; array = longAt(stackPointer - (1 * 4)); /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (2 * 4)); if ((integerPointer1 & 1)) { portNum = (integerPointer1 >> 1); goto l3; } else { primitiveFail(); portNum = 0; goto l3; } l3: /* end stackIntegerValue: */; fmt = (((unsigned) (longAt(array))) >> 8) & 15; /* begin success: */ successValue = (fmt >= 8) && (fmt <= 11); successFlag = successValue && successFlag; if (successFlag) { /* begin lengthOf: */ header = longAt(array); if ((header & 3) == 0) { sz = (longAt(array - 8)) & 4294967292U; } else { sz = header & 252; } fmt1 = (((unsigned) header) >> 8) & 15; if (fmt1 < 8) { arrayLength = ((unsigned) (sz - 4)) >> 2; goto l1; } else { arrayLength = (sz - 4) - (fmt1 & 3); goto l1; } l1: /* end lengthOf: */; bytesWritten = sqMIDIPortWriteFromAt(portNum, arrayLength, array + 4, time); } if (successFlag) { /* begin pop: */ stackPointer -= 4 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((bytesWritten << 1) | 1)); stackPointer = sp; } } int primitiveMakePoint(void) { int integerReceiver; int integerArgument; int object; int sp; int integerPointer; int top; int integerPointer1; int top1; int pointResult; int sp1; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { integerReceiver = (integerPointer1 >> 1); goto l2; } else { successFlag = false; integerReceiver = 1; goto l2; } l2: /* end popInteger */; if (successFlag) { /* begin push: */ /* begin makePointwithxValue:yValue: */ pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); /* begin storePointer:ofObject:withValue: */ if (pointResult < youngStart) { possibleRootStoreIntovalue(pointResult, ((integerReceiver << 1) | 1)); } longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((integerReceiver << 1) | 1)); /* begin storePointer:ofObject:withValue: */ if (pointResult < youngStart) { possibleRootStoreIntovalue(pointResult, ((integerArgument << 1) | 1)); } longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((integerArgument << 1) | 1)); object = pointResult; longAtput(sp = stackPointer + 4, object); stackPointer = sp; } else { /* begin checkIntegerResult:from: */ if (successFlag && ((0 ^ (0 << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp1 = stackPointer + 4, ((0 << 1) | 1)); stackPointer = sp1; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(18); } } } int primitiveMillisecondClock(void) { int object; int sp; /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ object = ((((ioMSecs()) & 536870911) << 1) | 1); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } int primitiveMod(void) { int integerReceiver; int integerArgument; int integerResult; int integerPointer; int top; int integerPointer1; int top1; int sp; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { integerReceiver = (integerPointer1 >> 1); goto l2; } else { successFlag = false; integerReceiver = 1; goto l2; } l2: /* end popInteger */; /* begin success: */ successFlag = (integerArgument != 0) && successFlag; if (!(successFlag)) { integerArgument = 1; } integerResult = integerReceiver % integerArgument; if (integerArgument < 0) { if (integerResult > 0) { integerResult += integerArgument; } } else { if (integerResult < 0) { integerResult += integerArgument; } } /* begin checkIntegerResult:from: */ if (successFlag && ((integerResult ^ (integerResult << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((integerResult << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(11); } } int primitiveMouseButtons(void) { int buttonWord; int sp; /* begin pop: */ stackPointer -= 1 * 4; buttonWord = ioGetButtonState(); /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((buttonWord << 1) | 1)); stackPointer = sp; } int primitiveMousePoint(void) { int y; int pointWord; int x; int object; int sp; int pointResult; /* begin pop: */ stackPointer -= 1 * 4; pointWord = ioMousePoint(); /* begin signExtend16: */ if ((((((unsigned) pointWord) >> 16) & 65535) & 32768) == 0) { x = (((unsigned) pointWord) >> 16) & 65535; goto l1; } else { x = ((((unsigned) pointWord) >> 16) & 65535) - 65536; goto l1; } l1: /* end signExtend16: */; /* begin signExtend16: */ if (((pointWord & 65535) & 32768) == 0) { y = pointWord & 65535; goto l2; } else { y = (pointWord & 65535) - 65536; goto l2; } l2: /* end signExtend16: */; /* begin push: */ /* begin makePointwithxValue:yValue: */ pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); /* begin storePointer:ofObject:withValue: */ if (pointResult < youngStart) { possibleRootStoreIntovalue(pointResult, ((x << 1) | 1)); } longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((x << 1) | 1)); /* begin storePointer:ofObject:withValue: */ if (pointResult < youngStart) { possibleRootStoreIntovalue(pointResult, ((y << 1) | 1)); } longAtput(((((char *) pointResult)) + 4) + (1 << 2), ((y << 1) | 1)); object = pointResult; longAtput(sp = stackPointer + 4, object); stackPointer = sp; } int primitiveMultiply(void) { int arg; int result; int rcvr; int successValue; int sp; rcvr = longAt(stackPointer - (1 * 4)); arg = longAt(stackPointer - (0 * 4)); /* begin pop: */ stackPointer -= 2 * 4; /* begin success: */ successFlag = (((rcvr & arg) & 1) != 0) && successFlag; if (successFlag) { rcvr = (rcvr >> 1); arg = (arg >> 1); result = rcvr * arg; /* begin success: */ successValue = (arg == 0) || ((result / arg) == rcvr); successFlag = successValue && successFlag; } /* begin checkIntegerResult:from: */ if (successFlag && ((result ^ (result << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((result << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(9); } } int primitiveNew(void) { int spaceOkay; int class; int object; int sp; int top; int okay; int format; int minFree; int minFree1; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; class = top; /* begin sufficientSpaceToInstantiate:indexableSize: */ format = (((unsigned) ((longAt(((((char *) class)) + 4) + (2 << 2))) - 1)) >> 8) & 15; if ((0 > 0) && (format < 2)) { spaceOkay = false; goto l3; } if (format < 8) { /* begin sufficientSpaceToAllocate: */ minFree = (lowSpaceThreshold + (2500 + (0 * 4))) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { okay = true; goto l1; } else { okay = sufficientSpaceAfterGC(minFree); goto l1; } l1: /* end sufficientSpaceToAllocate: */; } else { /* begin sufficientSpaceToAllocate: */ minFree1 = (lowSpaceThreshold + (2500 + 0)) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree1) { okay = true; goto l2; } else { okay = sufficientSpaceAfterGC(minFree1); goto l2; } l2: /* end sufficientSpaceToAllocate: */; } spaceOkay = okay; l3: /* end sufficientSpaceToInstantiate:indexableSize: */; /* begin success: */ successFlag = spaceOkay && successFlag; if (successFlag) { /* begin push: */ object = instantiateClassindexableSize(class, 0); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveNewMethod(void) { int size; int i; int header; int theMethod; int bytecodeCount; int class; int literalCount; int valuePointer; int top; int top1; int sp; int integerPointer; int top2; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; header = top; /* begin popInteger */ /* begin popStack */ top2 = longAt(stackPointer); stackPointer -= 4; integerPointer = top2; if ((integerPointer & 1)) { bytecodeCount = (integerPointer >> 1); goto l1; } else { successFlag = false; bytecodeCount = 1; goto l1; } l1: /* end popInteger */; /* begin success: */ successFlag = ((header & 1)) && successFlag; if (!(successFlag)) { /* begin unPop: */ stackPointer += 2 * 4; } /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; class = top1; size = ((((((unsigned) header) >> 10) & 255) + 1) * 4) + bytecodeCount; theMethod = instantiateClassindexableSize(class, size); /* begin storePointer:ofObject:withValue: */ if (theMethod < youngStart) { possibleRootStoreIntovalue(theMethod, header); } longAtput(((((char *) theMethod)) + 4) + (0 << 2), header); literalCount = (((unsigned) header) >> 10) & 255; for (i = 1; i <= literalCount; i += 1) { /* begin storePointer:ofObject:withValue: */ valuePointer = nilObj; if (theMethod < youngStart) { possibleRootStoreIntovalue(theMethod, valuePointer); } longAtput(((((char *) theMethod)) + 4) + (i << 2), valuePointer); } /* begin push: */ longAtput(sp = stackPointer + 4, theMethod); stackPointer = sp; } int primitiveNewWithArg(void) { int spaceOkay; int size; int class; int top; int object; int sp; int integerPointer; int top1; int okay; int format; int minFree; int minFree1; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer = top1; if ((integerPointer & 1)) { size = (integerPointer >> 1); goto l1; } else { successFlag = false; size = 1; goto l1; } l1: /* end popInteger */; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; class = top; /* begin success: */ successFlag = (size >= 0) && successFlag; if (successFlag) { /* begin sufficientSpaceToInstantiate:indexableSize: */ format = (((unsigned) ((longAt(((((char *) class)) + 4) + (2 << 2))) - 1)) >> 8) & 15; if ((size > 0) && (format < 2)) { spaceOkay = false; goto l4; } if (format < 8) { /* begin sufficientSpaceToAllocate: */ minFree = (lowSpaceThreshold + (2500 + (size * 4))) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { okay = true; goto l3; } else { okay = sufficientSpaceAfterGC(minFree); goto l3; } l3: /* end sufficientSpaceToAllocate: */; } else { /* begin sufficientSpaceToAllocate: */ minFree1 = (lowSpaceThreshold + (2500 + size)) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree1) { okay = true; goto l2; } else { okay = sufficientSpaceAfterGC(minFree1); goto l2; } l2: /* end sufficientSpaceToAllocate: */; } spaceOkay = okay; l4: /* end sufficientSpaceToInstantiate:indexableSize: */; /* begin success: */ successFlag = spaceOkay && successFlag; } if (successFlag) { /* begin push: */ object = instantiateClassindexableSize(class, size); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveNext(void) { int array; int stream; int stringy; int arrayClass; int index; int limit; int result; int successValue; int ccIndex; int oop; int sp; int sp1; int top; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; stream = top; successFlag = (((((unsigned) (longAt(stream))) >> 8) & 15) <= 4) && ((lengthOf(stream)) >= (2 + 1)); if (successFlag) { array = longAt(((((char *) stream)) + 4) + (0 << 2)); index = fetchIntegerofObject(1, stream); limit = fetchIntegerofObject(2, stream); /* begin fetchClassOf: */ if ((array & 1)) { arrayClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(array))) >> 12) & 31) - 1; if (ccIndex < 0) { arrayClass = (longAt(array - 4)) & 4294967292U; goto l1; } else { arrayClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; stringy = arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2))); if (!(stringy)) { /* begin success: */ successValue = (arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) || ((arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) || ((arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))) || (arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)))))); successFlag = successValue && successFlag; } /* begin success: */ successFlag = (index < limit) && successFlag; } if (successFlag) { index += 1; /* begin pushRemappableOop: */ remapBuffer[remapBufferCount += 1] = stream; result = stObjectat(array, index); /* begin popRemappableOop */ oop = remapBuffer[remapBufferCount]; remapBufferCount -= 1; stream = oop; } if (successFlag) { /* begin storeInteger:ofObject:withValue: */ if ((index ^ (index << 1)) >= 0) { longAtput(((((char *) stream)) + 4) + (1 << 2), ((index << 1) | 1)); } else { primitiveFail(); } } if (successFlag) { if (stringy) { /* begin push: */ longAtput(sp = stackPointer + 4, longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (((result >> 1)) << 2))); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, result); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveNextInstance(void) { int object; int instance; int sp; int top; int thisClass; int classPointer; int thisObj; int ccIndex; int ccIndex1; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; object = top; /* begin instanceAfter: */ /* begin fetchClassOf: */ if ((object & 1)) { classPointer = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l3; } ccIndex1 = ((((unsigned) (longAt(object))) >> 12) & 31) - 1; if (ccIndex1 < 0) { classPointer = (longAt(object - 4)) & 4294967292U; goto l3; } else { classPointer = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex1 << 2)); goto l3; } l3: /* end fetchClassOf: */; thisObj = accessibleObjectAfter(object); while (!(thisObj == null)) { /* begin fetchClassOf: */ if ((thisObj & 1)) { thisClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l2; } ccIndex = ((((unsigned) (longAt(thisObj))) >> 12) & 31) - 1; if (ccIndex < 0) { thisClass = (longAt(thisObj - 4)) & 4294967292U; goto l2; } else { thisClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l2; } l2: /* end fetchClassOf: */; if (thisClass == classPointer) { instance = thisObj; goto l1; } thisObj = accessibleObjectAfter(thisObj); } instance = nilObj; l1: /* end instanceAfter: */; if (instance == nilObj) { /* begin unPop: */ stackPointer += 1 * 4; primitiveFail(); } else { /* begin push: */ longAtput(sp = stackPointer + 4, instance); stackPointer = sp; } } int primitiveNextObject(void) { int object; int instance; int sp; int top; int sp1; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; object = top; instance = accessibleObjectAfter(object); if (instance == null) { /* begin pushInteger: */ /* begin push: */ longAtput(sp1 = stackPointer + 4, ((0 << 1) | 1)); stackPointer = sp1; } else { /* begin push: */ longAtput(sp = stackPointer + 4, instance); stackPointer = sp; } } int primitiveNextPut(void) { int array; int stream; int storeVal; int value; int arrayClass; int index; int limit; int successValue; int sp; int top; int top1; int ccIndex; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; value = top; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; stream = top1; successFlag = (((((unsigned) (longAt(stream))) >> 8) & 15) <= 4) && ((lengthOf(stream)) >= (3 + 1)); if (successFlag) { array = longAt(((((char *) stream)) + 4) + (0 << 2)); index = fetchIntegerofObject(1, stream); limit = fetchIntegerofObject(3, stream); /* begin fetchClassOf: */ if ((array & 1)) { arrayClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l1; } ccIndex = ((((unsigned) (longAt(array))) >> 12) & 31) - 1; if (ccIndex < 0) { arrayClass = (longAt(array - 4)) & 4294967292U; goto l1; } else { arrayClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l1; } l1: /* end fetchClassOf: */; /* begin success: */ successValue = (arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) || ((arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) || ((arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)))) || (arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (4 << 2)))))); successFlag = successValue && successFlag; /* begin success: */ successFlag = (index < limit) && successFlag; } if (successFlag) { index += 1; if (arrayClass == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) { storeVal = asciiOfCharacter(value); } else { storeVal = value; } stObjectatput(array, index, storeVal); } if (successFlag) { /* begin storeInteger:ofObject:withValue: */ if ((index ^ (index << 1)) >= 0) { longAtput(((((char *) stream)) + 4) + (1 << 2), ((index << 1) | 1)); } else { primitiveFail(); } } if (successFlag) { /* begin push: */ longAtput(sp = stackPointer + 4, value); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveNoop(void) { /* begin pop: */ stackPointer -= argumentCount * 4; } int primitiveNotEqual(void) { int integerReceiver; int integerArgument; int result; int top; int top1; int sp; int sp1; successFlag = true; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerArgument = top; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerReceiver = top1; result = !(compare31or32Bitsequal(integerReceiver, integerArgument)); /* begin checkBooleanResult:from: */ if (successFlag) { /* begin pushBool: */ if (result) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(8); } } int primitiveObjectAt(void) { int thisReceiver; int index; int sp; int integerPointer; int top; int top1; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { index = (integerPointer >> 1); goto l1; } else { successFlag = false; index = 1; goto l1; } l1: /* end popInteger */; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; thisReceiver = top1; /* begin success: */ successFlag = (index > 0) && successFlag; /* begin success: */ successFlag = (index <= (((((unsigned) (longAt(((((char *) thisReceiver)) + 4) + (0 << 2)))) >> 10) & 255) + 1)) && successFlag; if (successFlag) { /* begin push: */ longAtput(sp = stackPointer + 4, longAt(((((char *) thisReceiver)) + 4) + ((index - 1) << 2))); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveObjectAtPut(void) { int thisReceiver; int newValue; int index; int sp; int top; int integerPointer; int top1; int top2; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; newValue = top; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer = top1; if ((integerPointer & 1)) { index = (integerPointer >> 1); goto l1; } else { successFlag = false; index = 1; goto l1; } l1: /* end popInteger */; /* begin popStack */ top2 = longAt(stackPointer); stackPointer -= 4; thisReceiver = top2; /* begin success: */ successFlag = (index > 0) && successFlag; /* begin success: */ successFlag = (index <= (((((unsigned) (longAt(((((char *) thisReceiver)) + 4) + (0 << 2)))) >> 10) & 255) + 1)) && successFlag; if (successFlag) { /* begin storePointer:ofObject:withValue: */ if (thisReceiver < youngStart) { possibleRootStoreIntovalue(thisReceiver, newValue); } longAtput(((((char *) thisReceiver)) + 4) + ((index - 1) << 2), newValue); /* begin push: */ longAtput(sp = stackPointer + 4, newValue); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 3 * 4; } } int primitiveObjectPointsTo(void) { int i; int thang; int lastField; int rcvr; int top; int top1; int sp; int sp1; int sp2; int sp3; int sp4; int sp5; int methodHeader; int sz; int fmt; int header; int type; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; thang = top; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; rcvr = top1; if ((rcvr & 1)) { /* begin pushBool: */ if (false) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } return null; } /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(rcvr))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header = longAt(rcvr); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l2; } else { if ((header & 126976) == 0) { type = 1; goto l2; } else { type = 3; goto l2; } } l2: /* end rightType: */; if (type == 0) { sz = (longAt(rcvr - 8)) & 4294967292U; goto l3; } else { sz = header & 252; goto l3; } l3: /* end sizeBitsOfSafe: */; lastField = sz - 4; goto l1; } if (fmt < 12) { lastField = 0; goto l1; } methodHeader = longAt(rcvr + 4); lastField = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerOf: */; for (i = 4; i <= lastField; i += 4) { if ((longAt(rcvr + i)) == thang) { /* begin pushBool: */ if (true) { /* begin push: */ longAtput(sp2 = stackPointer + 4, trueObj); stackPointer = sp2; } else { /* begin push: */ longAtput(sp3 = stackPointer + 4, falseObj); stackPointer = sp3; } return null; } } /* begin pushBool: */ if (false) { /* begin push: */ longAtput(sp4 = stackPointer + 4, trueObj); stackPointer = sp4; } else { /* begin push: */ longAtput(sp5 = stackPointer + 4, falseObj); stackPointer = sp5; } } int primitivePerform(void) { int performSelector; int selectorIndex; int newReceiver; int toIndex; int fromIndex; int lastFrom; performSelector = messageSelector; messageSelector = longAt(stackPointer - ((argumentCount - 1) * 4)); newReceiver = longAt(stackPointer - (argumentCount * 4)); argumentCount -= 1; lookupMethodInClass(fetchClassOf(newReceiver)); /* begin success: */ successFlag = (((((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 25) & 31) == argumentCount) && successFlag; if (successFlag) { selectorIndex = (((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - argumentCount; /* begin transfer:fromIndex:ofObject:toIndex:ofObject: */ fromIndex = activeContext + ((selectorIndex + 1) * 4); toIndex = activeContext + (selectorIndex * 4); lastFrom = fromIndex + (argumentCount * 4); while (fromIndex < lastFrom) { fromIndex += 4; toIndex += 4; longAtput(toIndex, longAt(fromIndex)); } /* begin pop: */ stackPointer -= 1 * 4; /* begin executeNewMethod */ if ((primitiveIndex == 0) || (!(primitiveResponse()))) { activateNewMethod(); /* begin quickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { checkForInterrupts(); } } successFlag = true; } else { argumentCount += 1; messageSelector = performSelector; } } int primitivePerformWithArgs(void) { int argumentArray; int performSelector; int arraySize; int thisReceiver; int index; int cntxSize; int sp; int sp1; int sp2; int top; int top1; int sz; int objectPointer; int sz1; int header; int header1; int ccIndex; int cl; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; argumentArray = top1; /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(argumentArray); if ((header & 3) == 0) { sz = (longAt(argumentArray - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; arraySize = ((unsigned) (sz - 4)) >> 2; /* begin fetchWordLengthOf: */ objectPointer = activeContext; /* begin sizeBitsOf: */ header1 = longAt(objectPointer); if ((header1 & 3) == 0) { sz1 = (longAt(objectPointer - 8)) & 4294967292U; goto l2; } else { sz1 = header1 & 252; goto l2; } l2: /* end sizeBitsOf: */; cntxSize = ((unsigned) (sz1 - 4)) >> 2; /* begin success: */ successFlag = (((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) + arraySize) < cntxSize) && successFlag; /* begin assertClassOf:is: */ if ((argumentArray & 1)) { successFlag = false; goto l3; } ccIndex = (((unsigned) (longAt(argumentArray))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(argumentArray - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && successFlag; l3: /* end assertClassOf:is: */; if (successFlag) { performSelector = messageSelector; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; messageSelector = top; thisReceiver = longAt(stackPointer); argumentCount = arraySize; index = 1; while (index <= argumentCount) { /* begin push: */ longAtput(sp = stackPointer + 4, longAt(((((char *) argumentArray)) + 4) + ((index - 1) << 2))); stackPointer = sp; index += 1; } lookupMethodInClass(fetchClassOf(thisReceiver)); /* begin success: */ successFlag = (((((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 25) & 31) == argumentCount) && successFlag; if (successFlag) { /* begin executeNewMethod */ if ((primitiveIndex == 0) || (!(primitiveResponse()))) { activateNewMethod(); /* begin quickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { checkForInterrupts(); } } successFlag = true; } else { /* begin pop: */ stackPointer -= argumentCount * 4; /* begin push: */ longAtput(sp1 = stackPointer + 4, messageSelector); stackPointer = sp1; /* begin push: */ longAtput(sp2 = stackPointer + 4, argumentArray); stackPointer = sp2; argumentCount = 2; messageSelector = performSelector; } } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitivePointX(void) { int rcvr; int sp; int top; int ccIndex; int cl; successFlag = true; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; rcvr = top; /* begin assertClassOf:is: */ if ((rcvr & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvr - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { /* begin push: */ longAtput(sp = stackPointer + 4, longAt(((((char *) rcvr)) + 4) + (0 << 2))); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 1 * 4; failSpecialPrim(0); } } int primitivePointY(void) { int rcvr; int sp; int top; int ccIndex; int cl; successFlag = true; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; rcvr = top; /* begin assertClassOf:is: */ if ((rcvr & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(rcvr))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(rcvr - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { /* begin push: */ longAtput(sp = stackPointer + 4, longAt(((((char *) rcvr)) + 4) + (1 << 2))); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 1 * 4; failSpecialPrim(0); } } int primitivePushFalse(void) { int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; /* begin push: */ longAtput(sp = stackPointer + 4, falseObj); stackPointer = sp; } int primitivePushMinusOne(void) { int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; /* begin push: */ longAtput(sp = stackPointer + 4, 4294967295U); stackPointer = sp; } int primitivePushNil(void) { int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; /* begin push: */ longAtput(sp = stackPointer + 4, nilObj); stackPointer = sp; } int primitivePushOne(void) { int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; /* begin push: */ longAtput(sp = stackPointer + 4, 3); stackPointer = sp; } int primitivePushSelf(void) { } int primitivePushTrue(void) { int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } int primitivePushTwo(void) { int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; /* begin push: */ longAtput(sp = stackPointer + 4, 5); stackPointer = sp; } int primitivePushZero(void) { int top; int sp; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; /* begin push: */ longAtput(sp = stackPointer + 4, 1); stackPointer = sp; } int primitiveQuit(void) { ioExit(); } int primitiveQuo(void) { int arg; int result; int rcvr; int sp; int integerPointer; int top; int integerPointer1; int top1; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { arg = (integerPointer >> 1); goto l1; } else { successFlag = false; arg = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { rcvr = (integerPointer1 >> 1); goto l2; } else { successFlag = false; rcvr = 1; goto l2; } l2: /* end popInteger */; /* begin success: */ successFlag = (arg != 0) && successFlag; if (successFlag) { if (rcvr > 0) { if (arg > 0) { result = rcvr / arg; } else { result = 0 - (rcvr / (0 - arg)); } } else { if (arg > 0) { result = 0 - ((0 - rcvr) / arg); } else { result = (0 - rcvr) / (0 - arg); } } /* begin success: */ successFlag = ((result ^ (result << 1)) >= 0) && successFlag; } if (successFlag) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((result << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveReadJoystick(void) { int index; int object; int sp; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { index = (integerPointer >> 1); goto l1; } else { primitiveFail(); index = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin push: */ object = positive32BitIntegerFor(joystickRead(index)); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } } int primitiveRelinquishProcessor(void) { int microSecs; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { microSecs = (integerPointer >> 1); goto l1; } else { primitiveFail(); microSecs = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { ioRelinquishProcessorForMicroseconds(microSecs); /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveResolverAbortLookup(void) { sqResolverAbort(); } int primitiveResolverAddressLookupResult(void) { int sz; int s; int sp; sz = sqResolverAddrLookupResultSize(); if (successFlag) { s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); sqResolverAddrLookupResult(((char *) (s + 4)), sz); } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((1 - 1) * 4), s); stackPointer = sp; } } int primitiveResolverError(void) { int err; int sp; err = sqResolverError(); if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((1 - 1) * 4), ((err << 1) | 1)); stackPointer = sp; } } int primitiveResolverLocalAddress(void) { int addr; int oop; int sp; addr = sqResolverLocalAddress(); if (successFlag) { /* begin pop:thenPush: */ oop = intToNetAddress(addr); longAtput(sp = stackPointer - ((1 - 1) * 4), oop); stackPointer = sp; } } int primitiveResolverNameLookupResult(void) { int addr; int oop; int sp; addr = sqResolverNameLookupResult(); if (successFlag) { /* begin pop:thenPush: */ oop = intToNetAddress(addr); longAtput(sp = stackPointer - ((1 - 1) * 4), oop); stackPointer = sp; } } int primitiveResolverStartAddressLookup(void) { int addr; addr = netAddressToInt(longAt(stackPointer)); if (successFlag) { sqResolverStartAddrLookup(addr); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveResolverStartNameLookup(void) { int sz; int name; int sz1; int header; int fmt; int ccIndex; int cl; name = longAt(stackPointer); /* begin assertClassOf:is: */ if ((name & 1)) { successFlag = false; goto l2; } ccIndex = (((unsigned) (longAt(name))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(name - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)))) && successFlag; l2: /* end assertClassOf:is: */; if (successFlag) { /* begin lengthOf: */ header = longAt(name); if ((header & 3) == 0) { sz1 = (longAt(name - 8)) & 4294967292U; } else { sz1 = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { sz = ((unsigned) (sz1 - 4)) >> 2; goto l1; } else { sz = (sz1 - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf: */; sqResolverStartNameLookup(((char *) (name + 4)), sz); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveResolverStatus(void) { int status; int sp; status = sqResolverStatus(); if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((1 - 1) * 4), ((status << 1) | 1)); stackPointer = sp; } } int primitiveResponse(void) { int startTime; if (primitiveIndex > 700) { return false; } if (nextWakeupTick != 0) { startTime = ioLowResMSecs(); } successFlag = true; switch (primitiveIndex) { case 0: primitiveFail(); break; case 1: primitiveAdd(); break; case 2: primitiveSubtract(); break; case 3: primitiveLessThan(); break; case 4: primitiveGreaterThan(); break; case 5: primitiveLessOrEqual(); break; case 6: primitiveGreaterOrEqual(); break; case 7: primitiveEqual(); break; case 8: primitiveNotEqual(); break; case 9: primitiveMultiply(); break; case 10: primitiveDivide(); break; case 11: primitiveMod(); break; case 12: primitiveDiv(); break; case 13: primitiveQuo(); break; case 14: primitiveBitAnd(); break; case 15: primitiveBitOr(); break; case 16: primitiveBitXor(); break; case 17: primitiveBitShift(); break; case 18: primitiveMakePoint(); break; case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: primitiveFail(); break; case 40: primitiveAsFloat(); break; case 41: primitiveFloatAdd(); break; case 42: primitiveFloatSubtract(); break; case 43: primitiveFloatLessThan(); break; case 44: primitiveFloatGreaterThan(); break; case 45: primitiveFloatLessOrEqual(); break; case 46: primitiveFloatGreaterOrEqual(); break; case 47: primitiveFloatEqual(); break; case 48: primitiveFloatNotEqual(); break; case 49: primitiveFloatMultiply(); break; case 50: primitiveFloatDivide(); break; case 51: primitiveTruncated(); break; case 52: primitiveFractionalPart(); break; case 53: primitiveExponent(); break; case 54: primitiveTimesTwoPower(); break; case 55: primitiveSquareRoot(); break; case 56: primitiveSine(); break; case 57: primitiveArctan(); break; case 58: primitiveLogN(); break; case 59: primitiveExp(); break; case 60: primitiveAt(); break; case 61: primitiveAtPut(); break; case 62: primitiveSize(); break; case 63: primitiveStringAt(); break; case 64: primitiveStringAtPut(); break; case 65: primitiveNext(); break; case 66: primitiveNextPut(); break; case 67: primitiveAtEnd(); break; case 68: primitiveObjectAt(); break; case 69: primitiveObjectAtPut(); break; case 70: primitiveNew(); break; case 71: primitiveNewWithArg(); break; case 72: primitiveFail(); break; case 73: primitiveInstVarAt(); break; case 74: primitiveInstVarAtPut(); break; case 75: primitiveAsOop(); break; case 76: primitiveFail(); break; case 77: primitiveSomeInstance(); break; case 78: primitiveNextInstance(); break; case 79: primitiveNewMethod(); break; case 80: primitiveFail(); break; case 81: primitiveValue(); break; case 82: primitiveValueWithArgs(); break; case 83: primitivePerform(); break; case 84: primitivePerformWithArgs(); break; case 85: primitiveSignal(); break; case 86: primitiveWait(); break; case 87: primitiveResume(); break; case 88: primitiveSuspend(); break; case 89: primitiveFlushCache(); break; case 90: primitiveMousePoint(); break; case 91: case 92: primitiveFail(); break; case 93: primitiveInputSemaphore(); break; case 94: primitiveFail(); break; case 95: primitiveInputWord(); break; case 96: primitiveCopyBits(); break; case 97: primitiveSnapshot(); break; case 98: case 99: case 100: primitiveFail(); break; case 101: primitiveBeCursor(); break; case 102: primitiveBeDisplay(); break; case 103: primitiveScanCharacters(); break; case 104: primitiveDrawLoop(); break; case 105: primitiveStringReplace(); break; case 106: primitiveScreenSize(); break; case 107: primitiveMouseButtons(); break; case 108: primitiveKbdNext(); break; case 109: primitiveKbdPeek(); break; case 110: primitiveEquivalent(); break; case 111: primitiveClass(); break; case 112: primitiveBytesLeft(); break; case 113: primitiveQuit(); break; case 114: primitiveExitToDebugger(); break; case 115: case 116: case 117: primitiveFail(); break; case 118: primitiveDoPrimitiveWithArgs(); break; case 119: primitiveFlushCacheSelective(); break; case 120: primitiveFail(); break; case 121: primitiveImageName(); break; case 122: primitiveNoop(); break; case 123: primitiveFail(); break; case 124: primitiveLowSpaceSemaphore(); break; case 125: primitiveSignalAtBytesLeft(); break; case 126: primitiveDeferDisplayUpdates(); break; case 127: primitiveShowDisplayRect(); break; case 128: primitiveArrayBecome(); break; case 129: primitiveSpecialObjectsOop(); break; case 130: primitiveFullGC(); break; case 131: primitiveIncrementalGC(); break; case 132: primitiveObjectPointsTo(); break; case 133: primitiveSetInterruptKey(); break; case 134: primitiveInterruptSemaphore(); break; case 135: primitiveMillisecondClock(); break; case 136: primitiveSignalAtMilliseconds(); break; case 137: primitiveSecondsClock(); break; case 138: primitiveSomeObject(); break; case 139: primitiveNextObject(); break; case 140: primitiveBeep(); break; case 141: primitiveClipboardText(); break; case 142: primitiveVMPath(); break; case 143: primitiveShortAt(); break; case 144: primitiveShortAtPut(); break; case 145: primitiveConstantFill(); break; case 146: primitiveReadJoystick(); break; case 147: primitiveWarpBits(); break; case 148: primitiveClone(); break; case 149: primitiveGetAttribute(); break; case 150: primitiveFileAtEnd(); break; case 151: primitiveFileClose(); break; case 152: primitiveFileGetPosition(); break; case 153: primitiveFileOpen(); break; case 154: primitiveFileRead(); break; case 155: primitiveFileSetPosition(); break; case 156: primitiveFileDelete(); break; case 157: primitiveFileSize(); break; case 158: primitiveFileWrite(); break; case 159: primitiveFileRename(); break; case 160: primitiveDirectoryCreate(); break; case 161: primitiveDirectoryDelimitor(); break; case 162: primitiveDirectoryLookup(); break; case 163: case 164: case 165: case 166: case 167: case 168: primitiveFail(); break; case 169: primitiveDirectorySetMacTypeAndCreator(); break; case 170: primitiveSoundStart(); break; case 171: primitiveSoundStartWithSemaphore(); break; case 172: primitiveSoundStop(); break; case 173: primitiveSoundAvailableSpace(); break; case 174: primitiveSoundPlaySamples(); break; case 175: primitiveSoundPlaySilence(); break; case 176: primWaveTableSoundmixSampleCountintostartingAtpan(); break; case 177: primFMSoundmixSampleCountintostartingAtpan(); break; case 178: primPluckedSoundmixSampleCountintostartingAtpan(); break; case 179: primSampledSoundmixSampleCountintostartingAtpan(); break; case 180: primFMSoundmixSampleCountintostartingAtleftVolrightVol(); break; case 181: primPluckedSoundmixSampleCountintostartingAtleftVolrightVol(); break; case 182: primSampledSoundmixSampleCountintostartingAtleftVolrightVol(); break; case 183: primReverbSoundapplyReverbTostartingAtcount(); break; case 184: primLoopedSampledSoundmixSampleCountintostartingAtleftVolrightVol(); break; case 185: case 186: case 187: case 188: primitiveFail(); break; case 189: primitiveSoundInsertSamples(); break; case 190: primitiveSoundStartRecording(); break; case 191: primitiveSoundStopRecording(); break; case 192: primitiveSoundGetRecordingSampleRate(); break; case 193: primitiveSoundRecordSamples(); break; case 194: primitiveSoundSetRecordLevel(); break; case 195: case 196: case 197: case 198: case 199: primitiveFail(); break; case 200: primitiveInitializeNetwork(); break; case 201: primitiveResolverStartNameLookup(); break; case 202: primitiveResolverNameLookupResult(); break; case 203: primitiveResolverStartAddressLookup(); break; case 204: primitiveResolverAddressLookupResult(); break; case 205: primitiveResolverAbortLookup(); break; case 206: primitiveResolverLocalAddress(); break; case 207: primitiveResolverStatus(); break; case 208: primitiveResolverError(); break; case 209: primitiveSocketCreate(); break; case 210: primitiveSocketDestroy(); break; case 211: primitiveSocketConnectionStatus(); break; case 212: primitiveSocketError(); break; case 213: primitiveSocketLocalAddress(); break; case 214: primitiveSocketLocalPort(); break; case 215: primitiveSocketRemoteAddress(); break; case 216: primitiveSocketRemotePort(); break; case 217: primitiveSocketConnectToPort(); break; case 218: primitiveSocketListenOnPort(); break; case 219: primitiveSocketCloseConnection(); break; case 220: primitiveSocketAbortConnection(); break; case 221: primitiveSocketReceiveDataBufCount(); break; case 222: primitiveSocketReceiveDataAvailable(); break; case 223: primitiveSocketSendDataBufCount(); break; case 224: primitiveSocketSendDone(); break; case 225: case 226: case 227: case 228: case 229: primitiveFail(); break; case 230: primitiveRelinquishProcessor(); break; case 231: primitiveForceDisplayUpdate(); break; case 232: primitiveFormPrint(); break; case 233: primitiveSetFullScreen(); break; case 234: primBitmapdecompressfromByteArrayat(); break; case 235: primStringcomparewithcollated(); break; case 236: primSampledSoundconvert8bitSignedFromto16Bit(); break; case 237: primBitmapcompresstoByteArray(); break; case 238: primitiveSerialPortOpen(); break; case 239: primitiveSerialPortClose(); break; case 240: primitiveSerialPortWrite(); break; case 241: primitiveSerialPortRead(); break; case 242: primitiveFail(); break; case 243: primStringtranslatefromtotable(); break; case 244: primStringfindFirstInStringinSetstartingAt(); break; case 245: primStringindexOfAsciiinStringstartingAt(); break; case 246: case 247: case 248: case 249: primitiveFail(); break; case 250: clearProfile(); break; case 251: dumpProfile(); break; case 252: startProfiling(); break; case 253: stopProfiling(); break; case 254: primitiveVMParameter(); break; case 255: primitiveFail(); break; case 256: primitivePushSelf(); break; case 257: primitivePushTrue(); break; case 258: primitivePushFalse(); break; case 259: primitivePushNil(); break; case 260: primitivePushMinusOne(); break; case 261: primitivePushZero(); break; case 262: primitivePushOne(); break; case 263: primitivePushTwo(); break; case 264: case 265: case 266: case 267: case 268: case 269: case 270: case 271: case 272: case 273: case 274: case 275: case 276: case 277: case 278: case 279: case 280: case 281: case 282: case 283: case 284: case 285: case 286: case 287: case 288: case 289: case 290: case 291: case 292: case 293: case 294: case 295: case 296: case 297: case 298: case 299: case 300: case 301: case 302: case 303: case 304: case 305: case 306: case 307: case 308: case 309: case 310: case 311: case 312: case 313: case 314: case 315: case 316: case 317: case 318: case 319: case 320: case 321: case 322: case 323: case 324: case 325: case 326: case 327: case 328: case 329: case 330: case 331: case 332: case 333: case 334: case 335: case 336: case 337: case 338: case 339: case 340: case 341: case 342: case 343: case 344: case 345: case 346: case 347: case 348: case 349: case 350: case 351: case 352: case 353: case 354: case 355: case 356: case 357: case 358: case 359: case 360: case 361: case 362: case 363: case 364: case 365: case 366: case 367: case 368: case 369: case 370: case 371: case 372: case 373: case 374: case 375: case 376: case 377: case 378: case 379: case 380: case 381: case 382: case 383: case 384: case 385: case 386: case 387: case 388: case 389: case 390: case 391: case 392: case 393: case 394: case 395: case 396: case 397: case 398: case 399: case 400: case 401: case 402: case 403: case 404: case 405: case 406: case 407: case 408: case 409: case 410: case 411: case 412: case 413: case 414: case 415: case 416: case 417: case 418: case 419: case 420: case 421: case 422: case 423: case 424: case 425: case 426: case 427: case 428: case 429: case 430: case 431: case 432: case 433: case 434: case 435: case 436: case 437: case 438: case 439: case 440: case 441: case 442: case 443: case 444: case 445: case 446: case 447: case 448: case 449: case 450: case 451: case 452: case 453: case 454: case 455: case 456: case 457: case 458: case 459: case 460: case 461: case 462: case 463: case 464: case 465: case 466: case 467: case 468: case 469: case 470: case 471: case 472: case 473: case 474: case 475: case 476: case 477: case 478: case 479: case 480: case 481: case 482: case 483: case 484: case 485: case 486: case 487: case 488: case 489: case 490: case 491: case 492: case 493: case 494: case 495: case 496: case 497: case 498: case 499: case 500: case 501: case 502: case 503: case 504: case 505: case 506: case 507: case 508: case 509: case 510: case 511: case 512: case 513: case 514: case 515: case 516: case 517: case 518: case 519: primitiveLoadInstVar(); break; case 520: primitiveFail(); break; case 521: primitiveMIDIClosePort(); break; case 522: primitiveMIDIGetClock(); break; case 523: primitiveMIDIGetPortCount(); break; case 524: primitiveMIDIGetPortDirectionality(); break; case 525: primitiveMIDIGetPortName(); break; case 526: primitiveMIDIOpenPort(); break; case 527: primitiveMIDIParameterGetOrSet(); break; case 528: primitiveMIDIRead(); break; case 529: primitiveMIDIWrite(); break; case 530: case 531: case 532: case 533: case 534: case 535: case 536: case 537: case 538: case 539: primitiveFail(); break; case 540: primitiveAsyncFileClose(); break; case 541: primitiveAsyncFileOpen(); break; case 542: primitiveAsyncFileReadResult(); break; case 543: primitiveAsyncFileReadStart(); break; case 544: primitiveAsyncFileWriteResult(); break; case 545: primitiveAsyncFileWriteStart(); break; case 546: case 547: case 548: case 549: case 550: case 551: case 552: case 553: case 554: case 555: case 556: case 557: case 558: case 559: case 560: case 561: case 562: case 563: case 564: case 565: case 566: case 567: case 568: case 569: case 570: case 571: case 572: case 573: case 574: case 575: case 576: case 577: case 578: case 579: case 580: case 581: case 582: case 583: case 584: case 585: case 586: case 587: case 588: case 589: case 590: case 591: case 592: case 593: case 594: case 595: case 596: case 597: case 598: case 599: case 600: case 601: case 602: case 603: case 604: case 605: case 606: case 607: case 608: case 609: case 610: case 611: case 612: case 613: case 614: case 615: case 616: case 617: case 618: case 619: case 620: case 621: case 622: case 623: case 624: case 625: case 626: case 627: case 628: case 629: case 630: case 631: case 632: case 633: case 634: case 635: case 636: case 637: case 638: case 639: case 640: case 641: case 642: case 643: case 644: case 645: case 646: case 647: case 648: case 649: case 650: case 651: case 652: case 653: case 654: case 655: case 656: case 657: case 658: case 659: case 660: case 661: case 662: case 663: case 664: case 665: case 666: case 667: case 668: case 669: case 670: case 671: case 672: case 673: case 674: case 675: case 676: case 677: case 678: case 679: case 680: case 681: case 682: case 683: case 684: case 685: case 686: case 687: case 688: case 689: case 690: case 691: case 692: case 693: case 694: case 695: case 696: case 697: case 698: case 699: case 700: primitiveFail(); break; } if ((nextWakeupTick != 0) && ((ioLowResMSecs()) != startTime)) { if (((ioMSecs()) & 536870911) >= nextWakeupTick) { if (successFlag) { checkForInterrupts(); } else { interruptCheckCounter = 0; } } } return successFlag; } int primitiveResume(void) { int proc; proc = longAt(stackPointer); if (successFlag) { resume(proc); } } int primitiveScanCharacters(void) { int stopArray; int displayFlag; int start; int stop; int string; int rcvr; int rightX; int sp; int integerPointer; int integerPointer1; int integerPointer2; int successValue; int sourceX2; int ascii; int top; int nextDestX; int charVal; int left; int lastIndex; int objectPointer; int integerValue; int lastIndex1; int objectPointer1; int objectPointer2; int objectPointer3; rcvr = longAt(stackPointer - (6 * 4)); /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (5 * 4)); if ((integerPointer & 1)) { start = (integerPointer >> 1); goto l1; } else { primitiveFail(); start = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (4 * 4)); if ((integerPointer1 & 1)) { stop = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); stop = 0; goto l2; } l2: /* end stackIntegerValue: */; string = longAt(stackPointer - (3 * 4)); /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (2 * 4)); if ((integerPointer2 & 1)) { rightX = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); rightX = 0; goto l3; } l3: /* end stackIntegerValue: */; stopArray = longAt(stackPointer - (1 * 4)); /* begin booleanValueOf: */ if ((longAt(stackPointer - (0 * 4))) == trueObj) { displayFlag = true; goto l4; } if ((longAt(stackPointer - (0 * 4))) == falseObj) { displayFlag = false; goto l4; } successFlag = false; displayFlag = null; l4: /* end booleanValueOf: */; if (!(successFlag)) { return null; } /* begin success: */ successValue = loadScannerFromstartstopstringrightXstopArraydisplayFlag(rcvr, start, stop, string, rightX, stopArray, displayFlag); successFlag = successValue && successFlag; if (successFlag) { /* begin scanCharacters */ if (scanDisplayFlag) { clipRange(); left = dx; top = dy; } lastIndex = scanStart; while (lastIndex <= scanStop) { charVal = stObjectat(scanString, lastIndex); ascii = (charVal >> 1); if (!successFlag) { goto l6; } stopCode = stObjectat(scanStopArray, ascii + 1); if (!successFlag) { goto l6; } if (!(stopCode == nilObj)) { /* begin returnAt:lastIndex:left:top: */ stopCode = stObjectat(scanStopArray, ascii + 1); if (!successFlag) { goto l6; } /* begin storeInteger:ofObject:withValue: */ objectPointer1 = bitBltOop; if ((lastIndex ^ (lastIndex << 1)) >= 0) { longAtput(((((char *) objectPointer1)) + 4) + (15 << 2), ((lastIndex << 1) | 1)); } else { primitiveFail(); } if (scanDisplayFlag) { affectedL = left; affectedR = bbW + dx; affectedT = top; affectedB = bbH + dy; } goto l6; } sourceX = stObjectat(scanXTable, ascii + 1); sourceX2 = stObjectat(scanXTable, ascii + 2); if (!successFlag) { goto l6; } if (((sourceX & 1)) && ((sourceX2 & 1))) { sourceX = (sourceX >> 1); sourceX2 = (sourceX2 >> 1); } else { primitiveFail(); goto l6; } nextDestX = destX + (width = sourceX2 - sourceX); if (nextDestX > scanRightX) { /* begin returnAt:lastIndex:left:top: */ stopCode = stObjectat(scanStopArray, 258); if (!successFlag) { goto l6; } /* begin storeInteger:ofObject:withValue: */ objectPointer2 = bitBltOop; if ((lastIndex ^ (lastIndex << 1)) >= 0) { longAtput(((((char *) objectPointer2)) + 4) + (15 << 2), ((lastIndex << 1) | 1)); } else { primitiveFail(); } if (scanDisplayFlag) { affectedL = left; affectedR = bbW + dx; affectedT = top; affectedB = bbH + dy; } goto l6; } if (scanDisplayFlag) { copyBits(); } destX = nextDestX; /* begin storeInteger:ofObject:withValue: */ objectPointer = bitBltOop; integerValue = destX; if ((integerValue ^ (integerValue << 1)) >= 0) { longAtput(((((char *) objectPointer)) + 4) + (4 << 2), ((integerValue << 1) | 1)); } else { primitiveFail(); } lastIndex += 1; } /* begin returnAt:lastIndex:left:top: */ lastIndex1 = scanStop; stopCode = stObjectat(scanStopArray, 257); if (!successFlag) { goto l5; } /* begin storeInteger:ofObject:withValue: */ objectPointer3 = bitBltOop; if ((lastIndex1 ^ (lastIndex1 << 1)) >= 0) { longAtput(((((char *) objectPointer3)) + 4) + (15 << 2), ((lastIndex1 << 1) | 1)); } else { primitiveFail(); } if (scanDisplayFlag) { affectedL = left; affectedR = bbW + dx; affectedT = top; affectedB = bbH + dy; } l5: /* end returnAt:lastIndex:left:top: */; l6: /* end scanCharacters */; } if (successFlag) { if (displayFlag) { showDisplayBits(); } /* begin pop: */ stackPointer -= 7 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, stopCode); stackPointer = sp; } } int primitiveScreenSize(void) { int pointWord; int object; int sp; int pointResult; /* begin pop: */ stackPointer -= 1 * 4; pointWord = ioScreenSize(); /* begin push: */ /* begin makePointwithxValue:yValue: */ pointResult = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (12 << 2)), 12, nilObj); /* begin storePointer:ofObject:withValue: */ if (pointResult < youngStart) { possibleRootStoreIntovalue(pointResult, ((((((unsigned) pointWord) >> 16) & 65535) << 1) | 1)); } longAtput(((((char *) pointResult)) + 4) + (0 << 2), ((((((unsigned) pointWord) >> 16) & 65535) << 1) | 1)); /* begin storePointer:ofObject:withValue: */ if (pointResult < youngStart) { possibleRootStoreIntovalue(pointResult, (((pointWord & 65535) << 1) | 1)); } longAtput(((((char *) pointResult)) + 4) + (1 << 2), (((pointWord & 65535) << 1) | 1)); object = pointResult; longAtput(sp = stackPointer + 4, object); stackPointer = sp; } int primitiveSecondsClock(void) { int object; int sp; /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ object = positive32BitIntegerFor(ioSeconds()); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } int primitiveSerialPortClose(void) { int portNum; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { portNum = (integerPointer >> 1); goto l1; } else { primitiveFail(); portNum = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { serialPortClose(portNum); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveSerialPortOpen(void) { int dataBits; int parityType; int stopBitsType; int portNum; int baudRate; int xOnChar; int xOffChar; int inFlowControl; int outFlowControl; int integerPointer; int integerPointer1; int integerPointer2; int integerPointer3; int integerPointer4; int integerPointer5; int integerPointer6; int integerPointer7; int integerPointer8; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { xOffChar = (integerPointer >> 1); goto l1; } else { primitiveFail(); xOffChar = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { xOnChar = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); xOnChar = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (2 * 4)); if ((integerPointer2 & 1)) { outFlowControl = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); outFlowControl = 0; goto l3; } l3: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer3 = longAt(stackPointer - (3 * 4)); if ((integerPointer3 & 1)) { inFlowControl = (integerPointer3 >> 1); goto l4; } else { primitiveFail(); inFlowControl = 0; goto l4; } l4: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer4 = longAt(stackPointer - (4 * 4)); if ((integerPointer4 & 1)) { dataBits = (integerPointer4 >> 1); goto l5; } else { primitiveFail(); dataBits = 0; goto l5; } l5: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer5 = longAt(stackPointer - (5 * 4)); if ((integerPointer5 & 1)) { parityType = (integerPointer5 >> 1); goto l6; } else { primitiveFail(); parityType = 0; goto l6; } l6: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer6 = longAt(stackPointer - (6 * 4)); if ((integerPointer6 & 1)) { stopBitsType = (integerPointer6 >> 1); goto l7; } else { primitiveFail(); stopBitsType = 0; goto l7; } l7: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer7 = longAt(stackPointer - (7 * 4)); if ((integerPointer7 & 1)) { baudRate = (integerPointer7 >> 1); goto l8; } else { primitiveFail(); baudRate = 0; goto l8; } l8: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer8 = longAt(stackPointer - (8 * 4)); if ((integerPointer8 & 1)) { portNum = (integerPointer8 >> 1); goto l9; } else { primitiveFail(); portNum = 0; goto l9; } l9: /* end stackIntegerValue: */; if (successFlag) { serialPortOpen( portNum, baudRate, stopBitsType, parityType, dataBits, inFlowControl, outFlowControl, xOnChar, xOffChar); } if (successFlag) { /* begin pop: */ stackPointer -= 9 * 4; } } int primitiveSerialPortRead(void) { int array; int startIndex; int portNum; int bytesRead; int count; int fmt; int sp; int integerPointer; int integerPointer1; int integerPointer2; int successValue; int successValue1; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { startIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); startIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; array = longAt(stackPointer - (2 * 4)); /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (3 * 4)); if ((integerPointer2 & 1)) { portNum = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); portNum = 0; goto l3; } l3: /* end stackIntegerValue: */; fmt = (((unsigned) (longAt(array))) >> 8) & 15; /* begin success: */ successValue = (fmt >= 8) && (fmt <= 11); successFlag = successValue && successFlag; /* begin success: */ successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= (lengthOf(array))); successFlag = successValue1 && successFlag; if (successFlag) { bytesRead = serialPortReadInto(portNum, count, ((array + 4) + startIndex) - 1); } if (successFlag) { /* begin pop: */ stackPointer -= 5 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((bytesRead << 1) | 1)); stackPointer = sp; } } int primitiveSerialPortWrite(void) { int array; int startIndex; int portNum; int bytesWritten; int count; int fmt; int integerPointer; int integerPointer1; int integerPointer2; int successValue; int successValue1; int sp; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { startIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); startIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; array = longAt(stackPointer - (2 * 4)); /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (3 * 4)); if ((integerPointer2 & 1)) { portNum = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); portNum = 0; goto l3; } l3: /* end stackIntegerValue: */; fmt = (((unsigned) (longAt(array))) >> 8) & 15; /* begin success: */ successValue = (fmt >= 8) && (fmt <= 11); successFlag = successValue && successFlag; /* begin success: */ successValue1 = (startIndex >= 1) && (((startIndex + count) - 1) <= (lengthOf(array))); successFlag = successValue1 && successFlag; if (successFlag) { bytesWritten = serialPortWriteFrom(portNum, count, ((array + 4) + startIndex) - 1); } if (successFlag) { /* begin pop: */ stackPointer -= 5 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((bytesWritten << 1) | 1)); stackPointer = sp; } } int primitiveSetFullScreen(void) { int argOop; argOop = longAt(stackPointer); if (argOop == trueObj) { ioSetFullScreen(true); } else { if (argOop == falseObj) { ioSetFullScreen(false); } else { primitiveFail(); } } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveSetInterruptKey(void) { int keycode; int integerPointer; int top; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { keycode = (integerPointer >> 1); goto l1; } else { successFlag = false; keycode = 1; goto l1; } l1: /* end popInteger */; if (successFlag) { interruptKeycode = keycode; } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveShortAt(void) { int addr; int sz; int value; int index; int rcvr; int integerPointer; int successValue; int successValue1; int sp; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { index = (integerPointer >> 1); goto l1; } else { primitiveFail(); index = 0; goto l1; } l1: /* end stackIntegerValue: */; rcvr = longAt(stackPointer - (1 * 4)); /* begin success: */ successValue = (!((rcvr & 1))) && (isWordsOrBytes(rcvr)); successFlag = successValue && successFlag; if (!(successFlag)) { return null; } sz = ((int) ((sizeBitsOf(rcvr)) - 4) >> 1); /* begin success: */ successValue1 = (index >= 1) && (index <= sz); successFlag = successValue1 && successFlag; if (successFlag) { addr = (rcvr + 4) + (2 * (index - 1)); value = *((short int *) addr); /* begin pop: */ stackPointer -= 2 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((value << 1) | 1)); stackPointer = sp; } } int primitiveShortAtPut(void) { int addr; int sz; int value; int index; int rcvr; int integerPointer; int integerPointer1; int successValue; int successValue1; int successValue2; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { value = (integerPointer >> 1); goto l1; } else { primitiveFail(); value = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { index = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); index = 0; goto l2; } l2: /* end stackIntegerValue: */; rcvr = longAt(stackPointer - (2 * 4)); /* begin success: */ successValue = (!((rcvr & 1))) && (isWordsOrBytes(rcvr)); successFlag = successValue && successFlag; if (!(successFlag)) { return null; } sz = ((int) ((sizeBitsOf(rcvr)) - 4) >> 1); /* begin success: */ successValue1 = (index >= 1) && (index <= sz); successFlag = successValue1 && successFlag; /* begin success: */ successValue2 = (value >= -32768) && (value <= 32767); successFlag = successValue2 && successFlag; if (successFlag) { addr = (rcvr + 4) + (2 * (index - 1)); *((short int *) addr) = value; /* begin pop: */ stackPointer -= 2 * 4; } } int primitiveShowDisplayRect(void) { int displayObj; int dispBits; int dispBitsPtr; int top; int bottom; int h; int w; int d; int right; int left; int integerPointer; int integerPointer1; int integerPointer2; int integerPointer3; int successValue; int successValue1; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { bottom = (integerPointer >> 1); goto l1; } else { primitiveFail(); bottom = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { top = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); top = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (2 * 4)); if ((integerPointer2 & 1)) { right = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); right = 0; goto l3; } l3: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer3 = longAt(stackPointer - (3 * 4)); if ((integerPointer3 & 1)) { left = (integerPointer3 >> 1); goto l4; } else { primitiveFail(); left = 0; goto l4; } l4: /* end stackIntegerValue: */; displayObj = longAt(((((char *) specialObjectsOop)) + 4) + (14 << 2)); /* begin success: */ successValue = (((((unsigned) (longAt(displayObj))) >> 8) & 15) <= 4) && ((lengthOf(displayObj)) >= 4); successFlag = successValue && successFlag; if (successFlag) { dispBits = longAt(((((char *) displayObj)) + 4) + (0 << 2)); w = fetchIntegerofObject(1, displayObj); h = fetchIntegerofObject(2, displayObj); d = fetchIntegerofObject(3, displayObj); } if (left < 0) { left = 0; } if (right > w) { right = w; } if (top < 0) { top = 0; } if (bottom > h) { bottom = h; } /* begin success: */ successValue1 = (left <= right) && (top <= bottom); successFlag = successValue1 && successFlag; if (successFlag) { dispBitsPtr = dispBits + 4; ioShowDisplay(dispBitsPtr, w, h, d, left, right, top, bottom); } if (successFlag) { /* begin pop: */ stackPointer -= 4 * 4; } } int primitiveSignal(void) { int sema; int ccIndex; int cl; sema = longAt(stackPointer); /* begin assertClassOf:is: */ if ((sema & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(sema))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(sema - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { synchronousSignal(sema); } } int primitiveSignalAtBytesLeft(void) { int bytes; int integerPointer; int top; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { bytes = (integerPointer >> 1); goto l1; } else { successFlag = false; bytes = 1; goto l1; } l1: /* end popInteger */; if (successFlag) { lowSpaceThreshold = bytes; } else { lowSpaceThreshold = 0; /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveSignalAtMilliseconds(void) { int sema; int tick; int oop; int oop1; int valuePointer; int integerPointer; int top; int top1; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { tick = (integerPointer >> 1); goto l1; } else { successFlag = false; tick = 1; goto l1; } l1: /* end popInteger */; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; sema = top1; if (successFlag) { if ((fetchClassOf(sema)) == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) { /* begin storePointer:ofObject:withValue: */ oop = specialObjectsOop; if (oop < youngStart) { possibleRootStoreIntovalue(oop, sema); } longAtput(((((char *) oop)) + 4) + (29 << 2), sema); nextWakeupTick = tick; } else { /* begin storePointer:ofObject:withValue: */ oop1 = specialObjectsOop; valuePointer = nilObj; if (oop1 < youngStart) { possibleRootStoreIntovalue(oop1, valuePointer); } longAtput(((((char *) oop1)) + 4) + (29 << 2), valuePointer); nextWakeupTick = 0; } } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveSine(void) { double rcvr; rcvr = popFloat(); if (successFlag) { pushFloat(sin(rcvr)); } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveSize(void) { int sz; int rcvr; int sp; int hdr; int totalLength; int fmt; int fixedFields; int sz1; int classFormat; int class; int ccIndex; rcvr = longAt(stackPointer); if ((rcvr & 1)) { sz = 0; } else { /* begin stSizeOf: */ hdr = longAt(rcvr); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz1 = (longAt(rcvr - 8)) & 4294967292U; } else { sz1 = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz1 - 4)) >> 2; goto l1; } else { totalLength = (sz1 - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l2; } if (fmt < 2) { fixedFields = totalLength; goto l2; } /* begin fetchClassOf: */ if ((rcvr & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l3; } ccIndex = ((((unsigned) (longAt(rcvr))) >> 12) & 31) - 1; if (ccIndex < 0) { class = (longAt(rcvr - 4)) & 4294967292U; goto l3; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l3; } l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l2: /* end fixedFieldsOf:format:length: */; sz = totalLength - fixedFields; } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, ((sz << 1) | 1)); stackPointer = sp; } else { failSpecialPrim(62); } } int primitiveSnapshot(void) { int activeProc; int dataSize; int rcvr; int top; int sp; int sp1; int sp2; int valuePointer; /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); activeProc = longAt(((((char *) (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2))))) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ valuePointer = activeContext; if (activeProc < youngStart) { possibleRootStoreIntovalue(activeProc, valuePointer); } longAtput(((((char *) activeProc)) + 4) + (1 << 2), valuePointer); incrementalGC(); fullGC(); dataSize = freeBlock - (startOfMemory()); if (successFlag) { /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; rcvr = top; /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; writeImageFile(dataSize); /* begin pop: */ stackPointer -= 1 * 4; } if (successFlag) { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } else { /* begin push: */ longAtput(sp2 = stackPointer + 4, rcvr); stackPointer = sp2; } } int primitiveSocketAbortConnection(void) { SocketPtr s; s = socketValueOf(longAt(stackPointer)); if (successFlag) { sqSocketAbortConnection(s); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveSocketCloseConnection(void) { SocketPtr s; s = socketValueOf(longAt(stackPointer)); if (successFlag) { sqSocketCloseConnection(s); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveSocketConnectToPort(void) { int addr; int port; SocketPtr s; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { port = (integerPointer >> 1); goto l1; } else { primitiveFail(); port = 0; goto l1; } l1: /* end stackIntegerValue: */; addr = netAddressToInt(longAt(stackPointer - (1 * 4))); s = socketValueOf(longAt(stackPointer - (2 * 4))); if (successFlag) { sqSocketConnectToPort(s, addr, port); } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; } } int primitiveSocketConnectionStatus(void) { int status; SocketPtr s; int sp; s = socketValueOf(longAt(stackPointer)); if (successFlag) { status = sqSocketConnectionStatus(s); } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), ((status << 1) | 1)); stackPointer = sp; } } int primitiveSocketCreate(void) { int semaIndex; int socketType; int sendBufSize; int socketOop; int netType; SocketPtr s; int recvBufSize; int sp; int integerPointer; int integerPointer1; int integerPointer2; int integerPointer3; int integerPointer4; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { semaIndex = (integerPointer >> 1); goto l1; } else { primitiveFail(); semaIndex = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { sendBufSize = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); sendBufSize = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (2 * 4)); if ((integerPointer2 & 1)) { recvBufSize = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); recvBufSize = 0; goto l3; } l3: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer3 = longAt(stackPointer - (3 * 4)); if ((integerPointer3 & 1)) { socketType = (integerPointer3 >> 1); goto l4; } else { primitiveFail(); socketType = 0; goto l4; } l4: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer4 = longAt(stackPointer - (4 * 4)); if ((integerPointer4 & 1)) { netType = (integerPointer4 >> 1); goto l5; } else { primitiveFail(); netType = 0; goto l5; } l5: /* end stackIntegerValue: */; if (successFlag) { socketOop = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (26 << 2)), socketRecordSize()); s = socketValueOf(socketOop); sqSocketCreateNetTypeSocketTypeRecvBytesSendBytesSemaID(s, netType, socketType, recvBufSize, sendBufSize, semaIndex); if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((6 - 1) * 4), socketOop); stackPointer = sp; } } } int primitiveSocketDestroy(void) { SocketPtr s; s = socketValueOf(longAt(stackPointer)); if (successFlag) { sqSocketDestroy(s); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveSocketError(void) { int err; SocketPtr s; int sp; s = socketValueOf(longAt(stackPointer)); if (successFlag) { err = sqSocketError(s); } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), ((err << 1) | 1)); stackPointer = sp; } } int primitiveSocketListenOnPort(void) { int port; SocketPtr s; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { port = (integerPointer >> 1); goto l1; } else { primitiveFail(); port = 0; goto l1; } l1: /* end stackIntegerValue: */; s = socketValueOf(longAt(stackPointer - (1 * 4))); if (successFlag) { sqSocketListenOnPort(s, port); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; } } int primitiveSocketLocalAddress(void) { int addr; SocketPtr s; int oop; int sp; s = socketValueOf(longAt(stackPointer)); if (successFlag) { addr = sqSocketLocalAddress(s); } if (successFlag) { /* begin pop:thenPush: */ oop = intToNetAddress(addr); longAtput(sp = stackPointer - ((2 - 1) * 4), oop); stackPointer = sp; } } int primitiveSocketLocalPort(void) { int port; SocketPtr s; int sp; s = socketValueOf(longAt(stackPointer)); if (successFlag) { port = sqSocketLocalPort(s); } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), ((port << 1) | 1)); stackPointer = sp; } } int primitiveSocketReceiveDataAvailable(void) { int dataIsAvailable; SocketPtr s; int sp; int sp1; s = socketValueOf(longAt(stackPointer)); if (successFlag) { dataIsAvailable = sqSocketReceiveDataAvailable(s); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (dataIsAvailable) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveSocketReceiveDataBufCount(void) { int array; int startIndex; int arrayBase; int bytesReceived; int bufStart; int byteSize; SocketPtr s; int count; int sp; int integerPointer; int integerPointer1; int successValue; int successValue1; int fmt; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { startIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); startIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; array = longAt(stackPointer - (2 * 4)); s = socketValueOf(longAt(stackPointer - (3 * 4))); /* begin success: */ /* begin isWordsOrBytes: */ fmt = (((unsigned) (longAt(array))) >> 8) & 15; successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); successFlag = successValue && successFlag; if (((((unsigned) (longAt(array))) >> 8) & 15) == 6) { byteSize = 4; } else { byteSize = 1; } /* begin success: */ successValue1 = (startIndex >= 1) && ((count >= 0) && (((startIndex + count) - 1) <= (lengthOf(array)))); successFlag = successValue1 && successFlag; if (successFlag) { arrayBase = array + 4; bufStart = arrayBase + ((startIndex - 1) * byteSize); bytesReceived = sqSocketReceiveDataBufCount(s, bufStart, count * byteSize); } if (successFlag) { /* begin pop: */ stackPointer -= 5 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, (((bytesReceived / byteSize) << 1) | 1)); stackPointer = sp; } } int primitiveSocketRemoteAddress(void) { int addr; SocketPtr s; int oop; int sp; s = socketValueOf(longAt(stackPointer)); if (successFlag) { addr = sqSocketRemoteAddress(s); } if (successFlag) { /* begin pop:thenPush: */ oop = intToNetAddress(addr); longAtput(sp = stackPointer - ((2 - 1) * 4), oop); stackPointer = sp; } } int primitiveSocketRemotePort(void) { int port; SocketPtr s; int sp; s = socketValueOf(longAt(stackPointer)); if (successFlag) { port = sqSocketRemotePort(s); } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), ((port << 1) | 1)); stackPointer = sp; } } int primitiveSocketSendDataBufCount(void) { int array; int startIndex; int arrayBase; int bytesSent; int bufStart; int byteSize; SocketPtr s; int count; int sp; int integerPointer; int integerPointer1; int successValue; int successValue1; int fmt; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { count = (integerPointer >> 1); goto l1; } else { primitiveFail(); count = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (1 * 4)); if ((integerPointer1 & 1)) { startIndex = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); startIndex = 0; goto l2; } l2: /* end stackIntegerValue: */; array = longAt(stackPointer - (2 * 4)); s = socketValueOf(longAt(stackPointer - (3 * 4))); /* begin success: */ /* begin isWordsOrBytes: */ fmt = (((unsigned) (longAt(array))) >> 8) & 15; successValue = (fmt == 6) || ((fmt >= 8) && (fmt <= 11)); successFlag = successValue && successFlag; if (((((unsigned) (longAt(array))) >> 8) & 15) == 6) { byteSize = 4; } else { byteSize = 1; } /* begin success: */ successValue1 = (startIndex >= 1) && ((count >= 0) && (((startIndex + count) - 1) <= (lengthOf(array)))); successFlag = successValue1 && successFlag; if (successFlag) { arrayBase = array + 4; bufStart = arrayBase + ((startIndex - 1) * byteSize); bytesSent = sqSocketSendDataBufCount(s, bufStart, count * byteSize); } if (successFlag) { /* begin pop: */ stackPointer -= 5 * 4; /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, (((bytesSent / byteSize) << 1) | 1)); stackPointer = sp; } } int primitiveSocketSendDone(void) { int done; SocketPtr s; int sp; int sp1; s = socketValueOf(longAt(stackPointer)); if (successFlag) { done = sqSocketSendDone(s); } if (successFlag) { /* begin pop: */ stackPointer -= 2 * 4; /* begin pushBool: */ if (done) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } } int primitiveSomeInstance(void) { int instance; int class; int sp; int top; int thisClass; int thisObj; int ccIndex; int obj; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; class = top; /* begin initialInstanceOf: */ /* begin firstAccessibleObject */ /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; obj = chunk + extra; while (obj < endOfMemory) { if (!(((longAt(obj)) & 3) == 2)) { thisObj = obj; goto l4; } /* begin objectAfter: */ if (checkAssertions) { if (obj >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(obj)) & 3) == 2) { sz = (longAt(obj)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(obj); if ((header & 3) == 0) { sz = (longAt(obj - 8)) & 4294967292U; goto l3; } else { sz = header & 252; goto l3; } l3: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(obj + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; obj = (obj + sz) + extra2; } error("heap is empty"); l4: /* end firstAccessibleObject */; while (!(thisObj == null)) { /* begin fetchClassOf: */ if ((thisObj & 1)) { thisClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l2; } ccIndex = ((((unsigned) (longAt(thisObj))) >> 12) & 31) - 1; if (ccIndex < 0) { thisClass = (longAt(thisObj - 4)) & 4294967292U; goto l2; } else { thisClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l2; } l2: /* end fetchClassOf: */; if (thisClass == class) { instance = thisObj; goto l1; } thisObj = accessibleObjectAfter(thisObj); } instance = nilObj; l1: /* end initialInstanceOf: */; if (instance == nilObj) { /* begin unPop: */ stackPointer += 1 * 4; primitiveFail(); } else { /* begin push: */ longAtput(sp = stackPointer + 4, instance); stackPointer = sp; } } int primitiveSomeObject(void) { int object; int sp; int obj; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ /* begin firstAccessibleObject */ /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; obj = chunk + extra; while (obj < endOfMemory) { if (!(((longAt(obj)) & 3) == 2)) { object = obj; goto l2; } /* begin objectAfter: */ if (checkAssertions) { if (obj >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(obj)) & 3) == 2) { sz = (longAt(obj)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(obj); if ((header & 3) == 0) { sz = (longAt(obj - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(obj + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; obj = (obj + sz) + extra2; } error("heap is empty"); l2: /* end firstAccessibleObject */; longAtput(sp = stackPointer + 4, object); stackPointer = sp; } int primitiveSoundAvailableSpace(void) { int frames; int object; int sp; frames = snd_AvailableSpace(); /* begin success: */ successFlag = (frames >= 0) && successFlag; if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ object = positive32BitIntegerFor(frames); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } } int primitiveSoundGetRecordingSampleRate(void) { double rate; rate = snd_GetRecordingSampleRate(); if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; pushFloat(rate); } } int primitiveSoundInsertSamples(void) { int buf; int leadTime; int frameCount; int framesPlayed; int object; int sp; int integerPointer; int integerPointer1; int successValue; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { leadTime = (integerPointer >> 1); goto l1; } else { primitiveFail(); leadTime = 0; goto l1; } l1: /* end stackIntegerValue: */; buf = longAt(stackPointer - (1 * 4)); /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (2 * 4)); if ((integerPointer1 & 1)) { frameCount = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); frameCount = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin success: */ successFlag = (((((unsigned) (longAt(buf))) >> 8) & 15) == 6) && successFlag; /* begin success: */ successValue = frameCount <= (lengthOf(buf)); successFlag = successValue && successFlag; if (successFlag) { framesPlayed = snd_InsertSamplesFromLeadTime(frameCount, buf + 4, leadTime); /* begin success: */ successFlag = (framesPlayed >= 0) && successFlag; } if (successFlag) { /* begin pop: */ stackPointer -= 4 * 4; /* begin push: */ object = positive32BitIntegerFor(framesPlayed); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } } int primitiveSoundPlaySamples(void) { int startIndex; int buf; int frameCount; int framesPlayed; int object; int sp; int integerPointer; int integerPointer1; int successValue; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { startIndex = (integerPointer >> 1); goto l1; } else { primitiveFail(); startIndex = 0; goto l1; } l1: /* end stackIntegerValue: */; buf = longAt(stackPointer - (1 * 4)); /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (2 * 4)); if ((integerPointer1 & 1)) { frameCount = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); frameCount = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin success: */ successFlag = (((((unsigned) (longAt(buf))) >> 8) & 15) == 6) && successFlag; /* begin success: */ successValue = (startIndex >= 1) && (((startIndex + frameCount) - 1) <= (lengthOf(buf))); successFlag = successValue && successFlag; if (successFlag) { framesPlayed = snd_PlaySamplesFromAtLength(frameCount, buf + 4, startIndex - 1); /* begin success: */ successFlag = (framesPlayed >= 0) && successFlag; } if (successFlag) { /* begin pop: */ stackPointer -= 4 * 4; /* begin push: */ object = positive32BitIntegerFor(framesPlayed); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } } int primitiveSoundPlaySilence(void) { int framesPlayed; int object; int sp; framesPlayed = snd_PlaySilence(); /* begin success: */ successFlag = (framesPlayed >= 0) && successFlag; if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ object = positive32BitIntegerFor(framesPlayed); longAtput(sp = stackPointer + 4, object); stackPointer = sp; } } int primitiveSoundRecordSamples(void) { int startWordIndex; int samplesRecorded; int bufSizeInBytes; int buf; int successValue; int sp; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { startWordIndex = (integerPointer >> 1); goto l1; } else { primitiveFail(); startWordIndex = 0; goto l1; } l1: /* end stackIntegerValue: */; buf = longAt(stackPointer - (1 * 4)); /* begin success: */ successFlag = (((((unsigned) (longAt(buf))) >> 8) & 15) == 6) && successFlag; if (successFlag) { bufSizeInBytes = (lengthOf(buf)) * 4; /* begin success: */ successValue = (startWordIndex >= 1) && (((startWordIndex - 1) * 2) < bufSizeInBytes); successFlag = successValue && successFlag; } if (successFlag) { samplesRecorded = snd_RecordSamplesIntoAtLength(buf + 4, startWordIndex - 1, bufSizeInBytes); } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, ((samplesRecorded << 1) | 1)); stackPointer = sp; } } int primitiveSoundSetRecordLevel(void) { int level; int integerPointer; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { level = (integerPointer >> 1); goto l1; } else { primitiveFail(); level = 0; goto l1; } l1: /* end stackIntegerValue: */; if (successFlag) { snd_SetRecordLevel(level); } if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; } } int primitiveSoundStart(void) { int stereoFlag; int samplesPerSec; int bufFrames; int integerPointer; int integerPointer1; /* begin booleanValueOf: */ if ((longAt(stackPointer - (0 * 4))) == trueObj) { stereoFlag = true; goto l1; } if ((longAt(stackPointer - (0 * 4))) == falseObj) { stereoFlag = false; goto l1; } successFlag = false; stereoFlag = null; l1: /* end booleanValueOf: */; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (1 * 4)); if ((integerPointer & 1)) { samplesPerSec = (integerPointer >> 1); goto l2; } else { primitiveFail(); samplesPerSec = 0; goto l2; } l2: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (2 * 4)); if ((integerPointer1 & 1)) { bufFrames = (integerPointer1 >> 1); goto l3; } else { primitiveFail(); bufFrames = 0; goto l3; } l3: /* end stackIntegerValue: */; if (successFlag) { /* begin success: */ successFlag = (snd_Start(bufFrames, samplesPerSec, stereoFlag, 0)) && successFlag; } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; } } int primitiveSoundStartRecording(void) { int stereoFlag; int semaIndex; int desiredSamplesPerSec; int integerPointer; int integerPointer1; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { semaIndex = (integerPointer >> 1); goto l1; } else { primitiveFail(); semaIndex = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin booleanValueOf: */ if ((longAt(stackPointer - (1 * 4))) == trueObj) { stereoFlag = true; goto l2; } if ((longAt(stackPointer - (1 * 4))) == falseObj) { stereoFlag = false; goto l2; } successFlag = false; stereoFlag = null; l2: /* end booleanValueOf: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (2 * 4)); if ((integerPointer1 & 1)) { desiredSamplesPerSec = (integerPointer1 >> 1); goto l3; } else { primitiveFail(); desiredSamplesPerSec = 0; goto l3; } l3: /* end stackIntegerValue: */; if (successFlag) { snd_StartRecording(desiredSamplesPerSec, stereoFlag, semaIndex); } if (successFlag) { /* begin pop: */ stackPointer -= 3 * 4; } } int primitiveSoundStartWithSemaphore(void) { int stereoFlag; int semaIndex; int samplesPerSec; int bufFrames; int integerPointer; int integerPointer1; int integerPointer2; /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (0 * 4)); if ((integerPointer & 1)) { semaIndex = (integerPointer >> 1); goto l1; } else { primitiveFail(); semaIndex = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin booleanValueOf: */ if ((longAt(stackPointer - (1 * 4))) == trueObj) { stereoFlag = true; goto l2; } if ((longAt(stackPointer - (1 * 4))) == falseObj) { stereoFlag = false; goto l2; } successFlag = false; stereoFlag = null; l2: /* end booleanValueOf: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (2 * 4)); if ((integerPointer1 & 1)) { samplesPerSec = (integerPointer1 >> 1); goto l3; } else { primitiveFail(); samplesPerSec = 0; goto l3; } l3: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (3 * 4)); if ((integerPointer2 & 1)) { bufFrames = (integerPointer2 >> 1); goto l4; } else { primitiveFail(); bufFrames = 0; goto l4; } l4: /* end stackIntegerValue: */; if (successFlag) { /* begin success: */ successFlag = (snd_Start(bufFrames, samplesPerSec, stereoFlag, semaIndex)) && successFlag; } if (successFlag) { /* begin pop: */ stackPointer -= 4 * 4; } } int primitiveSoundStop(void) { snd_Stop(); } int primitiveSoundStopRecording(void) { snd_StopRecording(); } int primitiveSpecialObjectsOop(void) { int sp; /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, specialObjectsOop); stackPointer = sp; } int primitiveSquareRoot(void) { double rcvr; rcvr = popFloat(); /* begin success: */ successFlag = (rcvr >= 0.0) && successFlag; if (successFlag) { pushFloat(sqrt(rcvr)); } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveStringAt(void) { int index; int result; int rcvr; int sp; /* begin commonAt: */ index = longAt(stackPointer); rcvr = longAt(stackPointer - (1 * 4)); if (((index & 1)) && (!((rcvr & 1)))) { index = (index >> 1); result = stObjectat(rcvr, index); if (true && (successFlag)) { result = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (24 << 2))))) + 4) + (((result >> 1)) << 2)); } } else { successFlag = false; } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((2 - 1) * 4), result); stackPointer = sp; } else { if (true) { failSpecialPrim(63); } else { failSpecialPrim(60); } } } int primitiveStringAtPut(void) { int value; int valToStore; int index; int rcvr; int sp; /* begin commonAtPut: */ value = valToStore = longAt(stackPointer); index = longAt(stackPointer - (1 * 4)); rcvr = longAt(stackPointer - (2 * 4)); if (((index & 1)) && (!((rcvr & 1)))) { index = (index >> 1); if (true) { valToStore = asciiOfCharacter(value); } stObjectatput(rcvr, index, valToStore); } else { successFlag = false; } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((3 - 1) * 4), value); stackPointer = sp; } else { if (true) { failSpecialPrim(64); } else { failSpecialPrim(61); } } } int primitiveStringReplace(void) { int array; int srcIndex; int start; int stop; int arrayFmt; int arrayInstSize; int i; int hdr; int totalLength; int repl; int replStart; int replFmt; int replInstSize; int integerPointer; int integerPointer1; int integerPointer2; int sz; int classFormat; int class; int sz1; int classFormat1; int class1; int ccIndex; int ccIndex1; array = longAt(stackPointer - (4 * 4)); /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (3 * 4)); if ((integerPointer & 1)) { start = (integerPointer >> 1); goto l1; } else { primitiveFail(); start = 0; goto l1; } l1: /* end stackIntegerValue: */; /* begin stackIntegerValue: */ integerPointer1 = longAt(stackPointer - (2 * 4)); if ((integerPointer1 & 1)) { stop = (integerPointer1 >> 1); goto l2; } else { primitiveFail(); stop = 0; goto l2; } l2: /* end stackIntegerValue: */; repl = longAt(stackPointer - (1 * 4)); /* begin stackIntegerValue: */ integerPointer2 = longAt(stackPointer - (0 * 4)); if ((integerPointer2 & 1)) { replStart = (integerPointer2 >> 1); goto l3; } else { primitiveFail(); replStart = 0; goto l3; } l3: /* end stackIntegerValue: */; if (!(successFlag)) { return primitiveFail(); } if ((repl & 1)) { return primitiveFail(); } hdr = longAt(array); arrayFmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz = (longAt(array - 8)) & 4294967292U; } else { sz = hdr & 252; } if (arrayFmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; goto l4; } else { totalLength = (sz - 4) - (arrayFmt & 3); goto l4; } l4: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((arrayFmt > 3) || (arrayFmt == 2)) { arrayInstSize = 0; goto l5; } if (arrayFmt < 2) { arrayInstSize = totalLength; goto l5; } /* begin fetchClassOf: */ if ((array & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l8; } ccIndex = ((((unsigned) (longAt(array))) >> 12) & 31) - 1; if (ccIndex < 0) { class = (longAt(array - 4)) & 4294967292U; goto l8; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l8; } l8: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; arrayInstSize = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l5: /* end fixedFieldsOf:format:length: */; if (!((start >= 1) && ((start <= stop) && ((stop + arrayInstSize) <= totalLength)))) { return primitiveFail(); } hdr = longAt(repl); replFmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz1 = (longAt(repl - 8)) & 4294967292U; } else { sz1 = hdr & 252; } if (replFmt < 8) { totalLength = ((unsigned) (sz1 - 4)) >> 2; goto l6; } else { totalLength = (sz1 - 4) - (replFmt & 3); goto l6; } l6: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((replFmt > 3) || (replFmt == 2)) { replInstSize = 0; goto l7; } if (replFmt < 2) { replInstSize = totalLength; goto l7; } /* begin fetchClassOf: */ if ((repl & 1)) { class1 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l9; } ccIndex1 = ((((unsigned) (longAt(repl))) >> 12) & 31) - 1; if (ccIndex1 < 0) { class1 = (longAt(repl - 4)) & 4294967292U; goto l9; } else { class1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex1 << 2)); goto l9; } l9: /* end fetchClassOf: */; classFormat1 = (longAt(((((char *) class1)) + 4) + (2 << 2))) - 1; replInstSize = (((((unsigned) classFormat1) >> 11) & 192) + ((((unsigned) classFormat1) >> 2) & 63)) - 1; l7: /* end fixedFieldsOf:format:length: */; if (!((replStart >= 1) && ((((stop - start) + replStart) + replInstSize) <= totalLength))) { return primitiveFail(); } if (arrayFmt < 8) { if (!(arrayFmt == replFmt)) { return primitiveFail(); } } else { if (!((arrayFmt & 12) == (replFmt & 12))) { return primitiveFail(); } } srcIndex = (replStart + replInstSize) - 1; if (arrayFmt < 4) { for (i = ((start + arrayInstSize) - 1); i <= ((stop + arrayInstSize) - 1); i += 1) { /* begin storePointer:ofObject:withValue: */ if (array < youngStart) { possibleRootStoreIntovalue(array, longAt(((((char *) repl)) + 4) + (srcIndex << 2))); } longAtput(((((char *) array)) + 4) + (i << 2), longAt(((((char *) repl)) + 4) + (srcIndex << 2))); srcIndex += 1; } } else { if (arrayFmt < 8) { for (i = ((start + arrayInstSize) - 1); i <= ((stop + arrayInstSize) - 1); i += 1) { longAtput(((((char *) array)) + 4) + (i << 2), longAt(((((char *) repl)) + 4) + (srcIndex << 2))); srcIndex += 1; } } else { for (i = ((start + arrayInstSize) - 1); i <= ((stop + arrayInstSize) - 1); i += 1) { byteAtput(((((char *) array)) + 4) + i, byteAt(((((char *) repl)) + 4) + srcIndex)); srcIndex += 1; } } } /* begin pop: */ stackPointer -= 4 * 4; } int primitiveSubtract(void) { int integerReceiver; int integerArgument; int integerPointer; int top; int integerPointer1; int top1; int sp; successFlag = true; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { integerArgument = (integerPointer >> 1); goto l1; } else { successFlag = false; integerArgument = 1; goto l1; } l1: /* end popInteger */; /* begin popInteger */ /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; integerPointer1 = top1; if ((integerPointer1 & 1)) { integerReceiver = (integerPointer1 >> 1); goto l2; } else { successFlag = false; integerReceiver = 1; goto l2; } l2: /* end popInteger */; /* begin checkIntegerResult:from: */ if (successFlag && (((integerReceiver - integerArgument) ^ ((integerReceiver - integerArgument) << 1)) >= 0)) { /* begin pushInteger: */ /* begin push: */ longAtput(sp = stackPointer + 4, (((integerReceiver - integerArgument) << 1) | 1)); stackPointer = sp; } else { /* begin unPop: */ stackPointer += 2 * 4; failSpecialPrim(2); } } int primitiveSuspend(void) { int activeProc; int sp; int newProc; int sched; int oldProc; int valuePointer; int tmp; activeProc = longAt(((((char *) (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2))))) + 4) + (1 << 2)); /* begin success: */ successFlag = ((longAt(stackPointer)) == activeProc) && successFlag; if (successFlag) { /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, nilObj); stackPointer = sp; /* begin transferTo: */ newProc = wakeHighestPriority(); sched = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); oldProc = longAt(((((char *) sched)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ valuePointer = activeContext; if (oldProc < youngStart) { possibleRootStoreIntovalue(oldProc, valuePointer); } longAtput(((((char *) oldProc)) + 4) + (1 << 2), valuePointer); /* begin storePointer:ofObject:withValue: */ if (sched < youngStart) { possibleRootStoreIntovalue(sched, newProc); } longAtput(((((char *) sched)) + 4) + (1 << 2), newProc); /* begin newActiveContext: */ /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); if ((longAt(((((char *) newProc)) + 4) + (1 << 2))) < youngStart) { beRootIfOld(longAt(((((char *) newProc)) + 4) + (1 << 2))); } activeContext = longAt(((((char *) newProc)) + 4) + (1 << 2)); /* begin fetchContextRegisters: */ tmp = longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = longAt(((((char *) newProc)) + 4) + (1 << 2)); } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (2 << 2))) >> 1); stackPointer = ((longAt(((((char *) newProc)) + 4) + (1 << 2))) + 4) + (((6 + tmp) - 1) * 4); reclaimableContextCount = 0; } } int primitiveTimesTwoPower(void) { int arg; double rcvr; int integerPointer; int top; /* begin popInteger */ /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; integerPointer = top; if ((integerPointer & 1)) { arg = (integerPointer >> 1); goto l1; } else { successFlag = false; arg = 1; goto l1; } l1: /* end popInteger */; rcvr = popFloat(); if (successFlag) { pushFloat(ldexp(rcvr, arg)); } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveTruncated(void) { double trunc; double frac; double rcvr; rcvr = popFloat(); if (successFlag) { frac = modf(rcvr, &trunc); success((-1073741824.0 <= trunc) && (trunc <= 1073741823.0)); } if (successFlag) { pushInteger((int) trunc); } else { /* begin unPop: */ stackPointer += 1 * 4; } } int primitiveVMParameter(void) { int mem; int arg; int paramsArraySize; int i; int index; int result; int sp; int sp1; int sp2; mem = ((int) memory); if (argumentCount == 0) { paramsArraySize = 22; result = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)), paramsArraySize); for (i = 0; i <= (paramsArraySize - 1); i += 1) { longAtput(((((char *) result)) + 4) + (i << 2), ((0 << 1) | 1)); } longAtput(((((char *) result)) + 4) + (0 << 2), (((youngStart - mem) << 1) | 1)); longAtput(((((char *) result)) + 4) + (1 << 2), (((freeBlock - mem) << 1) | 1)); longAtput(((((char *) result)) + 4) + (2 << 2), (((endOfMemory - mem) << 1) | 1)); longAtput(((((char *) result)) + 4) + (3 << 2), ((allocationCount << 1) | 1)); longAtput(((((char *) result)) + 4) + (4 << 2), ((allocationsBetweenGCs << 1) | 1)); longAtput(((((char *) result)) + 4) + (5 << 2), ((tenuringThreshold << 1) | 1)); longAtput(((((char *) result)) + 4) + (6 << 2), ((statFullGCs << 1) | 1)); longAtput(((((char *) result)) + 4) + (7 << 2), ((statFullGCMSecs << 1) | 1)); longAtput(((((char *) result)) + 4) + (8 << 2), ((statIncrGCs << 1) | 1)); longAtput(((((char *) result)) + 4) + (9 << 2), ((statIncrGCMSecs << 1) | 1)); longAtput(((((char *) result)) + 4) + (10 << 2), ((statTenures << 1) | 1)); longAtput(((((char *) result)) + 4) + (20 << 2), ((rootTableCount << 1) | 1)); longAtput(((((char *) result)) + 4) + (21 << 2), ((statRootTableOverflows << 1) | 1)); /* begin pop:thenPush: */ longAtput(sp = stackPointer - ((1 - 1) * 4), result); stackPointer = sp; return null; } arg = longAt(stackPointer); if (!((arg & 1))) { return primitiveFail(); } arg = (arg >> 1); if (argumentCount == 1) { if ((arg < 1) || (arg > 22)) { return primitiveFail(); } if (arg == 1) { result = youngStart - mem; } if (arg == 2) { result = freeBlock - mem; } if (arg == 3) { result = endOfMemory - mem; } if (arg == 4) { result = allocationCount; } if (arg == 5) { result = allocationsBetweenGCs; } if (arg == 6) { result = tenuringThreshold; } if (arg == 7) { result = statFullGCs; } if (arg == 8) { result = statFullGCMSecs; } if (arg == 9) { result = statIncrGCs; } if (arg == 10) { result = statIncrGCMSecs; } if (arg == 11) { result = statTenures; } if ((arg >= 12) && (arg <= 20)) { result = 0; } if (arg == 21) { result = rootTableCount; } if (arg == 22) { result = statRootTableOverflows; } /* begin pop:thenPush: */ longAtput(sp1 = stackPointer - ((2 - 1) * 4), ((result << 1) | 1)); stackPointer = sp1; return null; } if (!(argumentCount == 2)) { return primitiveFail(); } index = longAt(stackPointer - (1 * 4)); if (!((index & 1))) { return primitiveFail(); } index = (index >> 1); if (index <= 0) { return primitiveFail(); } successFlag = false; if (index == 5) { result = allocationsBetweenGCs; allocationsBetweenGCs = arg; successFlag = true; } if (index == 6) { result = tenuringThreshold; tenuringThreshold = arg; successFlag = true; } if (successFlag) { /* begin pop:thenPush: */ longAtput(sp2 = stackPointer - ((3 - 1) * 4), ((result << 1) | 1)); stackPointer = sp2; return null; } primitiveFail(); } int primitiveVMPath(void) { int sz; int s; int sp; sz = vmPathSize(); s = instantiateClassindexableSize(longAt(((((char *) specialObjectsOop)) + 4) + (6 << 2)), sz); vmPathGetLength(s + 4, sz); /* begin pop: */ stackPointer -= 1 * 4; /* begin push: */ longAtput(sp = stackPointer + 4, s); stackPointer = sp; } int primitiveValue(void) { int blockArgumentCount; int initialIP; int blockContext; int toIndex; int fromIndex; int lastFrom; int successValue; int tmp; int argCount; blockContext = longAt(stackPointer - (argumentCount * 4)); /* begin argumentCountOfBlock: */ argCount = longAt(((((char *) blockContext)) + 4) + (3 << 2)); if ((argCount & 1)) { blockArgumentCount = (argCount >> 1); goto l1; } else { primitiveFail(); blockArgumentCount = 0; goto l1; } l1: /* end argumentCountOfBlock: */; /* begin success: */ successValue = (argumentCount == blockArgumentCount) && ((longAt(((((char *) blockContext)) + 4) + (0 << 2))) == nilObj); successFlag = successValue && successFlag; if (successFlag) { /* begin transfer:fromIndex:ofObject:toIndex:ofObject: */ fromIndex = activeContext + ((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - argumentCount) + 1) * 4); toIndex = blockContext + (6 * 4); lastFrom = fromIndex + (argumentCount * 4); while (fromIndex < lastFrom) { fromIndex += 4; toIndex += 4; longAtput(toIndex, longAt(fromIndex)); } /* begin pop: */ stackPointer -= (argumentCount + 1) * 4; initialIP = longAt(((((char *) blockContext)) + 4) + (4 << 2)); longAtput(((((char *) blockContext)) + 4) + (1 << 2), initialIP); /* begin storeStackPointerValue:inContext: */ longAtput(((((char *) blockContext)) + 4) + (2 << 2), ((argumentCount << 1) | 1)); longAtput(((((char *) blockContext)) + 4) + (0 << 2), activeContext); /* begin newActiveContext: */ /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); if (blockContext < youngStart) { beRootIfOld(blockContext); } activeContext = blockContext; /* begin fetchContextRegisters: */ tmp = longAt(((((char *) blockContext)) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) blockContext)) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = blockContext; } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) blockContext)) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) blockContext)) + 4) + (2 << 2))) >> 1); stackPointer = (blockContext + 4) + (((6 + tmp) - 1) * 4); } } int primitiveValueWithArgs(void) { int argumentArray; int arrayArgumentCount; int blockArgumentCount; int initialIP; int blockContext; int sz; int successValue; int toIndex; int fromIndex; int lastFrom; int top; int top1; int header; int tmp; int argCount; int ccIndex; int cl; /* begin popStack */ top = longAt(stackPointer); stackPointer -= 4; argumentArray = top; /* begin popStack */ top1 = longAt(stackPointer); stackPointer -= 4; blockContext = top1; /* begin argumentCountOfBlock: */ argCount = longAt(((((char *) blockContext)) + 4) + (3 << 2)); if ((argCount & 1)) { blockArgumentCount = (argCount >> 1); goto l2; } else { primitiveFail(); blockArgumentCount = 0; goto l2; } l2: /* end argumentCountOfBlock: */; /* begin assertClassOf:is: */ if ((argumentArray & 1)) { successFlag = false; goto l3; } ccIndex = (((unsigned) (longAt(argumentArray))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(argumentArray - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (7 << 2)))) && successFlag; l3: /* end assertClassOf:is: */; if (successFlag) { /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(argumentArray); if ((header & 3) == 0) { sz = (longAt(argumentArray - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; arrayArgumentCount = ((unsigned) (sz - 4)) >> 2; /* begin success: */ successValue = (arrayArgumentCount == blockArgumentCount) && ((longAt(((((char *) blockContext)) + 4) + (0 << 2))) == nilObj); successFlag = successValue && successFlag; } if (successFlag) { /* begin transfer:fromIndex:ofObject:toIndex:ofObject: */ fromIndex = argumentArray + (0 * 4); toIndex = blockContext + (6 * 4); lastFrom = fromIndex + (arrayArgumentCount * 4); while (fromIndex < lastFrom) { fromIndex += 4; toIndex += 4; longAtput(toIndex, longAt(fromIndex)); } initialIP = longAt(((((char *) blockContext)) + 4) + (4 << 2)); longAtput(((((char *) blockContext)) + 4) + (1 << 2), initialIP); /* begin storeStackPointerValue:inContext: */ longAtput(((((char *) blockContext)) + 4) + (2 << 2), ((arrayArgumentCount << 1) | 1)); longAtput(((((char *) blockContext)) + 4) + (0 << 2), activeContext); /* begin newActiveContext: */ /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); if (blockContext < youngStart) { beRootIfOld(blockContext); } activeContext = blockContext; /* begin fetchContextRegisters: */ tmp = longAt(((((char *) blockContext)) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) blockContext)) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = blockContext; } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) blockContext)) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) blockContext)) + 4) + (2 << 2))) >> 1); stackPointer = (blockContext + 4) + (((6 + tmp) - 1) * 4); } else { /* begin unPop: */ stackPointer += 2 * 4; } } int primitiveWait(void) { int sema; int activeProc; int excessSignals; int lastLink; int newProc; int sched; int oldProc; int valuePointer; int tmp; int ccIndex; int cl; sema = longAt(stackPointer); /* begin assertClassOf:is: */ if ((sema & 1)) { successFlag = false; goto l1; } ccIndex = (((unsigned) (longAt(sema))) >> 12) & 31; if (ccIndex == 0) { cl = (longAt(sema - 4)) & 4294967292U; } else { cl = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + ((ccIndex - 1) << 2)); } /* begin success: */ successFlag = (cl == (longAt(((((char *) specialObjectsOop)) + 4) + (18 << 2)))) && successFlag; l1: /* end assertClassOf:is: */; if (successFlag) { excessSignals = fetchIntegerofObject(2, sema); if (excessSignals > 0) { /* begin storeInteger:ofObject:withValue: */ if (((excessSignals - 1) ^ ((excessSignals - 1) << 1)) >= 0) { longAtput(((((char *) sema)) + 4) + (2 << 2), (((excessSignals - 1) << 1) | 1)); } else { primitiveFail(); } } else { activeProc = longAt(((((char *) (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2))))) + 4) + (1 << 2)); /* begin addLastLink:toList: */ if ((longAt(((((char *) sema)) + 4) + (0 << 2))) == nilObj) { /* begin storePointer:ofObject:withValue: */ if (sema < youngStart) { possibleRootStoreIntovalue(sema, activeProc); } longAtput(((((char *) sema)) + 4) + (0 << 2), activeProc); } else { lastLink = longAt(((((char *) sema)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ if (lastLink < youngStart) { possibleRootStoreIntovalue(lastLink, activeProc); } longAtput(((((char *) lastLink)) + 4) + (0 << 2), activeProc); } /* begin storePointer:ofObject:withValue: */ if (sema < youngStart) { possibleRootStoreIntovalue(sema, activeProc); } longAtput(((((char *) sema)) + 4) + (1 << 2), activeProc); /* begin storePointer:ofObject:withValue: */ if (activeProc < youngStart) { possibleRootStoreIntovalue(activeProc, sema); } longAtput(((((char *) activeProc)) + 4) + (3 << 2), sema); /* begin transferTo: */ newProc = wakeHighestPriority(); sched = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); oldProc = longAt(((((char *) sched)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ valuePointer = activeContext; if (oldProc < youngStart) { possibleRootStoreIntovalue(oldProc, valuePointer); } longAtput(((((char *) oldProc)) + 4) + (1 << 2), valuePointer); /* begin storePointer:ofObject:withValue: */ if (sched < youngStart) { possibleRootStoreIntovalue(sched, newProc); } longAtput(((((char *) sched)) + 4) + (1 << 2), newProc); /* begin newActiveContext: */ /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); if ((longAt(((((char *) newProc)) + 4) + (1 << 2))) < youngStart) { beRootIfOld(longAt(((((char *) newProc)) + 4) + (1 << 2))); } activeContext = longAt(((((char *) newProc)) + 4) + (1 << 2)); /* begin fetchContextRegisters: */ tmp = longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = longAt(((((char *) newProc)) + 4) + (1 << 2)); } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (2 << 2))) >> 1); stackPointer = ((longAt(((((char *) newProc)) + 4) + (1 << 2))) + 4) + (((6 + tmp) - 1) * 4); reclaimableContextCount = 0; } } } int primitiveWarpBits(void) { int rcvr; int ns; int successValue; int skewWord; int mergeWord; int startBits; int yDelta; int smoothingCount; int sourceMapOop; int t; int i; int nSteps; int word; int halftoneWord; int deltaP12x; int deltaP12y; int deltaP43x; int deltaP43y; int pAx; int pAy; int pBx; int xDelta; int pBy; int integerPointer; rcvr = longAt(stackPointer - (argumentCount * 4)); /* begin success: */ successValue = loadBitBltFrom(rcvr); successFlag = successValue && successFlag; if (successFlag) { /* begin warpBits */ ns = noSource; noSource = true; clipRange(); noSource = ns; if (noSource || ((bbW <= 0) || (bbH <= 0))) { affectedL = affectedR = affectedT = affectedB = 0; goto l1; } destMaskAndPointerInit(); /* begin warpLoop */ if (!((fetchWordLengthOf(bitBltOop)) >= (15 + 12))) { primitiveFail(); goto l3; } nSteps = height - 1; if (nSteps <= 0) { nSteps = 1; } pAx = fetchIntegerOrTruncFloatofObject(15, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 3, bitBltOop); deltaP12x = deltaFromtonSteps(pAx, t, nSteps); if (deltaP12x < 0) { pAx = t - (nSteps * deltaP12x); } pAy = fetchIntegerOrTruncFloatofObject(15 + 1, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 4, bitBltOop); deltaP12y = deltaFromtonSteps(pAy, t, nSteps); if (deltaP12y < 0) { pAy = t - (nSteps * deltaP12y); } pBx = fetchIntegerOrTruncFloatofObject(15 + 9, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 6, bitBltOop); deltaP43x = deltaFromtonSteps(pBx, t, nSteps); if (deltaP43x < 0) { pBx = t - (nSteps * deltaP43x); } pBy = fetchIntegerOrTruncFloatofObject(15 + 10, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 7, bitBltOop); deltaP43y = deltaFromtonSteps(pBy, t, nSteps); if (deltaP43y < 0) { pBy = t - (nSteps * deltaP43y); } if (!successFlag) { goto l3; } if (argumentCount == 2) { /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (1 * 4)); if ((integerPointer & 1)) { smoothingCount = (integerPointer >> 1); goto l2; } else { primitiveFail(); smoothingCount = 0; goto l2; } l2: /* end stackIntegerValue: */; sourceMapOop = longAt(stackPointer - (0 * 4)); if (sourceMapOop == nilObj) { if (sourcePixSize < 16) { primitiveFail(); goto l3; } } else { if ((fetchWordLengthOf(sourceMapOop)) < (1 << sourcePixSize)) { primitiveFail(); goto l3; } } } else { smoothingCount = 1; sourceMapOop = nilObj; } startBits = pixPerWord - (dx & (pixPerWord - 1)); nSteps = width - 1; if (nSteps <= 0) { nSteps = 1; } for (i = destY; i <= (clipY - 1); i += 1) { pAx += deltaP12x; pAy += deltaP12y; pBx += deltaP43x; pBy += deltaP43y; } for (i = 1; i <= bbH; i += 1) { xDelta = deltaFromtonSteps(pAx, pBx, nSteps); if (xDelta >= 0) { sx = pAx; } else { sx = pBx - (nSteps * xDelta); } yDelta = deltaFromtonSteps(pAy, pBy, nSteps); if (yDelta >= 0) { sy = pAy; } else { sy = pBy - (nSteps * yDelta); } for (word = destX; word <= (clipX - 1); word += 1) { sx += xDelta; sy += yDelta; } if (noHalftone) { halftoneWord = 4294967295U; } else { halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); } destMask = mask1; if (bbW < startBits) { skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(bbW, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); skewWord = ((((startBits - bbW) * destPixSize) < 0) ? ((unsigned) skewWord >> -((startBits - bbW) * destPixSize)) : ((unsigned) skewWord << ((startBits - bbW) * destPixSize))); } else { skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(startBits, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } for (word = 1; word <= nWords; word += 1) { mergeWord = mergewith(skewWord & halftoneWord, (longAt(destIndex)) & destMask); longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); destIndex += 4; if (word >= (nWords - 1)) { if (!(word == nWords)) { destMask = mask2; skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(pixPerWord, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } } else { destMask = 4294967295U; skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(pixPerWord, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } } pAx += deltaP12x; pAy += deltaP12y; pBx += deltaP43x; pBy += deltaP43y; destIndex += destDelta; } l3: /* end warpLoop */; if (hDir > 0) { affectedL = dx; affectedR = dx + bbW; } else { affectedL = (dx - bbW) + 1; affectedR = dx + 1; } if (vDir > 0) { affectedT = dy; affectedB = dy + bbH; } else { affectedT = (dy - bbH) + 1; affectedB = dy + 1; } l1: /* end warpBits */; showDisplayBits(); } } int print(char *s) { printf("%s", s); } int printCallStack(void) { int methodSel; int methodClass; int home; int ctxt; int methodArray; int done; int i; int classDict; int currClass; int classDictSize; int sz; int header; int ccIndex; int methodArray1; int done1; int i1; int classDict1; int currClass1; int classDictSize1; int sz1; int header1; int ccIndex2; int ccIndex1; ctxt = activeContext; while (!(ctxt == nilObj)) { if ((fetchClassOf(ctxt)) == (longAt(((((char *) specialObjectsOop)) + 4) + (11 << 2)))) { home = longAt(((((char *) ctxt)) + 4) + (5 << 2)); } else { home = ctxt; } /* begin findClassOfMethod:forReceiver: */ /* begin fetchClassOf: */ if (((longAt(((((char *) home)) + 4) + (5 << 2))) & 1)) { currClass1 = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l5; } ccIndex2 = ((((unsigned) (longAt(longAt(((((char *) home)) + 4) + (5 << 2))))) >> 12) & 31) - 1; if (ccIndex2 < 0) { currClass1 = (longAt((longAt(((((char *) home)) + 4) + (5 << 2))) - 4)) & 4294967292U; goto l5; } else { currClass1 = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex2 << 2)); goto l5; } l5: /* end fetchClassOf: */; done1 = false; while (!(done1)) { classDict1 = longAt(((((char *) currClass1)) + 4) + (1 << 2)); /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header1 = longAt(classDict1); if ((header1 & 3) == 0) { sz1 = (longAt(classDict1 - 8)) & 4294967292U; goto l4; } else { sz1 = header1 & 252; goto l4; } l4: /* end sizeBitsOf: */; classDictSize1 = ((unsigned) (sz1 - 4)) >> 2; methodArray1 = longAt(((((char *) classDict1)) + 4) + (1 << 2)); i1 = 0; while (i1 < (classDictSize1 - 2)) { if ((longAt(((((char *) home)) + 4) + (3 << 2))) == (longAt(((((char *) methodArray1)) + 4) + (i1 << 2)))) { methodClass = currClass1; goto l6; } i1 += 1; } currClass1 = longAt(((((char *) currClass1)) + 4) + (0 << 2)); done1 = currClass1 == nilObj; } /* begin fetchClassOf: */ if (((longAt(((((char *) home)) + 4) + (5 << 2))) & 1)) { methodClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l6; } ccIndex1 = ((((unsigned) (longAt(longAt(((((char *) home)) + 4) + (5 << 2))))) >> 12) & 31) - 1; if (ccIndex1 < 0) { methodClass = (longAt((longAt(((((char *) home)) + 4) + (5 << 2))) - 4)) & 4294967292U; goto l6; } else { methodClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex1 << 2)); goto l6; } methodClass = null; l6: /* end findClassOfMethod:forReceiver: */; /* begin findSelectorOfMethod:forReceiver: */ /* begin fetchClassOf: */ if (((longAt(((((char *) home)) + 4) + (5 << 2))) & 1)) { currClass = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l2; } ccIndex = ((((unsigned) (longAt(longAt(((((char *) home)) + 4) + (5 << 2))))) >> 12) & 31) - 1; if (ccIndex < 0) { currClass = (longAt((longAt(((((char *) home)) + 4) + (5 << 2))) - 4)) & 4294967292U; goto l2; } else { currClass = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l2; } l2: /* end fetchClassOf: */; done = false; while (!(done)) { classDict = longAt(((((char *) currClass)) + 4) + (1 << 2)); /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(classDict); if ((header & 3) == 0) { sz = (longAt(classDict - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; classDictSize = ((unsigned) (sz - 4)) >> 2; methodArray = longAt(((((char *) classDict)) + 4) + (1 << 2)); i = 0; while (i <= (classDictSize - 2)) { if ((longAt(((((char *) home)) + 4) + (3 << 2))) == (longAt(((((char *) methodArray)) + 4) + (i << 2)))) { methodSel = longAt(((((char *) classDict)) + 4) + ((i + 2) << 2)); goto l3; } i += 1; } currClass = longAt(((((char *) currClass)) + 4) + (0 << 2)); done = currClass == nilObj; } methodSel = longAt(((((char *) specialObjectsOop)) + 4) + (20 << 2)); l3: /* end findSelectorOfMethod:forReceiver: */; printNum(ctxt); print(" "); if (!(ctxt == home)) { print("[] in "); } printNameOfClasscount(methodClass, 5); print(">"); printStringOf(methodSel); /* begin cr */ printf("\n"); ctxt = longAt(((((char *) ctxt)) + 4) + (0 << 2)); } } int printChar(int aByte) { putchar(aByte); } int printNameOfClasscount(int classOop, int cnt) { if (cnt <= 0) { return print("bad class"); } if ((sizeBitsOf(classOop)) == 32) { printNameOfClasscount(longAt(((((char *) classOop)) + 4) + (6 << 2)), cnt - 1); print(" class"); } else { printStringOf(longAt(((((char *) classOop)) + 4) + (6 << 2))); } } int printNum(int n) { printf("%ld", (long) n); } int printStringOf(int oop) { int i; int fmt; int cnt; fmt = (((unsigned) (longAt(oop))) >> 8) & 15; if (fmt < 8) { return null; } cnt = ((100 < (lengthOf(oop))) ? 100 : (lengthOf(oop))); i = 0; while (i < cnt) { /* begin printChar: */ putchar(byteAt(((((char *) oop)) + 4) + i)); i += 1; } } int push(int object) { int sp; longAtput(sp = stackPointer + 4, object); stackPointer = sp; } int pushBool(int trueOrFalse) { int sp; int sp1; if (trueOrFalse) { /* begin push: */ longAtput(sp = stackPointer + 4, trueObj); stackPointer = sp; } else { /* begin push: */ longAtput(sp1 = stackPointer + 4, falseObj); stackPointer = sp1; } } int pushFloat(double f) { int newFloatObj; int sp; newFloatObj = instantiateSmallClasssizeInBytesfill(longAt(((((char *) specialObjectsOop)) + 4) + (9 << 2)), 12, 0); storeFloatAtfrom(newFloatObj + 4, f); /* begin push: */ longAtput(sp = stackPointer + 4, newFloatObj); stackPointer = sp; } int pushInteger(int integerValue) { int sp; /* begin push: */ longAtput(sp = stackPointer + 4, ((integerValue << 1) | 1)); stackPointer = sp; } int pushRemappableOop(int oop) { remapBuffer[remapBufferCount += 1] = oop; } int putLongtoFile(int n, sqImageFile f) { int wordsWritten; wordsWritten = sqImageFileWrite(&n, sizeof(int), 1, f); /* begin success: */ successFlag = (wordsWritten == 1) && successFlag; } int putToSleep(int aProcess) { int priority; int processLists; int processList; int lastLink; priority = ((longAt(((((char *) aProcess)) + 4) + (2 << 2))) >> 1); processLists = longAt(((((char *) (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2))))) + 4) + (0 << 2)); processList = longAt(((((char *) processLists)) + 4) + ((priority - 1) << 2)); /* begin addLastLink:toList: */ if ((longAt(((((char *) processList)) + 4) + (0 << 2))) == nilObj) { /* begin storePointer:ofObject:withValue: */ if (processList < youngStart) { possibleRootStoreIntovalue(processList, aProcess); } longAtput(((((char *) processList)) + 4) + (0 << 2), aProcess); } else { lastLink = longAt(((((char *) processList)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ if (lastLink < youngStart) { possibleRootStoreIntovalue(lastLink, aProcess); } longAtput(((((char *) lastLink)) + 4) + (0 << 2), aProcess); } /* begin storePointer:ofObject:withValue: */ if (processList < youngStart) { possibleRootStoreIntovalue(processList, aProcess); } longAtput(((((char *) processList)) + 4) + (1 << 2), aProcess); /* begin storePointer:ofObject:withValue: */ if (aProcess < youngStart) { possibleRootStoreIntovalue(aProcess, processList); } longAtput(((((char *) aProcess)) + 4) + (3 << 2), processList); } int quickCheckForInterrupts(void) { if ((interruptCheckCounter -= 1) <= 0) { checkForInterrupts(); } } int quickFetchIntegerofObject(int fieldIndex, int objectPointer) { return ((longAt(((((char *) objectPointer)) + 4) + (fieldIndex << 2))) >> 1); } int readImageFromFileHeapSize(sqImageFile f, int desiredHeapSize) { int swapBytes; int dataSize; int minimumMemory; int memStart; int bytesRead; int bytesToShift; int headerStart; int headerSize; int oldBaseAddr; int startAddr; int addr; int i; int sched; int proc; int activeCntx; int tmp; int methodHeader; int wordAddr; int oop; int fmt; int stopAddr; int addr1; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; swapBytes = checkImageVersionFrom(f); headerStart = (sqImageFilePosition(f)) - 4; headerSize = getLongFromFileswap(f, swapBytes); dataSize = getLongFromFileswap(f, swapBytes); oldBaseAddr = getLongFromFileswap(f, swapBytes); specialObjectsOop = getLongFromFileswap(f, swapBytes); lastHash = getLongFromFileswap(f, swapBytes); savedWindowSize = getLongFromFileswap(f, swapBytes); fullScreenFlag = getLongFromFileswap(f, swapBytes); if (lastHash == 0) { lastHash = 999; } minimumMemory = dataSize + 80000; if (desiredHeapSize < minimumMemory) { error("Insufficient memory for this image"); } memory = (unsigned char *) sqAllocateMemory(minimumMemory, desiredHeapSize); if (memory == null) { error("Failed to allocate memory for the heap"); } memStart = startOfMemory(); memoryLimit = (memStart + desiredHeapSize) - 24; endOfMemory = memStart + dataSize; sqImageFileSeek(f, headerStart + headerSize); bytesRead = sqImageFileRead(memory, sizeof(unsigned char), dataSize, f); if (bytesRead != dataSize) { error("Read failed or premature end of image file"); } if (swapBytes) { /* begin reverseBytesInImage */ /* begin reverseBytesFrom:to: */ startAddr = startOfMemory(); addr = startAddr; while (addr < endOfMemory) { longAtput(addr, ((((((unsigned) (longAt(addr)) >> 24)) & 255) + ((((unsigned) (longAt(addr)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr)) << 24)) & 4278190080U)); addr += 4; } /* begin byteSwapByteObjects */ /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; oop = chunk + extra; while (oop < endOfMemory) { if (!(((longAt(oop)) & 3) == 2)) { fmt = (((unsigned) (longAt(oop))) >> 8) & 15; if (fmt >= 8) { wordAddr = oop + 4; if (fmt >= 12) { methodHeader = longAt(oop + 4); wordAddr = (wordAddr + 4) + (((((unsigned) methodHeader) >> 10) & 255) * 4); } /* begin reverseBytesFrom:to: */ stopAddr = oop + (sizeBitsOf(oop)); addr1 = wordAddr; while (addr1 < stopAddr) { longAtput(addr1, ((((((unsigned) (longAt(addr1)) >> 24)) & 255) + ((((unsigned) (longAt(addr1)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr1)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr1)) << 24)) & 4278190080U)); addr1 += 4; } } } /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(oop + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = (oop + sz) + extra2; } } bytesToShift = memStart - oldBaseAddr; /* begin initializeInterpreter: */ initializeObjectMemory(bytesToShift); initBBOpTable(); activeContext = nilObj; theHomeContext = nilObj; method = nilObj; receiver = nilObj; messageSelector = nilObj; newMethod = nilObj; /* begin flushMethodCache */ for (i = 1; i <= 2048; i += 1) { methodCache[i] = 0; } mcProbe = 0; /* begin loadInitialContext */ sched = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); proc = longAt(((((char *) sched)) + 4) + (1 << 2)); activeContext = longAt(((((char *) proc)) + 4) + (1 << 2)); if (activeContext < youngStart) { beRootIfOld(activeContext); } /* begin fetchContextRegisters: */ activeCntx = activeContext; tmp = longAt(((((char *) activeCntx)) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) activeCntx)) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = activeCntx; } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) activeCntx)) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) activeCntx)) + 4) + (2 << 2))) >> 1); stackPointer = (activeCntx + 4) + (((6 + tmp) - 1) * 4); reclaimableContextCount = 0; interruptCheckCounter = 0; nextPollTick = 0; nextWakeupTick = 0; lastTick = 0; interruptKeycode = 2094; interruptPending = false; semaphoresToSignalCount = 0; deferDisplayUpdates = false; return dataSize; } int recycleContextIfPossiblemethodContextClass(int cntxOop, int methodCntxClass) { int cntxHeader; int ccField; int isMethodCntx; if (cntxOop >= youngStart) { cntxHeader = longAt(cntxOop); ccField = cntxHeader & 126976; if (ccField == 0) { isMethodCntx = ((longAt(cntxOop - 4)) & 4294967292U) == methodCntxClass; } else { isMethodCntx = ccField == (((longAt(((((char *) methodCntxClass)) + 4) + (2 << 2))) - 1) & 126976); } if (isMethodCntx) { if ((cntxHeader & 252) == 76) { longAtput(((((char *) cntxOop)) + 4) + (0 << 2), freeSmallContexts); freeSmallContexts = cntxOop; } else { longAtput(((((char *) cntxOop)) + 4) + (0 << 2), freeLargeContexts); freeLargeContexts = cntxOop; } } } } int remap(int oop) { int fwdBlock; if (((oop & 1) == 0) && (((longAt(oop)) & 2147483648U) != 0)) { fwdBlock = (longAt(oop)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } return longAt(fwdBlock); } return oop; } int remapClassOf(int oop) { int newClassOop; int fwdBlock; int classHeader; int classOop; int newClassHeader; if (((longAt(oop)) & 3) == 3) { return null; } classHeader = longAt(oop - 4); classOop = classHeader & 4294967292U; if (((classOop & 1) == 0) && (((longAt(classOop)) & 2147483648U) != 0)) { fwdBlock = (longAt(classOop)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } newClassOop = longAt(fwdBlock); newClassHeader = newClassOop | (classHeader & 3); longAtput(oop - 4, newClassHeader); if ((oop < youngStart) && (newClassOop >= youngStart)) { beRootWhileForwarding(oop); } } } int remapFieldsAndClassOf(int oop) { int fwdBlock; int fieldOffset; int fieldOop; int newOop; int methodHeader; int size; int fwdBlock1; int fmt; int header; int newClassOop; int fwdBlock2; int classHeader; int classOop; int newClassHeader; /* begin lastPointerWhileForwarding: */ header = longAt(oop); if ((header & 2147483648U) != 0) { fwdBlock1 = header & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock1 > endOfMemory) && ((fwdBlock1 <= fwdTableNext) && ((fwdBlock1 & 3) == 0)))) { error("invalid fwd table entry"); } } header = longAt(fwdBlock1 + 4); } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 4) { if ((header & 3) == 0) { size = (longAt(oop - 8)) & 268435452; } else { size = header & 252; } fieldOffset = size - 4; goto l1; } if (fmt < 12) { fieldOffset = 0; goto l1; } methodHeader = longAt(oop + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerWhileForwarding: */; while (fieldOffset >= 4) { fieldOop = longAt(oop + fieldOffset); if (((fieldOop & 1) == 0) && (((longAt(fieldOop)) & 2147483648U) != 0)) { fwdBlock = (longAt(fieldOop)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } newOop = longAt(fwdBlock); longAtput(oop + fieldOffset, newOop); if ((oop < youngStart) && (newOop >= youngStart)) { beRootWhileForwarding(oop); } } fieldOffset -= 4; } /* begin remapClassOf: */ if (((longAt(oop)) & 3) == 3) { goto l2; } classHeader = longAt(oop - 4); classOop = classHeader & 4294967292U; if (((classOop & 1) == 0) && (((longAt(classOop)) & 2147483648U) != 0)) { fwdBlock2 = (longAt(classOop)) & 2147483644; if (checkAssertions) { /* begin fwdBlockValidate: */ if (!((fwdBlock2 > endOfMemory) && ((fwdBlock2 <= fwdTableNext) && ((fwdBlock2 & 3) == 0)))) { error("invalid fwd table entry"); } } newClassOop = longAt(fwdBlock2); newClassHeader = newClassOop | (classHeader & 3); longAtput(oop - 4, newClassHeader); if ((oop < youngStart) && (newClassOop >= youngStart)) { beRootWhileForwarding(oop); } } l2: /* end remapClassOf: */; } int removeFirstLinkOfList(int aList) { int next; int first; int last; int valuePointer; int valuePointer1; int valuePointer2; first = longAt(((((char *) aList)) + 4) + (0 << 2)); last = longAt(((((char *) aList)) + 4) + (1 << 2)); if (first == last) { /* begin storePointer:ofObject:withValue: */ valuePointer = nilObj; if (aList < youngStart) { possibleRootStoreIntovalue(aList, valuePointer); } longAtput(((((char *) aList)) + 4) + (0 << 2), valuePointer); /* begin storePointer:ofObject:withValue: */ valuePointer1 = nilObj; if (aList < youngStart) { possibleRootStoreIntovalue(aList, valuePointer1); } longAtput(((((char *) aList)) + 4) + (1 << 2), valuePointer1); } else { next = longAt(((((char *) first)) + 4) + (0 << 2)); /* begin storePointer:ofObject:withValue: */ if (aList < youngStart) { possibleRootStoreIntovalue(aList, next); } longAtput(((((char *) aList)) + 4) + (0 << 2), next); } /* begin storePointer:ofObject:withValue: */ valuePointer2 = nilObj; if (first < youngStart) { possibleRootStoreIntovalue(first, valuePointer2); } longAtput(((((char *) first)) + 4) + (0 << 2), valuePointer2); return first; } int reportContexts(void) { int small; int big; int cntxt; big = 0; cntxt = freeLargeContexts; while (!(cntxt == 1)) { big += 1; cntxt = longAt(((((char *) cntxt)) + 4) + (0 << 2)); } small = 0; cntxt = freeSmallContexts; while (!(cntxt == 1)) { small += 1; cntxt = longAt(((((char *) cntxt)) + 4) + (0 << 2)); } print("Recycled contexts: "); printNum(small); print(" small, "); printNum(big); print(" large ("); printNum((big * 156) + (small * 76)); print(" bytes)"); /* begin cr */ printf("\n"); } int restoreHeaderOf(int oop) { int fwdBlock; int fwdHeader; fwdHeader = longAt(oop); fwdBlock = fwdHeader & 2147483644; if (checkAssertions) { if ((fwdHeader & 2147483648U) == 0) { error("attempting to restore the header of an object that has no forwarding block"); } /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } longAtput(oop, longAt(fwdBlock + 4)); } int restoreHeadersAfterBecomingwith(int list1, int list2) { int fieldOffset; int oop1; int oop2; int hdr1; int hdr2; int fwdBlock; int fwdHeader; int fwdBlock1; int fwdHeader1; int methodHeader; int sz; int fmt; int header; int type; /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(list1))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header = longAt(list1); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l2; } else { if ((header & 126976) == 0) { type = 1; goto l2; } else { type = 3; goto l2; } } l2: /* end rightType: */; if (type == 0) { sz = (longAt(list1 - 8)) & 4294967292U; goto l3; } else { sz = header & 252; goto l3; } l3: /* end sizeBitsOfSafe: */; fieldOffset = sz - 4; goto l1; } if (fmt < 12) { fieldOffset = 0; goto l1; } methodHeader = longAt(list1 + 4); fieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerOf: */; while (fieldOffset >= 4) { oop1 = longAt(list1 + fieldOffset); oop2 = longAt(list2 + fieldOffset); /* begin restoreHeaderOf: */ fwdHeader = longAt(oop1); fwdBlock = fwdHeader & 2147483644; if (checkAssertions) { if ((fwdHeader & 2147483648U) == 0) { error("attempting to restore the header of an object that has no forwarding block"); } /* begin fwdBlockValidate: */ if (!((fwdBlock > endOfMemory) && ((fwdBlock <= fwdTableNext) && ((fwdBlock & 3) == 0)))) { error("invalid fwd table entry"); } } longAtput(oop1, longAt(fwdBlock + 4)); /* begin restoreHeaderOf: */ fwdHeader1 = longAt(oop2); fwdBlock1 = fwdHeader1 & 2147483644; if (checkAssertions) { if ((fwdHeader1 & 2147483648U) == 0) { error("attempting to restore the header of an object that has no forwarding block"); } /* begin fwdBlockValidate: */ if (!((fwdBlock1 > endOfMemory) && ((fwdBlock1 <= fwdTableNext) && ((fwdBlock1 & 3) == 0)))) { error("invalid fwd table entry"); } } longAtput(oop2, longAt(fwdBlock1 + 4)); /* begin exchangeHashBits:with: */ hdr1 = longAt(oop1); hdr2 = longAt(oop2); longAtput(oop1, (hdr1 & 3758227455U) | (hdr2 & 536739840)); longAtput(oop2, (hdr2 & 3758227455U) | (hdr1 & 536739840)); fieldOffset -= 4; } } int resume(int aProcess) { int activeProc; int activePriority; int newPriority; int sched; int oldProc; int valuePointer; int tmp; int priority; int processLists; int processList; int lastLink; int priority1; int processLists1; int processList1; int lastLink1; activeProc = longAt(((((char *) (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2))))) + 4) + (1 << 2)); activePriority = ((longAt(((((char *) activeProc)) + 4) + (2 << 2))) >> 1); newPriority = ((longAt(((((char *) aProcess)) + 4) + (2 << 2))) >> 1); if (newPriority > activePriority) { /* begin putToSleep: */ priority = ((longAt(((((char *) activeProc)) + 4) + (2 << 2))) >> 1); processLists = longAt(((((char *) (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2))))) + 4) + (0 << 2)); processList = longAt(((((char *) processLists)) + 4) + ((priority - 1) << 2)); /* begin addLastLink:toList: */ if ((longAt(((((char *) processList)) + 4) + (0 << 2))) == nilObj) { /* begin storePointer:ofObject:withValue: */ if (processList < youngStart) { possibleRootStoreIntovalue(processList, activeProc); } longAtput(((((char *) processList)) + 4) + (0 << 2), activeProc); } else { lastLink = longAt(((((char *) processList)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ if (lastLink < youngStart) { possibleRootStoreIntovalue(lastLink, activeProc); } longAtput(((((char *) lastLink)) + 4) + (0 << 2), activeProc); } /* begin storePointer:ofObject:withValue: */ if (processList < youngStart) { possibleRootStoreIntovalue(processList, activeProc); } longAtput(((((char *) processList)) + 4) + (1 << 2), activeProc); /* begin storePointer:ofObject:withValue: */ if (activeProc < youngStart) { possibleRootStoreIntovalue(activeProc, processList); } longAtput(((((char *) activeProc)) + 4) + (3 << 2), processList); /* begin transferTo: */ sched = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); oldProc = longAt(((((char *) sched)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ valuePointer = activeContext; if (oldProc < youngStart) { possibleRootStoreIntovalue(oldProc, valuePointer); } longAtput(((((char *) oldProc)) + 4) + (1 << 2), valuePointer); /* begin storePointer:ofObject:withValue: */ if (sched < youngStart) { possibleRootStoreIntovalue(sched, aProcess); } longAtput(((((char *) sched)) + 4) + (1 << 2), aProcess); /* begin newActiveContext: */ /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); if ((longAt(((((char *) aProcess)) + 4) + (1 << 2))) < youngStart) { beRootIfOld(longAt(((((char *) aProcess)) + 4) + (1 << 2))); } activeContext = longAt(((((char *) aProcess)) + 4) + (1 << 2)); /* begin fetchContextRegisters: */ tmp = longAt(((((char *) (longAt(((((char *) aProcess)) + 4) + (1 << 2))))) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) (longAt(((((char *) aProcess)) + 4) + (1 << 2))))) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = longAt(((((char *) aProcess)) + 4) + (1 << 2)); } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) (longAt(((((char *) aProcess)) + 4) + (1 << 2))))) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) (longAt(((((char *) aProcess)) + 4) + (1 << 2))))) + 4) + (2 << 2))) >> 1); stackPointer = ((longAt(((((char *) aProcess)) + 4) + (1 << 2))) + 4) + (((6 + tmp) - 1) * 4); reclaimableContextCount = 0; } else { /* begin putToSleep: */ priority1 = ((longAt(((((char *) aProcess)) + 4) + (2 << 2))) >> 1); processLists1 = longAt(((((char *) (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2))))) + 4) + (0 << 2)); processList1 = longAt(((((char *) processLists1)) + 4) + ((priority1 - 1) << 2)); /* begin addLastLink:toList: */ if ((longAt(((((char *) processList1)) + 4) + (0 << 2))) == nilObj) { /* begin storePointer:ofObject:withValue: */ if (processList1 < youngStart) { possibleRootStoreIntovalue(processList1, aProcess); } longAtput(((((char *) processList1)) + 4) + (0 << 2), aProcess); } else { lastLink1 = longAt(((((char *) processList1)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ if (lastLink1 < youngStart) { possibleRootStoreIntovalue(lastLink1, aProcess); } longAtput(((((char *) lastLink1)) + 4) + (0 << 2), aProcess); } /* begin storePointer:ofObject:withValue: */ if (processList1 < youngStart) { possibleRootStoreIntovalue(processList1, aProcess); } longAtput(((((char *) processList1)) + 4) + (1 << 2), aProcess); /* begin storePointer:ofObject:withValue: */ if (aProcess < youngStart) { possibleRootStoreIntovalue(aProcess, processList1); } longAtput(((((char *) aProcess)) + 4) + (3 << 2), processList1); } } int returnAtlastIndexlefttop(int stopIndex, int lastIndex, int left, int top) { int objectPointer; stopCode = stObjectat(scanStopArray, stopIndex); if (!successFlag) { return null; } /* begin storeInteger:ofObject:withValue: */ objectPointer = bitBltOop; if ((lastIndex ^ (lastIndex << 1)) >= 0) { longAtput(((((char *) objectPointer)) + 4) + (15 << 2), ((lastIndex << 1) | 1)); } else { primitiveFail(); } if (scanDisplayFlag) { affectedL = left; affectedR = bbW + dx; affectedT = top; affectedB = bbH + dy; } } int reverseBytesFromto(int startAddr, int stopAddr) { int addr; addr = startAddr; while (addr < stopAddr) { longAtput(addr, ((((((unsigned) (longAt(addr)) >> 24)) & 255) + ((((unsigned) (longAt(addr)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr)) << 24)) & 4278190080U)); addr += 4; } } int reverseBytesInImage(void) { int startAddr; int addr; int methodHeader; int wordAddr; int oop; int fmt; int stopAddr; int addr1; int chunk; int extra; int type; int extra1; int sz; int header; int extra2; int type1; int extra11; /* begin reverseBytesFrom:to: */ startAddr = startOfMemory(); addr = startAddr; while (addr < endOfMemory) { longAtput(addr, ((((((unsigned) (longAt(addr)) >> 24)) & 255) + ((((unsigned) (longAt(addr)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr)) << 24)) & 4278190080U)); addr += 4; } /* begin byteSwapByteObjects */ /* begin oopFromChunk: */ chunk = startOfMemory(); /* begin extraHeaderBytes: */ type = (longAt(chunk)) & 3; if (type > 1) { extra1 = 0; } else { if (type == 1) { extra1 = 4; } else { extra1 = 8; } } extra = extra1; oop = chunk + extra; while (oop < endOfMemory) { if (!(((longAt(oop)) & 3) == 2)) { fmt = (((unsigned) (longAt(oop))) >> 8) & 15; if (fmt >= 8) { wordAddr = oop + 4; if (fmt >= 12) { methodHeader = longAt(oop + 4); wordAddr = (wordAddr + 4) + (((((unsigned) methodHeader) >> 10) & 255) * 4); } /* begin reverseBytesFrom:to: */ stopAddr = oop + (sizeBitsOf(oop)); addr1 = wordAddr; while (addr1 < stopAddr) { longAtput(addr1, ((((((unsigned) (longAt(addr1)) >> 24)) & 255) + ((((unsigned) (longAt(addr1)) >> 8)) & 65280)) + ((((unsigned) (longAt(addr1)) << 8)) & 16711680)) + ((((unsigned) (longAt(addr1)) << 24)) & 4278190080U)); addr1 += 4; } } } /* begin objectAfter: */ if (checkAssertions) { if (oop >= endOfMemory) { error("no objects after the end of memory"); } } if (((longAt(oop)) & 3) == 2) { sz = (longAt(oop)) & 536870908; } else { /* begin sizeBitsOf: */ header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type1 = (longAt(oop + sz)) & 3; if (type1 > 1) { extra11 = 0; } else { if (type1 == 1) { extra11 = 4; } else { extra11 = 8; } } extra2 = extra11; oop = (oop + sz) + extra2; } } int rgbAddwith(int sourceWord, int destinationWord) { if (destPixSize < 16) { return partitionedAddtonBitsnPartitions(sourceWord, destinationWord, destPixSize, pixPerWord); } if (destPixSize == 16) { return (partitionedAddtonBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedAddtonBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); } else { return partitionedAddtonBitsnPartitions(sourceWord, destinationWord, 8, 3); } } int rgbDiffwith(int sourceWord, int destinationWord) { int destPixVal; int pixMask; int destShifted; int sourceShifted; int sourcePixVal; int diff; int maskShifted; int i; int bitsPerColor; int rgbMask; pixMask = (1 << destPixSize) - 1; if (destPixSize == 16) { bitsPerColor = 5; rgbMask = 31; } else { bitsPerColor = 8; rgbMask = 255; } maskShifted = destMask; destShifted = destinationWord; sourceShifted = sourceWord; for (i = 1; i <= pixPerWord; i += 1) { if ((maskShifted & pixMask) > 0) { destPixVal = destShifted & pixMask; sourcePixVal = sourceShifted & pixMask; if (destPixSize < 16) { if (sourcePixVal == destPixVal) { diff = 0; } else { diff = 1; } } else { diff = partitionedSubfromnBitsnPartitions(sourcePixVal, destPixVal, bitsPerColor, 3); diff = ((diff & rgbMask) + ((((unsigned) diff) >> bitsPerColor) & rgbMask)) + ((((unsigned) (((unsigned) diff) >> bitsPerColor)) >> bitsPerColor) & rgbMask); } bitCount += diff; } maskShifted = ((unsigned) maskShifted) >> destPixSize; sourceShifted = ((unsigned) sourceShifted) >> destPixSize; destShifted = ((unsigned) destShifted) >> destPixSize; } return destinationWord; } int rgbMapfromto(int sourcePixel, int nBitsIn, int nBitsOut) { int mask; int srcPix; int destPix; int d; if ((d = nBitsOut - nBitsIn) > 0) { mask = (1 << nBitsIn) - 1; srcPix = sourcePixel << d; mask = mask << d; destPix = srcPix & mask; mask = mask << nBitsOut; srcPix = srcPix << d; return (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << nBitsOut)); } else { if (d == 0) { return sourcePixel; } if (sourcePixel == 0) { return sourcePixel; } d = nBitsIn - nBitsOut; mask = (1 << nBitsOut) - 1; srcPix = ((unsigned) sourcePixel) >> d; destPix = srcPix & mask; mask = mask << nBitsOut; srcPix = ((unsigned) srcPix) >> d; destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << nBitsOut)); if (destPix == 0) { return 1; } return destPix; } } int rgbMaxwith(int sourceWord, int destinationWord) { int mask; int i; int result; int mask3; int i1; int result1; if (destPixSize < 16) { /* begin partitionedMax:with:nBits:nPartitions: */ mask = (1 << destPixSize) - 1; result = 0; for (i = 1; i <= pixPerWord; i += 1) { result = result | ((((destinationWord & mask) < (sourceWord & mask)) ? (sourceWord & mask) : (destinationWord & mask))); mask = mask << destPixSize; } return result; } if (destPixSize == 16) { return (partitionedMaxwithnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedMaxwithnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); } else { /* begin partitionedMax:with:nBits:nPartitions: */ mask3 = (1 << 8) - 1; result1 = 0; for (i1 = 1; i1 <= 3; i1 += 1) { result1 = result1 | ((((destinationWord & mask3) < (sourceWord & mask3)) ? (sourceWord & mask3) : (destinationWord & mask3))); mask3 = mask3 << 8; } return result1; } } int rgbMinwith(int sourceWord, int destinationWord) { int mask; int i; int result; int mask3; int i1; int result1; if (destPixSize < 16) { /* begin partitionedMin:with:nBits:nPartitions: */ mask = (1 << destPixSize) - 1; result = 0; for (i = 1; i <= pixPerWord; i += 1) { result = result | ((((destinationWord & mask) < (sourceWord & mask)) ? (destinationWord & mask) : (sourceWord & mask))); mask = mask << destPixSize; } return result; } if (destPixSize == 16) { return (partitionedMinwithnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedMinwithnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); } else { /* begin partitionedMin:with:nBits:nPartitions: */ mask3 = (1 << 8) - 1; result1 = 0; for (i1 = 1; i1 <= 3; i1 += 1) { result1 = result1 | ((((destinationWord & mask3) < (sourceWord & mask3)) ? (destinationWord & mask3) : (sourceWord & mask3))); mask3 = mask3 << 8; } return result1; } } int rgbMinInvertwith(int wordToInvert, int destinationWord) { int sourceWord; int mask; int i; int result; int mask3; int i1; int result1; sourceWord = ~wordToInvert; if (destPixSize < 16) { /* begin partitionedMin:with:nBits:nPartitions: */ mask = (1 << destPixSize) - 1; result = 0; for (i = 1; i <= pixPerWord; i += 1) { result = result | ((((destinationWord & mask) < (sourceWord & mask)) ? (destinationWord & mask) : (sourceWord & mask))); mask = mask << destPixSize; } return result; } if (destPixSize == 16) { return (partitionedMinwithnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedMinwithnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); } else { /* begin partitionedMin:with:nBits:nPartitions: */ mask3 = (1 << 8) - 1; result1 = 0; for (i1 = 1; i1 <= 3; i1 += 1) { result1 = result1 | ((((destinationWord & mask3) < (sourceWord & mask3)) ? (destinationWord & mask3) : (sourceWord & mask3))); mask3 = mask3 << 8; } return result1; } } int rgbSubwith(int sourceWord, int destinationWord) { if (destPixSize < 16) { return partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, destPixSize, pixPerWord); } if (destPixSize == 16) { return (partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 5, 3)) + ((partitionedSubfromnBitsnPartitions(((unsigned) sourceWord) >> 16, ((unsigned) destinationWord) >> 16, 5, 3)) << 16); } else { return partitionedSubfromnBitsnPartitions(sourceWord, destinationWord, 8, 3); } } int rightType(int headerWord) { if ((headerWord & 252) == 0) { return 0; } else { if ((headerWord & 126976) == 0) { return 1; } else { return 3; } } } int scanCharacters(void) { int sourceX2; int ascii; int top; int nextDestX; int charVal; int left; int lastIndex; int objectPointer; int integerValue; int lastIndex1; int objectPointer1; int objectPointer2; int objectPointer3; if (scanDisplayFlag) { clipRange(); left = dx; top = dy; } lastIndex = scanStart; while (lastIndex <= scanStop) { charVal = stObjectat(scanString, lastIndex); ascii = (charVal >> 1); if (!successFlag) { return null; } stopCode = stObjectat(scanStopArray, ascii + 1); if (!successFlag) { return null; } if (!(stopCode == nilObj)) { /* begin returnAt:lastIndex:left:top: */ stopCode = stObjectat(scanStopArray, ascii + 1); if (!successFlag) { return null; } /* begin storeInteger:ofObject:withValue: */ objectPointer1 = bitBltOop; if ((lastIndex ^ (lastIndex << 1)) >= 0) { longAtput(((((char *) objectPointer1)) + 4) + (15 << 2), ((lastIndex << 1) | 1)); } else { primitiveFail(); } if (scanDisplayFlag) { affectedL = left; affectedR = bbW + dx; affectedT = top; affectedB = bbH + dy; } return null; } sourceX = stObjectat(scanXTable, ascii + 1); sourceX2 = stObjectat(scanXTable, ascii + 2); if (!successFlag) { return null; } if (((sourceX & 1)) && ((sourceX2 & 1))) { sourceX = (sourceX >> 1); sourceX2 = (sourceX2 >> 1); } else { primitiveFail(); return null; } nextDestX = destX + (width = sourceX2 - sourceX); if (nextDestX > scanRightX) { /* begin returnAt:lastIndex:left:top: */ stopCode = stObjectat(scanStopArray, 258); if (!successFlag) { return null; } /* begin storeInteger:ofObject:withValue: */ objectPointer2 = bitBltOop; if ((lastIndex ^ (lastIndex << 1)) >= 0) { longAtput(((((char *) objectPointer2)) + 4) + (15 << 2), ((lastIndex << 1) | 1)); } else { primitiveFail(); } if (scanDisplayFlag) { affectedL = left; affectedR = bbW + dx; affectedT = top; affectedB = bbH + dy; } return null; } if (scanDisplayFlag) { copyBits(); } destX = nextDestX; /* begin storeInteger:ofObject:withValue: */ objectPointer = bitBltOop; integerValue = destX; if ((integerValue ^ (integerValue << 1)) >= 0) { longAtput(((((char *) objectPointer)) + 4) + (4 << 2), ((integerValue << 1) | 1)); } else { primitiveFail(); } lastIndex += 1; } /* begin returnAt:lastIndex:left:top: */ lastIndex1 = scanStop; stopCode = stObjectat(scanStopArray, 257); if (!successFlag) { goto l1; } /* begin storeInteger:ofObject:withValue: */ objectPointer3 = bitBltOop; if ((lastIndex1 ^ (lastIndex1 << 1)) >= 0) { longAtput(((((char *) objectPointer3)) + 4) + (15 << 2), ((lastIndex1 << 1) | 1)); } else { primitiveFail(); } if (scanDisplayFlag) { affectedL = left; affectedR = bbW + dx; affectedT = top; affectedB = bbH + dy; } l1: /* end returnAt:lastIndex:left:top: */; } int schedulerPointer(void) { return longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); } int sendSelectorToClass(int classPointer) { int ok; int probe; int p; int hash; int primBits; /* begin findNewMethodInClass: */ /* begin lookupInMethodCacheSel:class: */ hash = ((unsigned) (messageSelector ^ classPointer)) >> 2; probe = (hash & 511) + 1; for (p = 1; p <= 3; p += 1) { if (((methodCache[probe]) == messageSelector) && ((methodCache[probe + 512]) == classPointer)) { newMethod = methodCache[probe + (512 * 2)]; primitiveIndex = methodCache[probe + (512 * 3)]; ok = true; goto l1; } probe = ((((unsigned) hash) >> p) & 511) + 1; } ok = false; l1: /* end lookupInMethodCacheSel:class: */; if (!(ok)) { lookupMethodInClass(classPointer); /* begin primitiveIndexOf: */ primBits = (((unsigned) (longAt(((((char *) newMethod)) + 4) + (0 << 2)))) >> 1) & 805306879; if (primBits > 511) { primitiveIndex = (primBits & 511) + (((unsigned) primBits) >> 19); goto l2; } else { primitiveIndex = primBits; goto l2; } l2: /* end primitiveIndexOf: */; addToMethodCacheSelclassmethodprimIndex(messageSelector, classPointer, newMethod, primitiveIndex); } /* begin executeNewMethod */ if ((primitiveIndex == 0) || (!(primitiveResponse()))) { activateNewMethod(); /* begin quickCheckForInterrupts */ if ((interruptCheckCounter -= 1) <= 0) { checkForInterrupts(); } } } int sender(void) { return longAt(((((char *) theHomeContext)) + 4) + (0 << 2)); } int setInterpreter(int anInterpreter) { interpreterProxy = anInterpreter; } int setSizeOfFreeto(int chunk, int byteSize) { longAtput(chunk, (byteSize & 536870908) | 2); } int showDisplayBits(void) { int displayObj; int dispBits; int affectedRectL; int affectedRectR; int affectedRectT; int affectedRectB; int dispBitsIndex; int h; int w; int d; int successValue; if (deferDisplayUpdates) { return null; } displayObj = longAt(((((char *) specialObjectsOop)) + 4) + (14 << 2)); if (!(destForm == displayObj)) { return null; } /* begin success: */ successValue = (((((unsigned) (longAt(displayObj))) >> 8) & 15) <= 4) && ((lengthOf(displayObj)) >= 4); successFlag = successValue && successFlag; if (successFlag) { dispBits = longAt(((((char *) displayObj)) + 4) + (0 << 2)); w = fetchIntegerofObject(1, displayObj); h = fetchIntegerofObject(2, displayObj); d = fetchIntegerofObject(3, displayObj); } if (successFlag) { affectedRectL = affectedL; affectedRectR = affectedR; affectedRectT = affectedT; affectedRectB = affectedB; dispBitsIndex = dispBits + 4; ioShowDisplay(dispBitsIndex, w, h, d, affectedRectL, affectedRectR, affectedRectT, affectedRectB); } } int signExtend16(int int16) { if ((int16 & 32768) == 0) { return int16; } else { return int16 - 65536; } } int signalSemaphoreWithIndex(int index) { int i; if (index <= 0) { return null; } interruptCheckCounter = 0; for (i = 1; i <= semaphoresToSignalCount; i += 1) { if ((semaphoresToSignal[i]) == index) { return null; } } if (semaphoresToSignalCount < 25) { semaphoresToSignalCount += 1; semaphoresToSignal[semaphoresToSignalCount] = index; } } int sizeBitsOf(int oop) { int header; header = longAt(oop); if ((header & 3) == 0) { return (longAt(oop - 8)) & 4294967292U; } else { return header & 252; } } int sizeBitsOfSafe(int oop) { int header; int type; header = longAt(oop); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l1; } else { if ((header & 126976) == 0) { type = 1; goto l1; } else { type = 3; goto l1; } } l1: /* end rightType: */; if (type == 0) { return (longAt(oop - 8)) & 4294967292U; } else { return header & 252; } } int sizeHeader(int oop) { return longAt(oop - 8); } int sizeOfFree(int oop) { return (longAt(oop)) & 536870908; } int sizeOfSTArrayFromCPrimitive(void *cPtr) { int oop; int sz; int header; int fmt; oop = ((int) cPtr) - 4; if (!(isWordsOrBytes(oop))) { primitiveFail(); return 0; } /* begin lengthOf: */ header = longAt(oop); if ((header & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; } else { sz = header & 252; } fmt = (((unsigned) header) >> 8) & 15; if (fmt < 8) { return ((unsigned) (sz - 4)) >> 2; } else { return (sz - 4) - (fmt & 3); } return null; } int smoothPixatXfyfdxhdyhdxvdyvpixPerWordpixelMasksourceMap(int n, int xf, int yf, int dxh, int dyh, int dxv, int dyv, int srcPixPerWord, int sourcePixMask, int sourceMap) { int j; int sourcePix; int b; int x; int y; int bitsPerColor; int nPix; int maxPix; int i; int d; int rgb; int g; int r; int mask; int srcPix; int destPix; int d1; r = g = b = 0; maxPix = n * n; x = xf; y = yf; nPix = 0; for (i = 0; i <= (n - 1); i += 1) { for (j = 0; j <= (n - 1); j += 1) { sourcePix = (sourcePixAtXypixPerWord(((unsigned) ((x + (dxh * i)) + (dxv * j))) >> 14, ((unsigned) ((y + (dyh * i)) + (dyv * j))) >> 14, srcPixPerWord)) & sourcePixMask; if (!((combinationRule == 25) && (sourcePix == 0))) { nPix += 1; if (sourcePixSize < 16) { rgb = (longAt(((((char *) sourceMap)) + 4) + (sourcePix << 2))) & 16777215; } else { if (sourcePixSize == 32) { rgb = sourcePix & 16777215; } else { /* begin rgbMap:from:to: */ if ((d1 = 8 - 5) > 0) { mask = (1 << 5) - 1; srcPix = sourcePix << d1; mask = mask << d1; destPix = srcPix & mask; mask = mask << 8; srcPix = srcPix << d1; rgb = (destPix + (srcPix & mask)) + ((srcPix << d1) & (mask << 8)); goto l1; } else { if (d1 == 0) { rgb = sourcePix; goto l1; } if (sourcePix == 0) { rgb = sourcePix; goto l1; } d1 = 5 - 8; mask = (1 << 8) - 1; srcPix = ((unsigned) sourcePix) >> d1; destPix = srcPix & mask; mask = mask << 8; srcPix = ((unsigned) srcPix) >> d1; destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d1) & (mask << 8)); if (destPix == 0) { rgb = 1; goto l1; } rgb = destPix; goto l1; } l1: /* end rgbMap:from:to: */; } } r += (((unsigned) rgb) >> 16) & 255; g += (((unsigned) rgb) >> 8) & 255; b += rgb & 255; } } } if ((nPix == 0) || ((combinationRule == 25) && (nPix < (((int) maxPix >> 1))))) { return 0; } if (colorMap != nilObj) { bitsPerColor = cmBitsPerColor; } else { if (destPixSize == 16) { bitsPerColor = 5; } if (destPixSize == 32) { bitsPerColor = 8; } } d = 8 - bitsPerColor; rgb = (((((unsigned) (r / nPix)) >> d) << (bitsPerColor * 2)) + ((((unsigned) (g / nPix)) >> d) << bitsPerColor)) + (((unsigned) (b / nPix)) >> d); if (rgb == 0) { if (((r + g) + b) > 0) { rgb = 1; } } if (colorMap != nilObj) { return longAt(((((char *) colorMap)) + 4) + (rgb << 2)); } else { return rgb; } } int socketRecordSize(void) { return sizeof(SQSocket); } SQSocket * socketValueOf(int socketOop) { int socketIndex; int successValue; /* begin success: */ successValue = (((((unsigned) (longAt(socketOop))) >> 8) & 15) >= 8) && ((lengthOf(socketOop)) == (socketRecordSize())); successFlag = successValue && successFlag; if (successFlag) { socketIndex = socketOop + 4; return (SQSocket *) socketIndex; } else { return null; } } int sourcePixAtXypixPerWord(int x, int y, int srcPixPerWord) { int sourceWord; int index; if ((x < 0) || (x >= srcWidth)) { return 0; } if ((y < 0) || (y >= srcHeight)) { return 0; } index = ((y * sourceRaster) + (x / srcPixPerWord)) * 4; sourceWord = longAt((sourceBits + 4) + index); return ((unsigned) sourceWord) >> ((32 - sourcePixSize) - ((x % srcPixPerWord) * sourcePixSize)); } int sourceSkewAndPointerInit(void) { int dWid; int sxLowBits; int dxLowBits; int pixPerM1; pixPerM1 = pixPerWord - 1; sxLowBits = sx & pixPerM1; dxLowBits = dx & pixPerM1; if (hDir > 0) { dWid = ((bbW < (pixPerWord - dxLowBits)) ? bbW : (pixPerWord - dxLowBits)); preload = (sxLowBits + dWid) > pixPerM1; } else { dWid = ((bbW < (dxLowBits + 1)) ? bbW : (dxLowBits + 1)); preload = ((sxLowBits - dWid) + 1) < 0; } skew = (sxLowBits - dxLowBits) * destPixSize; if (preload) { if (skew < 0) { skew += 32; } else { skew -= 32; } } sourceIndex = (sourceBits + 4) + (((sy * sourceRaster) + (sx / (32 / sourcePixSize))) * 4); sourceDelta = 4 * ((sourceRaster * vDir) - (nWords * hDir)); if (preload) { sourceDelta -= 4 * hDir; } } int sourceWordwith(int sourceWord, int destinationWord) { return sourceWord; } int specialSelector(int index) { return longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (23 << 2))))) + 4) + ((index * 2) << 2)); } int splObj(int index) { return longAt(((((char *) specialObjectsOop)) + 4) + (index << 2)); } int stObjectat(int array, int index) { int hdr; int totalLength; int fmt; int fixedFields; int sz; int classFormat; int class; int ccIndex; hdr = longAt(array); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz = (longAt(array - 8)) & 4294967292U; } else { sz = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; goto l1; } else { totalLength = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l2; } if (fmt < 2) { fixedFields = totalLength; goto l2; } /* begin fetchClassOf: */ if ((array & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l3; } ccIndex = ((((unsigned) (longAt(array))) >> 12) & 31) - 1; if (ccIndex < 0) { class = (longAt(array - 4)) & 4294967292U; goto l3; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l3; } l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l2: /* end fixedFieldsOf:format:length: */; if (!((index >= 1) && (index <= (totalLength - fixedFields)))) { successFlag = false; } if (successFlag) { /* begin subscript:with:format: */ if (fmt < 4) { return longAt(((((char *) array)) + 4) + (((index + fixedFields) - 1) << 2)); } if (fmt < 8) { return positive32BitIntegerFor(longAt(((((char *) array)) + 4) + (((index + fixedFields) - 1) << 2))); } else { return (((byteAt(((((char *) array)) + 4) + ((index + fixedFields) - 1))) << 1) | 1); } return null; } else { return 0; } } int stObjectatput(int array, int index, int value) { int hdr; int totalLength; int fmt; int fixedFields; int valueToStore; int sz; int classFormat; int class; int ccIndex; hdr = longAt(array); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz = (longAt(array - 8)) & 4294967292U; } else { sz = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; goto l1; } else { totalLength = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l2; } if (fmt < 2) { fixedFields = totalLength; goto l2; } /* begin fetchClassOf: */ if ((array & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l3; } ccIndex = ((((unsigned) (longAt(array))) >> 12) & 31) - 1; if (ccIndex < 0) { class = (longAt(array - 4)) & 4294967292U; goto l3; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l3; } l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l2: /* end fixedFieldsOf:format:length: */; if (!((index >= 1) && (index <= (totalLength - fixedFields)))) { successFlag = false; } if (successFlag) { /* begin subscript:with:storing:format: */ if (fmt < 4) { /* begin storePointer:ofObject:withValue: */ if (array < youngStart) { possibleRootStoreIntovalue(array, value); } longAtput(((((char *) array)) + 4) + (((index + fixedFields) - 1) << 2), value); } else { if (fmt < 8) { valueToStore = positive32BitValueOf(value); if (successFlag) { longAtput(((((char *) array)) + 4) + (((index + fixedFields) - 1) << 2), valueToStore); } } else { if (!((value & 1))) { successFlag = false; } valueToStore = (value >> 1); if (!((valueToStore >= 0) && (valueToStore <= 255))) { successFlag = false; } if (successFlag) { byteAtput(((((char *) array)) + 4) + ((index + fixedFields) - 1), valueToStore); } } } } } int stSizeOf(int oop) { int hdr; int totalLength; int fmt; int fixedFields; int sz; int classFormat; int class; int ccIndex; hdr = longAt(oop); fmt = (((unsigned) hdr) >> 8) & 15; /* begin lengthOf:baseHeader:format: */ if ((hdr & 3) == 0) { sz = (longAt(oop - 8)) & 4294967292U; } else { sz = hdr & 252; } if (fmt < 8) { totalLength = ((unsigned) (sz - 4)) >> 2; goto l1; } else { totalLength = (sz - 4) - (fmt & 3); goto l1; } l1: /* end lengthOf:baseHeader:format: */; /* begin fixedFieldsOf:format:length: */ if ((fmt > 3) || (fmt == 2)) { fixedFields = 0; goto l2; } if (fmt < 2) { fixedFields = totalLength; goto l2; } /* begin fetchClassOf: */ if ((oop & 1)) { class = longAt(((((char *) specialObjectsOop)) + 4) + (5 << 2)); goto l3; } ccIndex = ((((unsigned) (longAt(oop))) >> 12) & 31) - 1; if (ccIndex < 0) { class = (longAt(oop - 4)) & 4294967292U; goto l3; } else { class = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (28 << 2))))) + 4) + (ccIndex << 2)); goto l3; } l3: /* end fetchClassOf: */; classFormat = (longAt(((((char *) class)) + 4) + (2 << 2))) - 1; fixedFields = (((((unsigned) classFormat) >> 11) & 192) + ((((unsigned) classFormat) >> 2) & 63)) - 1; l2: /* end fixedFieldsOf:format:length: */; return totalLength - fixedFields; } int stackIntegerValue(int offset) { int integerPointer; integerPointer = longAt(stackPointer - (offset * 4)); if ((integerPointer & 1)) { return (integerPointer >> 1); } else { primitiveFail(); return 0; } } int stackObjectValue(int offset) { int oop; oop = longAt(stackPointer - (offset * 4)); if ((oop & 1)) { primitiveFail(); return null; } return oop; } int stackPointerIndex(void) { return ((unsigned) ((stackPointer - activeContext) - 4)) >> 2; } int stackTop(void) { return longAt(stackPointer); } int stackValue(int offset) { return longAt(stackPointer - (offset * 4)); } int startField(void) { int typeBits; int childType; child = longAt(field); typeBits = child & 3; if ((typeBits & 1) == 1) { field -= 4; return 1; } if (typeBits == 0) { longAtput(field, parentField); parentField = field; return 2; } if (typeBits == 2) { if ((child & 126976) != 0) { child = child & 4294967292U; /* begin rightType: */ if ((child & 252) == 0) { childType = 0; goto l1; } else { if ((child & 126976) == 0) { childType = 1; goto l1; } else { childType = 3; goto l1; } } l1: /* end rightType: */; longAtput(field, child | childType); return 3; } else { child = longAt(field - 4); child = child & 4294967292U; longAtput(field - 4, parentField); parentField = (field - 4) | 1; return 2; } } } int startObj(void) { int oop; int lastFieldOffset; int header; int methodHeader; int sz; int fmt; int header1; int type; oop = child; if (oop < youngStart) { field = oop; return 3; } header = longAt(oop); if ((header & 2147483648U) == 0) { header = header & 4294967292U; header = (header | 2147483648U) | 2; longAtput(oop, header); /* begin lastPointerOf: */ fmt = (((unsigned) (longAt(oop))) >> 8) & 15; if (fmt < 4) { /* begin sizeBitsOfSafe: */ header1 = longAt(oop); /* begin rightType: */ if ((header1 & 252) == 0) { type = 0; goto l2; } else { if ((header1 & 126976) == 0) { type = 1; goto l2; } else { type = 3; goto l2; } } l2: /* end rightType: */; if (type == 0) { sz = (longAt(oop - 8)) & 4294967292U; goto l3; } else { sz = header1 & 252; goto l3; } l3: /* end sizeBitsOfSafe: */; lastFieldOffset = sz - 4; goto l1; } if (fmt < 12) { lastFieldOffset = 0; goto l1; } methodHeader = longAt(oop + 4); lastFieldOffset = (((((unsigned) methodHeader) >> 10) & 255) * 4) + 4; l1: /* end lastPointerOf: */; field = oop + lastFieldOffset; return 1; } else { field = oop; return 3; } } int startOfMemory(void) { return (int) memory; } int stopReason(void) { return stopCode; } int storeByteofObjectwithValue(int byteIndex, int oop, int valueByte) { return byteAtput(((((char *) oop)) + 4) + byteIndex, valueByte); } int storeContextRegisters(int activeCntx) { longAtput(((((char *) activeCntx)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeCntx)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); } int storeInstructionPointerValueinContext(int value, int contextPointer) { longAtput(((((char *) contextPointer)) + 4) + (1 << 2), ((value << 1) | 1)); } int storeIntegerofObjectwithValue(int fieldIndex, int objectPointer, int integerValue) { if ((integerValue ^ (integerValue << 1)) >= 0) { longAtput(((((char *) objectPointer)) + 4) + (fieldIndex << 2), ((integerValue << 1) | 1)); } else { primitiveFail(); } } int storePointerofObjectwithValue(int fieldIndex, int oop, int valuePointer) { if (oop < youngStart) { possibleRootStoreIntovalue(oop, valuePointer); } return longAtput(((((char *) oop)) + 4) + (fieldIndex << 2), valuePointer); } int storePointerUncheckedofObjectwithValue(int fieldIndex, int oop, int valuePointer) { return longAtput(((((char *) oop)) + 4) + (fieldIndex << 2), valuePointer); } int storeStackPointerValueinContext(int value, int contextPointer) { longAtput(((((char *) contextPointer)) + 4) + (2 << 2), ((value << 1) | 1)); } int storeWordofObjectwithValue(int fieldIndex, int oop, int valueWord) { return longAtput(((((char *) oop)) + 4) + (fieldIndex << 2), valueWord); } int subWordwith(int sourceWord, int destinationWord) { return sourceWord - destinationWord; } int subscriptwithformat(int array, int index, int fmt) { if (fmt < 4) { return longAt(((((char *) array)) + 4) + ((index - 1) << 2)); } if (fmt < 8) { return positive32BitIntegerFor(longAt(((((char *) array)) + 4) + ((index - 1) << 2))); } else { return (((byteAt(((((char *) array)) + 4) + (index - 1))) << 1) | 1); } } int subscriptwithstoringformat(int array, int index, int oopToStore, int fmt) { int valueToStore; if (fmt < 4) { /* begin storePointer:ofObject:withValue: */ if (array < youngStart) { possibleRootStoreIntovalue(array, oopToStore); } longAtput(((((char *) array)) + 4) + ((index - 1) << 2), oopToStore); } else { if (fmt < 8) { valueToStore = positive32BitValueOf(oopToStore); if (successFlag) { longAtput(((((char *) array)) + 4) + ((index - 1) << 2), valueToStore); } } else { if (!((oopToStore & 1))) { successFlag = false; } valueToStore = (oopToStore >> 1); if (!((valueToStore >= 0) && (valueToStore <= 255))) { successFlag = false; } if (successFlag) { byteAtput(((((char *) array)) + 4) + (index - 1), valueToStore); } } } } int success(int successValue) { successFlag = successValue && successFlag; } int sufficientSpaceAfterGC(int minFree) { incrementalGC(); if (((longAt(freeBlock)) & 536870908) < minFree) { if (signalLowSpace) { return false; } fullGC(); if (((longAt(freeBlock)) & 536870908) < (minFree + 15000)) { return false; } } return true; } int sufficientSpaceToAllocate(int bytes) { int minFree; minFree = (lowSpaceThreshold + bytes) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { return true; } else { return sufficientSpaceAfterGC(minFree); } } int sufficientSpaceToInstantiateindexableSize(int classOop, int size) { int okay; int format; int minFree; int minFree1; format = (((unsigned) ((longAt(((((char *) classOop)) + 4) + (2 << 2))) - 1)) >> 8) & 15; if ((size > 0) && (format < 2)) { return false; } if (format < 8) { /* begin sufficientSpaceToAllocate: */ minFree = (lowSpaceThreshold + (2500 + (size * 4))) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree) { okay = true; goto l1; } else { okay = sufficientSpaceAfterGC(minFree); goto l1; } l1: /* end sufficientSpaceToAllocate: */; } else { /* begin sufficientSpaceToAllocate: */ minFree1 = (lowSpaceThreshold + (2500 + size)) + 4; if (((longAt(freeBlock)) & 536870908) >= minFree1) { okay = true; goto l2; } else { okay = sufficientSpaceAfterGC(minFree1); goto l2; } l2: /* end sufficientSpaceToAllocate: */; } return okay; } int superclassOf(int classPointer) { return longAt(((((char *) classPointer)) + 4) + (0 << 2)); } int sweepPhase(void) { int entriesAvailable; int survivors; int firstFree; int oopHeader; int oop; int freeChunk; int oopHeaderType; int hdrBytes; int oopSize; int freeChunkSize; int extra; int chunk; int extra1; int type; int extra2; int type1; int extra3; entriesAvailable = fwdTableInit(); survivors = 0; freeChunk = null; firstFree = null; /* begin oopFromChunk: */ chunk = youngStart; /* begin extraHeaderBytes: */ type1 = (longAt(chunk)) & 3; if (type1 > 1) { extra3 = 0; } else { if (type1 == 1) { extra3 = 4; } else { extra3 = 8; } } extra1 = extra3; oop = chunk + extra1; while (oop < endOfMemory) { oopHeader = longAt(oop); oopHeaderType = oopHeader & 3; if (oopHeaderType == 3) { oopSize = oopHeader & 252; hdrBytes = 0; } else { if (oopHeaderType == 1) { oopSize = oopHeader & 252; hdrBytes = 4; } else { if (oopHeaderType == 0) { oopSize = (longAt(oop - 8)) & 4294967292U; hdrBytes = 8; } else { oopSize = oopHeader & 536870908; hdrBytes = 0; } } } if ((oopHeader & 2147483648U) == 0) { if (freeChunk != null) { freeChunkSize = (freeChunkSize + oopSize) + hdrBytes; } else { freeChunk = oop - hdrBytes; freeChunkSize = oopSize + (oop - freeChunk); if (firstFree == null) { firstFree = freeChunk; } } } else { longAtput(oop, oopHeader & 2147483647U); if (entriesAvailable > 0) { entriesAvailable -= 1; } else { firstFree = freeChunk; } if (freeChunk != null) { longAtput(freeChunk, (freeChunkSize & 536870908) | 2); } freeChunk = null; survivors += 1; } /* begin oopFromChunk: */ /* begin extraHeaderBytes: */ type = (longAt(oop + oopSize)) & 3; if (type > 1) { extra2 = 0; } else { if (type == 1) { extra2 = 4; } else { extra2 = 8; } } extra = extra2; oop = (oop + oopSize) + extra; } if (freeChunk != null) { longAtput(freeChunk, (freeChunkSize & 536870908) | 2); } if (!(oop == endOfMemory)) { error("sweep failed to find exact end of memory"); } if (firstFree == null) { error("expected to find at least one free object"); } else { compStart = firstFree; } if (!(displayBits == 0)) { oopHeader = longAt(displayBits); longAtput(displayBits, oopHeader & 2147483647U); } return survivors; } int synchronousSignal(int aSemaphore) { int excessSignals; if ((longAt(((((char *) aSemaphore)) + 4) + (0 << 2))) == nilObj) { excessSignals = fetchIntegerofObject(2, aSemaphore); /* begin storeInteger:ofObject:withValue: */ if (((excessSignals + 1) ^ ((excessSignals + 1) << 1)) >= 0) { longAtput(((((char *) aSemaphore)) + 4) + (2 << 2), (((excessSignals + 1) << 1) | 1)); } else { primitiveFail(); } } else { resume(removeFirstLinkOfList(aSemaphore)); } } int tallyIntoMapwith(int sourceWord, int destinationWord) { int pixVal; int mapIndex; int pixMask; int destShifted; int maskShifted; int i; int mask; int srcPix; int destPix; int d; int mask3; int srcPix1; int destPix1; int d1; if (colorMap == nilObj) { return destinationWord; } pixMask = (1 << destPixSize) - 1; destShifted = destinationWord; maskShifted = destMask; for (i = 1; i <= pixPerWord; i += 1) { if ((maskShifted & pixMask) > 0) { pixVal = destShifted & pixMask; if (destPixSize < 16) { mapIndex = pixVal; } else { if (destPixSize == 16) { /* begin rgbMap:from:to: */ if ((d = cmBitsPerColor - 5) > 0) { mask = (1 << 5) - 1; srcPix = pixVal << d; mask = mask << d; destPix = srcPix & mask; mask = mask << cmBitsPerColor; srcPix = srcPix << d; mapIndex = (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << cmBitsPerColor)); goto l1; } else { if (d == 0) { mapIndex = pixVal; goto l1; } if (pixVal == 0) { mapIndex = pixVal; goto l1; } d = 5 - cmBitsPerColor; mask = (1 << cmBitsPerColor) - 1; srcPix = ((unsigned) pixVal) >> d; destPix = srcPix & mask; mask = mask << cmBitsPerColor; srcPix = ((unsigned) srcPix) >> d; destPix = (destPix + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << cmBitsPerColor)); if (destPix == 0) { mapIndex = 1; goto l1; } mapIndex = destPix; goto l1; } l1: /* end rgbMap:from:to: */; } else { /* begin rgbMap:from:to: */ if ((d1 = cmBitsPerColor - 8) > 0) { mask3 = (1 << 8) - 1; srcPix1 = pixVal << d1; mask3 = mask3 << d1; destPix1 = srcPix1 & mask3; mask3 = mask3 << cmBitsPerColor; srcPix1 = srcPix1 << d1; mapIndex = (destPix1 + (srcPix1 & mask3)) + ((srcPix1 << d1) & (mask3 << cmBitsPerColor)); goto l2; } else { if (d1 == 0) { mapIndex = pixVal; goto l2; } if (pixVal == 0) { mapIndex = pixVal; goto l2; } d1 = 8 - cmBitsPerColor; mask3 = (1 << cmBitsPerColor) - 1; srcPix1 = ((unsigned) pixVal) >> d1; destPix1 = srcPix1 & mask3; mask3 = mask3 << cmBitsPerColor; srcPix1 = ((unsigned) srcPix1) >> d1; destPix1 = (destPix1 + (srcPix1 & mask3)) + ((((unsigned) srcPix1) >> d1) & (mask3 << cmBitsPerColor)); if (destPix1 == 0) { mapIndex = 1; goto l2; } mapIndex = destPix1; goto l2; } l2: /* end rgbMap:from:to: */; } } longAtput(((((char *) colorMap)) + 4) + (mapIndex << 2), (longAt(((((char *) colorMap)) + 4) + (mapIndex << 2))) + 1); } maskShifted = ((unsigned) maskShifted) >> destPixSize; destShifted = ((unsigned) destShifted) >> destPixSize; } return destinationWord; } int targetForm(void) { return destForm; } int temporary(int offset) { return longAt(((((char *) theHomeContext)) + 4) + ((offset + 6) << 2)); } int transferfromIndexofObjecttoIndexofObject(int count, int firstFrom, int fromOop, int firstTo, int toOop) { int toIndex; int fromIndex; int lastFrom; fromIndex = fromOop + (firstFrom * 4); toIndex = toOop + (firstTo * 4); lastFrom = fromIndex + (count * 4); while (fromIndex < lastFrom) { fromIndex += 4; toIndex += 4; longAtput(toIndex, longAt(fromIndex)); } } int transferTo(int newProc) { int sched; int oldProc; int valuePointer; int tmp; sched = longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2)); oldProc = longAt(((((char *) sched)) + 4) + (1 << 2)); /* begin storePointer:ofObject:withValue: */ valuePointer = activeContext; if (oldProc < youngStart) { possibleRootStoreIntovalue(oldProc, valuePointer); } longAtput(((((char *) oldProc)) + 4) + (1 << 2), valuePointer); /* begin storePointer:ofObject:withValue: */ if (sched < youngStart) { possibleRootStoreIntovalue(sched, newProc); } longAtput(((((char *) sched)) + 4) + (1 << 2), newProc); /* begin newActiveContext: */ /* begin storeContextRegisters: */ longAtput(((((char *) activeContext)) + 4) + (1 << 2), ((((instructionPointer - method) - (4 - 2)) << 1) | 1)); longAtput(((((char *) activeContext)) + 4) + (2 << 2), (((((((unsigned) ((stackPointer - activeContext) - 4)) >> 2) - 6) + 1) << 1) | 1)); if ((longAt(((((char *) newProc)) + 4) + (1 << 2))) < youngStart) { beRootIfOld(longAt(((((char *) newProc)) + 4) + (1 << 2))); } activeContext = longAt(((((char *) newProc)) + 4) + (1 << 2)); /* begin fetchContextRegisters: */ tmp = longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (3 << 2)); if ((tmp & 1)) { tmp = longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (5 << 2)); if (tmp < youngStart) { beRootIfOld(tmp); } } else { tmp = longAt(((((char *) newProc)) + 4) + (1 << 2)); } theHomeContext = tmp; receiver = longAt(((((char *) tmp)) + 4) + (5 << 2)); method = longAt(((((char *) tmp)) + 4) + (3 << 2)); tmp = ((longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (1 << 2))) >> 1); instructionPointer = ((method + tmp) + 4) - 2; tmp = ((longAt(((((char *) (longAt(((((char *) newProc)) + 4) + (1 << 2))))) + 4) + (2 << 2))) >> 1); stackPointer = ((longAt(((((char *) newProc)) + 4) + (1 << 2))) + 4) + (((6 + tmp) - 1) * 4); reclaimableContextCount = 0; } int unPop(int nItems) { stackPointer += nItems * 4; } int unknownBytecode(void) { error("Unknown bytecode"); } int upward(void) { int header; int type; if ((parentField & 1) == 1) { if (parentField == 3) { header = (longAt(field)) & 4294967292U; /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l1; } else { if ((header & 126976) == 0) { type = 1; goto l1; } else { type = 3; goto l1; } } l1: /* end rightType: */; longAtput(field, header + type); return 4; } else { child = field; field = parentField - 1; parentField = longAt(field); header = longAt(field + 4); /* begin rightType: */ if ((header & 252) == 0) { type = 0; goto l2; } else { if ((header & 126976) == 0) { type = 1; goto l2; } else { type = 3; goto l2; } } l2: /* end rightType: */; longAtput(field, child + type); field += 4; header = header & 4294967292U; longAtput(field, header + type); return 3; } } else { child = field; field = parentField; parentField = longAt(field); longAtput(field, child); field -= 4; return 1; } } int wakeHighestPriority(void) { int schedLists; int processList; int p; int sz; int header; schedLists = longAt(((((char *) (longAt(((((char *) (longAt(((((char *) specialObjectsOop)) + 4) + (3 << 2))))) + 4) + (1 << 2))))) + 4) + (0 << 2)); /* begin fetchWordLengthOf: */ /* begin sizeBitsOf: */ header = longAt(schedLists); if ((header & 3) == 0) { sz = (longAt(schedLists - 8)) & 4294967292U; goto l1; } else { sz = header & 252; goto l1; } l1: /* end sizeBitsOf: */; p = ((unsigned) (sz - 4)) >> 2; p -= 1; processList = longAt(((((char *) schedLists)) + 4) + (p << 2)); while ((longAt(((((char *) processList)) + 4) + (0 << 2))) == nilObj) { p -= 1; if (p < 0) { error("scheduler could not find a runnable process"); } processList = longAt(((((char *) schedLists)) + 4) + (p << 2)); } return removeFirstLinkOfList(processList); } int warpBits(void) { int ns; int skewWord; int mergeWord; int startBits; int yDelta; int smoothingCount; int sourceMapOop; int t; int i; int nSteps; int word; int halftoneWord; int deltaP12x; int deltaP12y; int deltaP43x; int deltaP43y; int pAx; int pAy; int pBx; int xDelta; int pBy; int integerPointer; ns = noSource; noSource = true; clipRange(); noSource = ns; if (noSource || ((bbW <= 0) || (bbH <= 0))) { affectedL = affectedR = affectedT = affectedB = 0; return null; } destMaskAndPointerInit(); /* begin warpLoop */ if (!((fetchWordLengthOf(bitBltOop)) >= (15 + 12))) { primitiveFail(); goto l2; } nSteps = height - 1; if (nSteps <= 0) { nSteps = 1; } pAx = fetchIntegerOrTruncFloatofObject(15, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 3, bitBltOop); deltaP12x = deltaFromtonSteps(pAx, t, nSteps); if (deltaP12x < 0) { pAx = t - (nSteps * deltaP12x); } pAy = fetchIntegerOrTruncFloatofObject(15 + 1, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 4, bitBltOop); deltaP12y = deltaFromtonSteps(pAy, t, nSteps); if (deltaP12y < 0) { pAy = t - (nSteps * deltaP12y); } pBx = fetchIntegerOrTruncFloatofObject(15 + 9, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 6, bitBltOop); deltaP43x = deltaFromtonSteps(pBx, t, nSteps); if (deltaP43x < 0) { pBx = t - (nSteps * deltaP43x); } pBy = fetchIntegerOrTruncFloatofObject(15 + 10, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 7, bitBltOop); deltaP43y = deltaFromtonSteps(pBy, t, nSteps); if (deltaP43y < 0) { pBy = t - (nSteps * deltaP43y); } if (!successFlag) { goto l2; } if (argumentCount == 2) { /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (1 * 4)); if ((integerPointer & 1)) { smoothingCount = (integerPointer >> 1); goto l1; } else { primitiveFail(); smoothingCount = 0; goto l1; } l1: /* end stackIntegerValue: */; sourceMapOop = longAt(stackPointer - (0 * 4)); if (sourceMapOop == nilObj) { if (sourcePixSize < 16) { primitiveFail(); goto l2; } } else { if ((fetchWordLengthOf(sourceMapOop)) < (1 << sourcePixSize)) { primitiveFail(); goto l2; } } } else { smoothingCount = 1; sourceMapOop = nilObj; } startBits = pixPerWord - (dx & (pixPerWord - 1)); nSteps = width - 1; if (nSteps <= 0) { nSteps = 1; } for (i = destY; i <= (clipY - 1); i += 1) { pAx += deltaP12x; pAy += deltaP12y; pBx += deltaP43x; pBy += deltaP43y; } for (i = 1; i <= bbH; i += 1) { xDelta = deltaFromtonSteps(pAx, pBx, nSteps); if (xDelta >= 0) { sx = pAx; } else { sx = pBx - (nSteps * xDelta); } yDelta = deltaFromtonSteps(pAy, pBy, nSteps); if (yDelta >= 0) { sy = pAy; } else { sy = pBy - (nSteps * yDelta); } for (word = destX; word <= (clipX - 1); word += 1) { sx += xDelta; sy += yDelta; } if (noHalftone) { halftoneWord = 4294967295U; } else { halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); } destMask = mask1; if (bbW < startBits) { skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(bbW, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); skewWord = ((((startBits - bbW) * destPixSize) < 0) ? ((unsigned) skewWord >> -((startBits - bbW) * destPixSize)) : ((unsigned) skewWord << ((startBits - bbW) * destPixSize))); } else { skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(startBits, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } for (word = 1; word <= nWords; word += 1) { mergeWord = mergewith(skewWord & halftoneWord, (longAt(destIndex)) & destMask); longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); destIndex += 4; if (word >= (nWords - 1)) { if (!(word == nWords)) { destMask = mask2; skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(pixPerWord, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } } else { destMask = 4294967295U; skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(pixPerWord, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } } pAx += deltaP12x; pAy += deltaP12y; pBx += deltaP43x; pBy += deltaP43y; destIndex += destDelta; } l2: /* end warpLoop */; if (hDir > 0) { affectedL = dx; affectedR = dx + bbW; } else { affectedL = (dx - bbW) + 1; affectedR = dx + 1; } if (vDir > 0) { affectedT = dy; affectedB = dy + bbH; } else { affectedT = (dy - bbH) + 1; affectedB = dy + 1; } } int warpLoop(void) { int skewWord; int mergeWord; int startBits; int yDelta; int smoothingCount; int sourceMapOop; int t; int i; int nSteps; int word; int halftoneWord; int deltaP12x; int deltaP12y; int deltaP43x; int deltaP43y; int pAx; int pAy; int pBx; int xDelta; int pBy; int integerPointer; if (!((fetchWordLengthOf(bitBltOop)) >= (15 + 12))) { return primitiveFail(); } nSteps = height - 1; if (nSteps <= 0) { nSteps = 1; } pAx = fetchIntegerOrTruncFloatofObject(15, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 3, bitBltOop); deltaP12x = deltaFromtonSteps(pAx, t, nSteps); if (deltaP12x < 0) { pAx = t - (nSteps * deltaP12x); } pAy = fetchIntegerOrTruncFloatofObject(15 + 1, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 4, bitBltOop); deltaP12y = deltaFromtonSteps(pAy, t, nSteps); if (deltaP12y < 0) { pAy = t - (nSteps * deltaP12y); } pBx = fetchIntegerOrTruncFloatofObject(15 + 9, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 6, bitBltOop); deltaP43x = deltaFromtonSteps(pBx, t, nSteps); if (deltaP43x < 0) { pBx = t - (nSteps * deltaP43x); } pBy = fetchIntegerOrTruncFloatofObject(15 + 10, bitBltOop); t = fetchIntegerOrTruncFloatofObject(15 + 7, bitBltOop); deltaP43y = deltaFromtonSteps(pBy, t, nSteps); if (deltaP43y < 0) { pBy = t - (nSteps * deltaP43y); } if (!successFlag) { return false; } if (argumentCount == 2) { /* begin stackIntegerValue: */ integerPointer = longAt(stackPointer - (1 * 4)); if ((integerPointer & 1)) { smoothingCount = (integerPointer >> 1); goto l1; } else { primitiveFail(); smoothingCount = 0; goto l1; } l1: /* end stackIntegerValue: */; sourceMapOop = longAt(stackPointer - (0 * 4)); if (sourceMapOop == nilObj) { if (sourcePixSize < 16) { return primitiveFail(); } } else { if ((fetchWordLengthOf(sourceMapOop)) < (1 << sourcePixSize)) { return primitiveFail(); } } } else { smoothingCount = 1; sourceMapOop = nilObj; } startBits = pixPerWord - (dx & (pixPerWord - 1)); nSteps = width - 1; if (nSteps <= 0) { nSteps = 1; } for (i = destY; i <= (clipY - 1); i += 1) { pAx += deltaP12x; pAy += deltaP12y; pBx += deltaP43x; pBy += deltaP43y; } for (i = 1; i <= bbH; i += 1) { xDelta = deltaFromtonSteps(pAx, pBx, nSteps); if (xDelta >= 0) { sx = pAx; } else { sx = pBx - (nSteps * xDelta); } yDelta = deltaFromtonSteps(pAy, pBy, nSteps); if (yDelta >= 0) { sy = pAy; } else { sy = pBy - (nSteps * yDelta); } for (word = destX; word <= (clipX - 1); word += 1) { sx += xDelta; sy += yDelta; } if (noHalftone) { halftoneWord = 4294967295U; } else { halftoneWord = longAt(halftoneBase + ((((dy + i) - 1) % halftoneHeight) * 4)); } destMask = mask1; if (bbW < startBits) { skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(bbW, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); skewWord = ((((startBits - bbW) * destPixSize) < 0) ? ((unsigned) skewWord >> -((startBits - bbW) * destPixSize)) : ((unsigned) skewWord << ((startBits - bbW) * destPixSize))); } else { skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(startBits, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } for (word = 1; word <= nWords; word += 1) { mergeWord = mergewith(skewWord & halftoneWord, (longAt(destIndex)) & destMask); longAtput(destIndex, (destMask & mergeWord) | ((~destMask) & (longAt(destIndex)))); destIndex += 4; if (word >= (nWords - 1)) { if (!(word == nWords)) { destMask = mask2; skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(pixPerWord, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } } else { destMask = 4294967295U; skewWord = warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(pixPerWord, xDelta, yDelta, deltaP12x, deltaP12y, smoothingCount, sourceMapOop); } } pAx += deltaP12x; pAy += deltaP12y; pBx += deltaP43x; pBy += deltaP43y; destIndex += destDelta; } } int warpSourcePixelsxDeltahyDeltahxDeltavyDeltavsmoothingsourceMap(int nPix, int xDeltah, int yDeltah, int xDeltav, int yDeltav, int n, int sourceMapOop) { int destWord; int sourcePix; int sourcePixMask; int destPixMask; int srcPixPerWord; int destPix; int i; int mask; int srcPix; int destPix1; int d; int mask3; int srcPix1; int destPix2; int d1; int mask4; int srcPix2; int destPix3; int d2; int mask5; int srcPix3; int destPix4; int d3; if (sourcePixSize == 32) { sourcePixMask = -1; } else { sourcePixMask = (1 << sourcePixSize) - 1; } if (destPixSize == 32) { destPixMask = -1; } else { destPixMask = (1 << destPixSize) - 1; } srcPixPerWord = 32 / sourcePixSize; destWord = 0; for (i = 1; i <= nPix; i += 1) { if (n > 1) { destPix = (smoothPixatXfyfdxhdyhdxvdyvpixPerWordpixelMasksourceMap(n, sx, sy, xDeltah / n, yDeltah / n, xDeltav / n, yDeltav / n, srcPixPerWord, sourcePixMask, sourceMapOop)) & destPixMask; } else { sourcePix = (sourcePixAtXypixPerWord(((unsigned) sx) >> 14, ((unsigned) sy) >> 14, srcPixPerWord)) & sourcePixMask; if (colorMap == nilObj) { if (destPixSize == sourcePixSize) { destPix = sourcePix; } else { if (sourcePixSize >= 16) { if (sourcePixSize == 16) { /* begin rgbMap:from:to: */ if ((d = 8 - 5) > 0) { mask = (1 << 5) - 1; srcPix = sourcePix << d; mask = mask << d; destPix1 = srcPix & mask; mask = mask << 8; srcPix = srcPix << d; destPix = (destPix1 + (srcPix & mask)) + ((srcPix << d) & (mask << 8)); goto l1; } else { if (d == 0) { destPix = sourcePix; goto l1; } if (sourcePix == 0) { destPix = sourcePix; goto l1; } d = 5 - 8; mask = (1 << 8) - 1; srcPix = ((unsigned) sourcePix) >> d; destPix1 = srcPix & mask; mask = mask << 8; srcPix = ((unsigned) srcPix) >> d; destPix1 = (destPix1 + (srcPix & mask)) + ((((unsigned) srcPix) >> d) & (mask << 8)); if (destPix1 == 0) { destPix = 1; goto l1; } destPix = destPix1; goto l1; } l1: /* end rgbMap:from:to: */; } else { /* begin rgbMap:from:to: */ if ((d1 = 5 - 8) > 0) { mask3 = (1 << 8) - 1; srcPix1 = sourcePix << d1; mask3 = mask3 << d1; destPix2 = srcPix1 & mask3; mask3 = mask3 << 5; srcPix1 = srcPix1 << d1; destPix = (destPix2 + (srcPix1 & mask3)) + ((srcPix1 << d1) & (mask3 << 5)); goto l2; } else { if (d1 == 0) { destPix = sourcePix; goto l2; } if (sourcePix == 0) { destPix = sourcePix; goto l2; } d1 = 8 - 5; mask3 = (1 << 5) - 1; srcPix1 = ((unsigned) sourcePix) >> d1; destPix2 = srcPix1 & mask3; mask3 = mask3 << 5; srcPix1 = ((unsigned) srcPix1) >> d1; destPix2 = (destPix2 + (srcPix1 & mask3)) + ((((unsigned) srcPix1) >> d1) & (mask3 << 5)); if (destPix2 == 0) { destPix = 1; goto l2; } destPix = destPix2; goto l2; } l2: /* end rgbMap:from:to: */; } } else { destPix = sourcePix & destPixMask; } } } else { if (sourcePixSize >= 16) { if (sourcePixSize == 16) { /* begin rgbMap:from:to: */ if ((d2 = cmBitsPerColor - 5) > 0) { mask4 = (1 << 5) - 1; srcPix2 = sourcePix << d2; mask4 = mask4 << d2; destPix3 = srcPix2 & mask4; mask4 = mask4 << cmBitsPerColor; srcPix2 = srcPix2 << d2; sourcePix = (destPix3 + (srcPix2 & mask4)) + ((srcPix2 << d2) & (mask4 << cmBitsPerColor)); goto l3; } else { if (d2 == 0) { sourcePix = sourcePix; goto l3; } if (sourcePix == 0) { sourcePix = sourcePix; goto l3; } d2 = 5 - cmBitsPerColor; mask4 = (1 << cmBitsPerColor) - 1; srcPix2 = ((unsigned) sourcePix) >> d2; destPix3 = srcPix2 & mask4; mask4 = mask4 << cmBitsPerColor; srcPix2 = ((unsigned) srcPix2) >> d2; destPix3 = (destPix3 + (srcPix2 & mask4)) + ((((unsigned) srcPix2) >> d2) & (mask4 << cmBitsPerColor)); if (destPix3 == 0) { sourcePix = 1; goto l3; } sourcePix = destPix3; goto l3; } l3: /* end rgbMap:from:to: */; } else { /* begin rgbMap:from:to: */ if ((d3 = cmBitsPerColor - 8) > 0) { mask5 = (1 << 8) - 1; srcPix3 = sourcePix << d3; mask5 = mask5 << d3; destPix4 = srcPix3 & mask5; mask5 = mask5 << cmBitsPerColor; srcPix3 = srcPix3 << d3; sourcePix = (destPix4 + (srcPix3 & mask5)) + ((srcPix3 << d3) & (mask5 << cmBitsPerColor)); goto l4; } else { if (d3 == 0) { sourcePix = sourcePix; goto l4; } if (sourcePix == 0) { sourcePix = sourcePix; goto l4; } d3 = 8 - cmBitsPerColor; mask5 = (1 << cmBitsPerColor) - 1; srcPix3 = ((unsigned) sourcePix) >> d3; destPix4 = srcPix3 & mask5; mask5 = mask5 << cmBitsPerColor; srcPix3 = ((unsigned) srcPix3) >> d3; destPix4 = (destPix4 + (srcPix3 & mask5)) + ((((unsigned) srcPix3) >> d3) & (mask5 << cmBitsPerColor)); if (destPix4 == 0) { sourcePix = 1; goto l4; } sourcePix = destPix4; goto l4; } l4: /* end rgbMap:from:to: */; } } destPix = (longAt(((((char *) colorMap)) + 4) + (sourcePix << 2))) & destPixMask; } } destWord = (destWord << destPixSize) | destPix; sx += xDeltah; sy += yDeltah; } return destWord; } int writeImageFile(int imageBytes) { sqImageFile f; int i; int bytesWritten; int headerStart; int headerSize; headerStart = 0; headerSize = 64; f = sqImageFileOpen(imageName, "wb"); if (f == null) { /* begin success: */ successFlag = false && successFlag; return null; } /* Note: on Unix systems one could put an exec command here, padded to 512 bytes */; sqImageFileSeek(f, headerStart); putLongtoFile(6502, f); putLongtoFile(headerSize, f); putLongtoFile(imageBytes, f); putLongtoFile(startOfMemory(), f); putLongtoFile(specialObjectsOop, f); putLongtoFile(lastHash, f); putLongtoFile(ioScreenSize(), f); putLongtoFile(fullScreenFlag, f); for (i = 1; i <= 8; i += 1) { putLongtoFile(0, f); } if (!(successFlag)) { sqImageFileClose(f); return null; } sqImageFileSeek(f, headerStart + headerSize); bytesWritten = sqImageFileWrite(memory, sizeof(unsigned char), imageBytes, f); /* begin success: */ successFlag = (bytesWritten == imageBytes) && successFlag; sqImageFileClose(f); dir_SetMacFileTypeAndCreator(imageName, strlen(imageName), "STim", "FAST"); }
25.306733
328
0.592636
[ "object" ]
465ead5342da5ac483c9cc5d85935ff796060ce3
511
h
C
Engine/src/Gameplay/Components/Projectile.h
venCjin/GameEngineProject
d8bdc8fc7236d74f6ecb5e8a8a5211699cc84d22
[ "Apache-2.0" ]
1
2020-03-04T20:46:40.000Z
2020-03-04T20:46:40.000Z
Engine/src/Gameplay/Components/Projectile.h
venCjin/GameEngineProject
d8bdc8fc7236d74f6ecb5e8a8a5211699cc84d22
[ "Apache-2.0" ]
null
null
null
Engine/src/Gameplay/Components/Projectile.h
venCjin/GameEngineProject
d8bdc8fc7236d74f6ecb5e8a8a5211699cc84d22
[ "Apache-2.0" ]
null
null
null
#pragma once #include "Core/ISerializable.h" #include "Gameplay/Components/Mesh.h" #include "Gameplay/GameObject.h" namespace sixengine { class Projectile : ISerializable { const float speed = 80.0f; public: Projectile(glm::vec3 dir, GameObject* go = nullptr) : speedDir(dir * speed) {} glm::vec3 speedDir; void SetDirection(glm::vec3 dir) { speedDir = dir * speed; } virtual void Load(std::iostream& stream) override {} virtual void Save(std::iostream& stream) override {} }; }
18.25
54
0.692759
[ "mesh" ]
46635a24ffb9da5f2f235df21b5fedc4490aa90c
1,028
h
C
Game.h
karanjoisher/Pong
08a5caccd1f1328aeac62825852b9bd344244b4e
[ "CC0-1.0" ]
null
null
null
Game.h
karanjoisher/Pong
08a5caccd1f1328aeac62825852b9bd344244b4e
[ "CC0-1.0" ]
null
null
null
Game.h
karanjoisher/Pong
08a5caccd1f1328aeac62825852b9bd344244b4e
[ "CC0-1.0" ]
null
null
null
#pragma once #include "GameObjectManager.h" class Game { public: static int SCREEN_WIDTH; static int SCREEN_HEIGHT; static VisibleGameObject *paddle1; static VisibleGameObject *paddle2; static VisibleGameObject *background; static VisibleGameObject *ball; static void multiplayerSetup(); static void AIsetup(); static void start(); static sf::RenderWindow _mainWindow; struct Settings { static std::vector<std::string> difficultyOptions; static std::string difficulty; static int winningPoints; static int maximumPoints; static int minimumPoints; static void incrementPoints(); static void decrementDifficulty(); static void decrementPoints(); static void incrementDifficulty(); private: static int currentDifficultyIndex; }; //static float deltaTime; static sf::Clock frameClock; static GameObjectManager manager; enum GameState {Uninitialized, ShowingMenu, Playing, GameOver, Exiting}; static GameState _gameState; private: static void setField(); static void gameLoop(); };
22.347826
73
0.772374
[ "vector" ]
4667478cc90f87cc73b554eb8147f076141a14ab
5,940
c
C
src/altivecbase64.c
user959/fastbase64
fccfda947a7ab0e4defe66e35ed9b69c4dc72451
[ "BSD-2-Clause" ]
375
2016-12-01T04:13:31.000Z
2022-02-24T00:48:24.000Z
src/altivecbase64.c
ZHaskell/fastbase64
7feccb6ecf3ae475141b316e524a18093fb72e56
[ "BSD-2-Clause" ]
11
2017-01-08T19:35:14.000Z
2021-04-06T23:24:33.000Z
src/altivecbase64.c
ZHaskell/fastbase64
7feccb6ecf3ae475141b316e524a18093fb72e56
[ "BSD-2-Clause" ]
29
2017-01-05T00:45:57.000Z
2022-01-28T19:46:48.000Z
#include "altivecbase64.h" #include <altivec.h> #include <stdbool.h> typedef __attribute__((__aligned__(16), __may_alias__)) vector unsigned char uint8x16; typedef __vector unsigned short uint16x8; typedef __vector unsigned int uint32x4; static inline uint8x16 set1_uint8x16(unsigned char a) { return (uint8x16){a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a}; } static inline uint8x16 set1_uint16x8(unsigned short a) { return (uint8x16)(uint16x8){a, a, a, a, a, a, a, a}; } static inline uint8x16 set1_uint32x4(int a) { return (uint8x16)(uint32x4){a, a, a, a}; } static inline uint8x16 madd_uint8x16(uint8x16 a, uint8x16 b) { const uint32x4 zero = {0, 0, 0, 0}; return (uint8x16)vec_vmsumuhm((uint16x8)a, (uint16x8)b, zero); } static inline uint8x16 enc_reshuffle(const uint8x16 input) { const uint8x16 perm_mask = {1, 0, 2, 1, 4, 3, 5, 4, 7, 6, 8, 7, 10, 9, 11, 10}; const uint8x16 in = vec_perm(input, input, perm_mask); const uint8x16 t0 = vec_and(in, (uint8x16)set1_uint32x4(0x0fc0fc00)); const uint8x16 t1 = vec_sr((uint16x8)t0, (uint16x8)set1_uint32x4(0x6000a)); const uint8x16 t2 = vec_and(in, (uint8x16)set1_uint32x4(0x003f03f0)); const uint8x16 t3 = vec_sl((uint16x8)t2, (uint16x8)set1_uint32x4(0x80004)); return vec_or(t1, t3); } static inline uint8x16 enc_translate(const uint8x16 in) { const uint8x16 lut = {65, 71, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -19, -16, 0, 0}; uint8x16 indices = vec_subs(in, set1_uint8x16(51)); const uint8x16 mask = vec_cmpgt((__vector char)in, (__vector char)set1_uint8x16(25)); indices = vec_sub(indices, mask); const uint8x16 out = vec_add(in, vec_perm(lut, lut, indices)); return out; } static inline uint8x16 dec_reshuffle(uint8x16 in) { const uint8x16 mask = set1_uint16x8(0x3f); // for each 4 bytes [00dddddd|00cccccc|00bbbbbb|00aaaaaa] we do: // [00000000|00cccccc|00000000|00aaaaaa] const uint8x16 c_and_a = vec_and(in, mask); // [0000cccc|cc000000|0000aaaa|aa000000] const uint8x16 c_and_a_shifted = vec_sl((uint16x8)c_and_a, (uint16x8)set1_uint16x8(6)); // [00000000|00dddddd|00000000|00bbbbbb] const uint8x16 d_and_b_shifted = vec_sr((uint16x8)in, (uint16x8)set1_uint16x8(8)); // [0000cccc|ccdddddd|0000aaaa|aabbbbbb] const uint8x16 cd_and_ab = vec_or(c_and_a_shifted, d_and_b_shifted); // [00000000|aaaaaabb|bbbbcccc|ccdddddd] const uint8x16 abcd = madd_uint8x16(cd_and_ab, set1_uint32x4(0x00011000)); // [4 zero bytes|next 3 bytes|next 3 bytes|next 3 bytes|ddddddcc|ccccbbbb|bbaaaaaa] return vec_perm(abcd, abcd, (uint8x16){2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1}); } size_t altivec_base64_encode(char *dest, const char *str, size_t len) { const char *const dest_orig = dest; uint8x16 inputvector; // pick off 12 bytes at a time for as long as we can. // But because we read 16 bytes at a time, ensure we have enough room to // do a full 16-byte read without segfaulting: while (len >= 16) { inputvector = vec_vsx_ld(0, (signed int const *)str); inputvector = enc_reshuffle(inputvector); inputvector = enc_translate(inputvector); vec_vsx_st(inputvector, 0, (uint8x16 *)dest); dest += 16; str += 12; len -= 12; } size_t scalarret = chromium_base64_encode(dest, str, len); if (scalarret == MODP_B64_ERROR) return MODP_B64_ERROR; return (dest - dest_orig) + scalarret; } size_t altivec_base64_decode(char *out, const char *src, size_t srclen) { char *out_orig = out; // pick off 16 bytes at a time for as long as we can, // but make sure that we quit before seeing any == markers at the end of // the string. Also, because we write 4 zero bytes at the end of the output // ensure that there are at least 6 valid bytes of input data remaining to // close the gap. 16 + 2 + 6 = 24 bytes: while (srclen >= 24) { // The input consists of six character sets in the Base64 alphabet, // which we need to map back to the 6-bit values they represent. // There are three ranges, two singles, and then there's the rest. // // # From To Add Characters // 1 [43] [62] +19 + // 2 [47] [63] +16 / // 3 [48..57] [52..61] +4 0..9 // 4 [65..90] [0..25] -65 A..Z // 5 [97..122] [26..51] -71 a..z // (6) Everything else => invalid input uint8x16 str = vec_vsx_ld(0, (signed int const *)src); // code by @aqrit from // https://github.com/WojciechMula/base64simd/issues/3#issuecomment-271137490 // transated into AltiVec const uint8x16 lut_lo = {0x15, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x13, 0x1A, 0x1B, 0x1B, 0x1B, 0x1A}; const uint8x16 lut_hi = {0x10, 0x10, 0x01, 0x02, 0x04, 0x08, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}; const uint8x16 lut_roll = {0, 16, 19, 4, -65, -65, -71, -71, 0, 0, 0, 0, 0, 0, 0, 0}; const uint8x16 mask_2F = set1_uint8x16(0x2f); // lookup uint8x16 hi_nibbles = vec_sr((uint32x4)str, vec_splat_u32(4)); uint8x16 lo_nibbles = vec_and(str, mask_2F); const uint8x16 lo = vec_perm(lut_lo, lut_lo, lo_nibbles); const uint8x16 eq_2F = vec_cmpeq(str, mask_2F); hi_nibbles = vec_and(hi_nibbles, mask_2F); const uint8x16 hi = vec_perm(lut_hi, lut_hi, hi_nibbles); const uint8x16 roll = vec_perm(lut_roll, lut_roll, vec_add(eq_2F, hi_nibbles)); if (vec_any_ne(vec_and(lo, hi), set1_uint8x16(0))) { break; } str = vec_add(str, roll); // end of copied function srclen -= 16; src += 16; // end of inlined function // Reshuffle the input to packed 12-byte output format: str = dec_reshuffle(str); vec_vsx_st(str, 0, (uint8x16 *)out); out += 12; } size_t scalarret = chromium_base64_decode(out, src, srclen); if (scalarret == MODP_B64_ERROR) return MODP_B64_ERROR; return (out - out_orig) + scalarret; }
40.135135
98
0.667677
[ "vector" ]