void ExplodeOnHitComponentLoader::BindValues() { std::string istr; if( Json::GetStr( ( *mSetters )["explosion_projectile"], istr ) ) { Bind<int32_t>( &ExplodeOnHitComponent::SetExplosionProjectile, AutoId( istr ) ); } Bind( "count", func_int32_t( &ExplodeOnHitComponent::SetCount ) ); Bind( "scatter", func_double( &ExplodeOnHitComponent::SetExplosionScatter ) ); if( Json::GetStr( ( *mSetters )["detonator_material"], istr ) ) { Bind<int32_t>( &ExplodeOnHitComponent::SetDetonatorMaterial, AutoId( istr ) ); } if( Json::GetStr( ( *mSetters )["distribution"], istr ) ) { Bind<ExplodeDistributionType::Type>( &ExplodeOnHitComponent::SetDistribution, mExplodeDistributionType( AutoId( istr ) ) ); } Bind( "secs_to_end_variance", func_double( &ExplodeOnHitComponent::SetSecsToEndVariance ) ); Bind( "position_variance", func_int32_t( &ExplodeOnHitComponent::SetPositionVariance ) ); Bind( "speed_variance", func_double( &ExplodeOnHitComponent::SetSpeedVariance ) ); Bind( "add_actor_radius", func_bool( &ExplodeOnHitComponent::SetAddActorRadius ) ); }
void WeaponLoader::BindValues() { L2( "Bind Weapon values \n" ); Bind( "shoot_cooldown", func_double( &Weapon::SetShootCooldown ) ); Bind( "shoot_alt_cooldown", func_double( &Weapon::SetShootAltCooldown ) ); Bind( "bullets", func_double( &Weapon::SetBullets ) ); Bind( "bullets", func_double( &Weapon::SetBulletsMax ) ); Bind( "shot_cost", func_int32_t( &Weapon::SetShotCost ) ); Bind( "shot_cost_alt", func_int32_t( &Weapon::SetShotCostAlt ) ); Bind( "reload_time", func_double( &Weapon::SetReloadTimeMax ) ); Bind( "static_reload", func_double( &Weapon::SetStaticReload ) ); Bind( "position_x", func_double(&Weapon::SetPositionX)); Bind( "position_y", func_double(&Weapon::SetPositionY)); std::string istr; if (Json::GetStr((*mSetters)["muzzle"], istr)) { Bind<int32_t>(&Weapon::SetMuzzleId, AutoId(istr)); } if (Json::GetStr((*mSetters)["muzzle_alt"], istr)) { Bind<int32_t>(&Weapon::SetMuzzleAltId, AutoId(istr)); } Scatter scatter; Json::GetDouble( ( *mSetters )["scatter_increase"], scatter.mIncrease ); Json::GetDouble( ( *mSetters )["scatter_alt_increase"], scatter.mAltIncrease ); Json::GetDouble( ( *mSetters )["scatter_chill"], scatter.mChill ); Json::GetDouble( ( *mSetters )["scatter_magic_number"], scatter.mMagicNumber ); L2( "Scatter in: %f %f %f %f", scatter.mIncrease, scatter.mAltIncrease, scatter.mChill, scatter.mMagicNumber ); Bind<Scatter>( &Weapon::SetScatter, scatter ); if (Json::GetStr( (*mSetters)["shot"], istr )) { Bind<int32_t>( &Weapon::SetShotId, AutoId( istr ) ); } if (Json::GetStr( (*mSetters)["shot_alt"], istr )) { Bind<int32_t>( &Weapon::SetShotAltId, AutoId( istr ) ); } Limited<double> sumBullets; sumBullets.Load( (*mSetters)["sum_bullets"] ); Bind<Limited<double>>(&Weapon::InitSumBullets, sumBullets); }
int main() { //****************************************** //doubles //These are loooong floats with and without exponents float looong_simple_float = 1.111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111; func_float(looong_simple_float); float looong_simple_float_exp = 1.21111111111111111111111111111111111111111111111111111111111111111111111111111e11; func_float(looong_simple_float_exp); //These are loooong floats with and without exponents. //These *have* to be floats (in internal representation), because of the subscripts f float looong_simple_float_subscript = 1.311111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111f; func_float(looong_simple_float_subscript); float looong_simple_float_exp_subscript = 1.411111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111e11111111f; func_float(looong_simple_float_exp_subscript); //****************************************** //doubles //These are loooong doubles with and without exponents double looong_simple_double = 2.122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222; func_double(looong_simple_double); double looong_simple_double_exp = 2.22222222222222222222222222222222222222222222222222222222222222222222222222222e122; func_double(looong_simple_double_exp); //These are loooong doubles with and without exponents. //These *have* to be doubles (in internal representation), because of no subscript double looong_simple_double_subscript = 2.322222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222f; func_double(looong_simple_double_subscript); double looong_simple_double_exp_subscript = 2.422222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222e12f; func_double(looong_simple_double_exp_subscript); //loong long doubles //These are loooong long doubles with and without exponents long double looong_simple_long_double = 3.133333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333; func_long_double(looong_simple_long_double); long double looong_simple_long_double_exp = 3.23333333333333333333333333333333333333333333333333333333333333333333333333333e133; func_long_double(looong_simple_long_double_exp); //These are loooong long doubles with and without exponents. //These *have* to be long doubles (in internal representation), because of the subscripts l ////lookout for the L or l at the end long double looong_simple_long_double_subscript = 3.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333L; func_long_double(looong_simple_long_double_subscript); long double looong_simple_long_double_exp_subscript = 3.433333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333e133L; func_long_double(looong_simple_long_double_exp_subscript); printf("Hello\n"); return 1; }
int main () { int x = 17; int *xP, **xPP; char buf[200]; char *s; int *ai; float *af; func_intptr(&x); func_intptr_ret(&x); func_string("zero\0xxxxxxxxxxxxxx"); func_strlen(buf); extern int func_arg0(char *); func_arg0(buf); printf("%s\n", buf); func_strfixed(buf); printf("%s\n", buf); x = 80; xP = &x; xPP = &xP; func_ppp(&xPP); s = (char*) malloc(100); strcpy(s, "Dude"); func_stringp(&s); func_enum(BLUE); func_short(-8, -9); func_ushort(33, 34); float f = func_float(3.4, -3.4); double d = func_double(3.4, -3.4); func_typedef(BLUE); ai = (int*) calloc(sizeof(int), 8); for (x = 0; x < 8; x++) ai[x] = 10 + x; func_arrayi(ai, 8); func_arrayi(ai, 2); af = (float*) calloc(sizeof(float), 8); for (x = 0; x < 8; x++) af[x] = 10.1 + x; func_arrayf(af, 8); func_arrayf(af, 2); { struct { int simple; int alen; int slen; struct { int a; int b; }* array; struct { int a; int b; } seq[3]; char* str; } x; x.simple = 89; x.alen = 2; x.array = malloc(800); x.array[0].a = 1; x.array[0].b = 10; x.array[1].a = 3; x.array[1].b = 30; x.seq[0].a = 4; x.seq[0].b = 40; x.seq[1].a = 5; x.seq[1].b = 50; x.seq[2].a = 6; x.seq[2].b = 60; x.slen = 3; x.str = "123junk"; func_struct(&x); } { char x[10] = {}; char y[10] = {}; func_call(x, y, call_func_work); } struct S2 { float f; char a; char b; }; struct S3 { char a[6]; float f; }; struct S2 func_struct_2(int, struct S3 s3, double d); func_struct_2(17, (struct S3){ "ABCDE", 0.25 }, 0.5);
void VisualBoxMultiplierComponentLoader::BindValues() { Bind( "width", func_double( &VisualBoxMultiplierComponent::SetWidth ) ); Bind( "height", func_double( &VisualBoxMultiplierComponent::SetHeight ) ); }
void MoveComponentLoader::BindValues() { Bind( "speed", func_double( &MoveComponent::SetSpeed ) ); }
int main(int argc, char* argv[]) { void *handle; char *error; int i; int esp = 0; void *func; handle = dlopen(argv[1], RTLD_NOW); if(0 == handle) { printf("Can't find library: %s\n", argv[1]); return -1; } func = dlsym(handle, argv[2]); if ((error = dlerror()) != NULL) { printf("Find symbol %s error: %s\n", argv[2], error); goto exit_runso; } switch (argv[argc - 1][0]) { case 'i': { int (*func_int)() = func; SETUP_STACK; printf("%p\n", func_int); int ret = func_int(); RESOTRE_STACK; printf("ret = %d\n", ret); break; } case 'd': { double (*func_double)() = func; SETUP_STACK; double ret = func_double(); RESOTRE_STACK; printf("ret = %f\n", ret); break; } case 's': { char* (*func_str)() = func; SETUP_STACK; char *ret = func_str(); RESOTRE_STACK; printf("ret = %s\n", ret); break; } case 'v': { void (*func_void)() = func; SETUP_STACK; func_void(); RESOTRE_STACK; printf("ret = void"); break; } }/* end of switch */ exit_runso: dlclose(handle); }
void PositionComponentLoader::BindValues() { Bind( "x", func_double( &PositionComponent::SetX ) ); Bind( "y", func_double( &PositionComponent::SetY ) ); SetterFuncList_t setterfunc = mSetterFuncList; }